HLA: Hadamard Linear Attention

Hanno Ackermann, Hong Cai, Mohsen Ghafoorian, Amirhossein Habibian · DOI

Abstract

The attention mechanism is an important reason for the success of transformers. It relies on computing pairwise relations between tokens. To reduce the high computational cost of standard quadratic attention, linear attention has been proposed as an efficient approximation. It employs kernel functions that are applied independently to the inputs before the pairwise similarities are calculated. That allows for an efficient computational procedure which, however, amounts to a low-degree rational function approximating softmax. We propose Hadamard Linear Attention (HLA). Unlike previous works on linear attention, the nonlinearity in HLA is not applied separately to queries and keys, but, analogously to standard softmax attention, after the pairwise similarities have been computed. It will be shown that the proposed nonlinearity amounts to a higher-degree rational function to approximate softmax. An efficient computational scheme for the proposed method is derived that is similar to that of standard linear attention. In contrast to other approaches, no time-consuming tensor reshaping is necessary to apply the proposed algorithm. The effectiveness of the approach is demonstrated by applying it to a large diffusion transformer model for video generation, an application that involves very large amounts of tokens.

Introduction: The Quadratic Bottleneck

Standard Softmax attention is $O(N^2)$, meaning computational requirements quadruple as sequence lengths double. This "quadratic tax" is particularly prohibitive for high-resolution video generation, where token counts are massive. While traditional Linear Attention reduces complexity to $O(N)$ using separable kernels, it introduces a "low-rank bottleneck." By applying nonlinearities to Queries ($Q$) and Keys ($K$) before interaction, these models are limited to low-degree rational function approximations of Softmax, often resulting in blurred details and poor dependency capture.

Methodology: Hadamard Linear Attention

HLA bridges the performance gap between efficient linear models and expressive quadratic ones through three core innovations:

  1. Post-Interaction Nonlinearity: HLA applies nonlinearity after pairwise similarities are computed, mimicking standard Softmax behavior.
  2. Hadamard Product of Terms: By taking the element-wise (Hadamard) product of $F$ different query-key interactions, HLA achieves a much higher-degree rational function. For instance, HLA with 3 factors ($F=3$) reaches a degree-9 approximation, providing the "mathematical wiggle room" needed to approximate the sharp peaks of Softmax.
  3. Tensorial Efficiency: The authors derive a scheme where the Hadamard product of dot products is computed via tensorial outer products. This maintains $O(N)$ complexity using standard, hardware-friendly operations like einsum without requiring custom CUDA kernels.

Experimental Evaluation and Results

The researchers integrated HLA into the Wan2.1 1.3B video diffusion model and evaluated it using the VBench suite. The model was trained on a combination of the OpenSoraPlan dataset and synthetic videos.

Video generation samples from the HLA-integrated Wan2.1 model showing high-quality results across various prompts.

Key findings include:

  • Compute Efficiency: On sequences of ~32k tokens, HLA-3F achieved performance nearly identical to quadratic baselines while requiring up to 90% less compute.
  • Quality and Detail: HLA variants scored within 1-2 points of state-of-the-art quadratic models on VBench (e.g., 81.42 vs 83.31). To preserve high-frequency details, a specific modulation block was added to restore fine textures often lost in linear approximations.
Diverse video outputs demonstrating the model's ability to maintain temporal consistency and fine details in complex subjects like machinery and architecture.

Key Insights and Future Work

HLA demonstrates that the "degree" of polynomial approximation is a critical factor in attention performance. By relaxing the low-rank constraint, HLA allows attention matrices to represent complex relationships without the quadratic cost. While the complexity grows polynomially with the number of factors ($F$), the current balance provides a significant leap in efficiency for long-form generative AI.

Future work may explore hybridizing HLA with windowing techniques or the "delta rule" to further push the boundaries of computationally feasible, high-resolution video generation on consumer-grade hardware.

Summary updated

BibTeX
@misc{ackermann2026hla,
  author = {Hanno Ackermann and Hong Cai and Mohsen Ghafoorian and Amirhossein Habibian},
  title = {{HLA: Hadamard Linear Attention}},
  year = {2026},
  eprint = {2602.12128},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.12128},
}
Figure