Robots Atlas>ROBOTS ATLAS
Architecture

Linear Attention

2020ActivePublished: 7 June 2026Updated: 7 June 2026Published
Key innovation
Replaces the costly softmax(QKᵀ) operation with a kernel approximation φ(Q)·(φ(K)ᵀV); via matrix-multiplication associativity this reduces complexity from O(n²·d) to O(n·d²) and enables autoregressive inference as a recurrent update with constant memory.
Category
Architecture
Abstraction level
Pattern
Operation level
Architecture blockLayerInference
Use cases
Long-sequence language modelingAutoregressive inference with constant memoryAudio and signal models (audio, time-series)Hybrids with local (sliding-window) attentionBackbones for RNN-Transformer models (RWKV, RetNet, DeltaNet)

How it works

1) Choose a feature map φ(·) (e.g. ELU+1, cosine, FAVOR+ orthogonal random features) — non-negativity is important. 2) Instead of computing A = softmax(QKᵀ) and then A·V, compute φ(K)ᵀV (shape d×d), then φ(Q) · (φ(K)ᵀV). 3) The normaliser is φ(Q)·Σ φ(K). 4) In the autoregressive regime, maintain a cumulative state S_t = S_{t−1} + φ(k_t)v_tᵀ and z_t = z_{t−1} + φ(k_t); output: y_t = (φ(q_t)ᵀ S_t) / (φ(q_t)ᵀ z_t). 5) Training uses a parallel (chunkwise / blockwise) form to exploit GPUs and keep parallelism along the sequence dimension.

Problem solved

Standard scaled dot-product attention has O(n²) time and memory complexity in sequence length, which is impractical for very long contexts and expensive in autoregressive inference. Linear Attention breaks the quadratic barrier, enabling training and inference on long sequences while preserving training parallelism and supporting recurrent inference with constant memory.

Components

Feature map φ(·)Approximates softmax and allows factorising the Q·Kᵀ product into linear operations.

A non-negative map applied independently to queries and keys; its choice governs expressiveness and stability. Common choices: ELU+1, cosine, FAVOR+ (orthogonal random features).

INQuery/key tensor.
OUTTensor after applying φ.
ELU+1Simple non-negative map used in the original Linear Transformer (Katharopoulos et al., 2020).
FAVOR+Softmax approximation via orthogonal random features (Performer, 2020).
Cosine / sin-cosCosine map used e.g. in cosFormer.

Official

Recurrent state S_tReplaces the K/V cache of classical attention with constant memory of size d_φ × d_v.

Matrix accumulating outer products φ(k_t)v_tᵀ; serves as "memory" in the autoregressive regime.

INMatrix accumulated over time steps.
OUTState after update.
Normaliser z_tStabilises the output scale and preserves a probabilistic interpretation.

Vector summing φ(k_t), used to normalise the output similarly to the softmax denominator.

INVector accumulated over time.
OUTCumulative sum of key features up to time t.

Official

Implementation

Implementation pitfalls
Numerical instability of the denominatorHigh

The sum φ(K) can approach zero or very small values early in the sequence, leading to division by near-zero.

Fix:Add an ε to the denominator, use layer normalisation, choose φ carefully.
Weaker performance on retrieval tasksMedium

Pure linear attention struggles with precise long-range recall because its state is a compressed sum.

Fix:Add the delta rule (DeltaNet) or gates (Gated Linear Attention); use hybrids with local attention.
Feature-map selectionMedium

A poor choice of φ degrades expressiveness or training stability.

Fix:Use proven maps (ELU+1, FAVOR+, cosine); calibrate at small scale before a full training run.

Evolution

Original paper · 2020 · ICML 2020 · Angelos Katharopoulos
Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François Fleuret
2020
Linear Transformer (Katharopoulos et al.)
Inflection point

Introduction of the kernel attention form with φ = ELU+1; demonstration of equivalence to an RNN in the autoregressive regime.

2020
Performer / FAVOR+

Softmax approximation via orthogonal random features; theoretical error guarantees.

2023
RetNet

Hybrid of parallel and recurrent forms with exponential decay; demonstrated scalability to large language models.

2024
Mamba2 / SSD — bridge to Linear Attention
Inflection point

"Transformers are SSMs" shows that selective SSMs and linear attention are two sides of the same structured-matrix duality.

2024
DeltaNet & Gated DeltaNet

Linear attention augmented with the delta rule and gating; significant improvements on retrieval and long-context tasks.

Hyperparameters (configurable axes)

Feature map φCritical

Choice of non-negative function approximating softmax.

ELU+1Default in Katharopoulos et al. 2020.
FAVOR+Performer; orthogonal random features.
cosinecosFormer.
Feature dimension d_φHigh

Dimension of the space after mapping with φ; affects state capacity and compute cost.

64Typical per-head value.
128Larger capacity, higher O(d²) cost.
Training chunk sizeMedium

Chunk size in the chunkwise form — a trade-off between parallelism and memory.

64Common in FLA implementations.
256Larger chunks – higher memory requirements.
NormalisationMedium

Whether to divide by Σ φ(K) (softmax-like normalisation) or use an unnormalised variant.

normalisedMore numerically stable.
unnormalisedUsed in some variants (e.g. RetNet).

Computational complexity

Time complexity: O(n · d²). Space complexity: O(d²).

Compute bottleneck

Matrix multiplication of size d × d

The dominant cost is accumulating the state φ(k_t)v_tᵀ and projecting it through φ(q_t). It dominates for small n; the advantage over softmax grows with n.

Depends on
d_φd_v

Execution paradigm

Primary mode
Dense

All tokens participate in the recurrent state update.

Activation pattern
All paths active
Additional modes
Conditional
Routing mechanism

Linear Attention has no routing. Gating/delta mechanisms appear in variants (e.g. Gated Linear Attention, DeltaNet).

Parallelism

Parallelism level
Partially parallel

Training is parallelised across sequence chunks; inference uses the recurrent form.

Scope
TrainingAcross tokensAcross devices
Constraints
!Autoregressive inference is inherently sequential across time steps.
!Training uses a chunkwise form to combine parallelism with linear cost.

Hardware requirements

Primary

The chunkwise form maps to large matmuls that exploit Tensor Cores; no quadratic attention reduces HBM pressure.

Good fit

Linear scaling and regular access patterns suit systolic MAC arrays.

Possible

Autoregressive inference is feasible (constant-size state), but throughput is bounded by φ computations.