Standard Transformer architectures rely on softmax self-attention, which exhibits quadratic time and memory complexity with respect to sequence length . While FlashAttention and its successors optimize memory access patterns to execute exact softmax attention efficiently within GPU SRAM, the fundamental quadratic compute barrier remains. Moreover, autoregressive generation requires maintaining a Key-Value (KV) cache that grows linearly with sequence length, creating a memory capacity and memory bandwidth bottleneck during decoding.
Linear attention models replace the exponential softmax kernel with decomposable feature maps, reducing attention complexity to and admitting a recurrent formulation with constant-size hidden states. However, vanilla linear attention suffers from two major limitations: degraded associative recall capacity compared to softmax attention, and poor hardware utilization during training.
Gated Linear Attention (GLA), introduced by Songlin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, and Yoon Kim (ICML 2024), resolves these trade-offs. By introducing data-dependent gating into the recurrent state updates and developing an I/O-aware chunkwise parallel training algorithm, GLA achieves competitive language modeling performance against LLaMA-style Transformers while offering linear-time inference and higher training throughput.

The Quadratic Bottleneck and Linear Attention Foundations
Standard causal self-attention computes an output sequence from queries , keys , and values :
Because the softmax function couples and nonlinearly inside the summation, the attention matrix cannot be factored. In autoregressive decoding, computing token requires computing inner products against all preceding key vectors stored in high-bandwidth memory (HBM).
Linearized Attention as Associative Memory
Linear attention replaces the softmax kernel with a feature map :
Applying the associative property of matrix multiplication allows reordering the summation:
Defining the recurrent state as:
The output at step simplifies to:
During inference, updating and computing requires arithmetic operations per step, independent of sequence length . The inference memory footprint remains fixed at elements per head, eliminating KV cache growth.
The Retention and Recall Degradation Problem
Despite efficiency, unconstrained linear attention struggles on tasks requiring precise key-value retrieval, such as Multi-Query Associative Recall (MQAR). In vanilla linear attention, every historical token contributes additively to without decay. Over long contexts, older key-value pairs accumulate, saturating the bounded state capacity and diluting retrieval signals.
Architectures like RetNet introduced fixed, data-independent exponential decay factors ():
While fixed decay prevents gradient explosion and biases attention toward recency, it cannot dynamically retain critical historical tokens while discarding irrelevant noise.
Mathematical Formulation of Gated Linear Attention
Gated Linear Attention augments the linear recurrence with a data-dependent, fine-grained gating mechanism. Instead of a scalar constant, GLA modulates each hidden feature dimension dynamically based on the input representation.

Data-Dependent Forget Gate Parametrization
Given input projection , GLA computes queries , keys , values , and gate logits :
Here, denotes the sigmoid activation function, , define a low-rank projection bottleneck, and is a learnable or fixed temperature parameter that sharpens gate values.
Because , each key dimension receives an independent decay rate between 0 and 1 at time step .
The Gated Recurrent Update
The hidden state evolves according to:
Expanding this recurrence unrolls the state into a cumulative product of historical decay vectors:
Letting denote the cumulative decay vector from step to step , the output at position is expressed in dual attention form:
This formulation reveals that GLA functions as a relative-position-weighted attention mechanism where the decay rate across token intervals is dynamic, input-conditioned, and channel-specific.
Hardware-Efficient Training: The Chunkwise Parallel Form
Evaluating the sequential recurrence step-by-step during training fails to utilize GPU Tensor Cores, which require dense matrix multiplications (GEMMs). Conversely, naive parallel materialization of the full attention matrix incurs quadratic memory overhead and memory bandwidth saturation.
To achieve maximum compute density and I/O efficiency, GLA employs a hybrid chunkwise parallel formulation implemented in Triton via the FlashLinearAttention library.
Sequence Partitioning and State Factorization
The input sequence of length is divided into non-overlapping chunks of length (typically or ), yielding chunks. For chunk index :
- , where
The chunk-level hidden state entering chunk is .
Within chunk , token representations decompose into two distinct components:
- Intra-chunk local interaction: Interactions between queries and keys located within the same chunk .
- Inter-chunk historical context: Interactions between queries in chunk and the accumulated state from all preceding chunks.
Mathematical Formulation of Chunk Computations
Let index positions within chunk :
Cumulative Decay Representation
The cumulative log-gate prefix sum within chunk is:
The decay from token to token () is:
Intra-Chunk Matrix Multiplications
The intra-chunk output is computed in parallel across the chunk using Tensor Cores:
Where represents the causal masked decay tensor. The local attention contribution is then:
Inter-Chunk Recurrence and Output Projection
The historical hidden state transferred across chunk boundaries updates recursively:
The contribution of historical chunks to the current chunk outputs is:
The complete output for chunk is the sum of both terms:
I/O-Aware Kernel Design in FlashLinearAttention
The FlashLinearAttention Triton kernel exploits GPU memory hierarchies by mapping chunk operations to SRAM:
- SRAM Residency: The chunk hidden state is maintained in on-chip SRAM across the chunk-level sequence iteration, avoiding intermediate writes and reads to global High-Bandwidth Memory (HBM).
- GEMM Acceleration: Intra-chunk operations are structured as standard matrix multiplications ( and ), fully utilizing hardware Tensor Cores.
- Recomputation in Backward Pass: Rather than caching all intermediate states for backpropagation, the backward kernel recomputes states on-the-fly during gradient propagation, reducing peak training memory to .
Structural Comparison Across Sub-Quadratic Architectures
GLA sits within a broader landscape of linear-time sequence models and State Space Models (SSMs). The key distinction lies in the state rank and gating topology.
- Softmax Attention (Transformer / FlashAttention): State size is , compute per token during inference is , training complexity is , associative recall is exact.
- Linear Attention (Katharopoulos et al.): State size is (matrix state), compute per token during inference is , training complexity is , gating is none (additive accumulation), associative recall is weak.
- RetNet (Retention): State size is (matrix state), compute per token during inference is , training complexity is , gating is data-independent scalar decay (), associative recall is moderate.
- Mamba (Selective SSM): State size is (vector state per channel), compute per token during inference is , training complexity is , gating is data-dependent continuous discretization (), associative recall is strong.
- Mamba-2 (State Space Duality / SSD): State size is (1D scalar semi-separable), compute per token during inference is , training complexity is , gating is 1-scalar data-dependent decay per block, associative recall is strong.
- Gated Linear Attention (GLA): State size is (2D full matrix state), compute per token during inference is , training complexity is , gating is data-dependent channel-wise vector gate (), associative recall is high.
Empirical Performance and Benchmarks
Experimental evaluations across language modeling benchmarks demonstrate the empirical impact of data-dependent matrix gating.
Language Modeling Perplexity
On standard pre-training runs evaluated at equal parameter counts and token budgets:
- 340M Parameter Models (15B Tokens Pre-training):
- Transformer++ baseline: 28.39 perplexity, 41.2 zero-shot accuracy
- RetNet: 32.33 perplexity, 41.0 zero-shot accuracy
- Mamba: 28.39 perplexity, 41.8 zero-shot accuracy
- GLA Transformer: 28.65 perplexity, 41.5 zero-shot accuracy
- 1.3B Parameter Models (100B Tokens Pre-training):
- Transformer++ baseline: 16.85 perplexity, 50.9 zero-shot accuracy
- RetNet: 18.64 perplexity, 48.9 zero-shot accuracy
- Mamba: 17.06 perplexity, 50.0 zero-shot accuracy
- GLA Transformer: 17.22 perplexity, 51.0 zero-shot accuracy
Associative Recall and Synthetic Needle Retrieval
On synthetic Multi-Query Associative Recall (MQAR) and selective retrieval tasks, data-independent models (such as RetNet) degrade sharply as sequence length scales due to uniform state decay. GLA maintains high recall accuracy by selectively assigning near-zero decay to key memory slots containing factual associations, matching or exceeding Mamba on synthetic memory benchmarks.
Context Length Extrapolation
Because GLA maintains a 2D matrix recurrent state modulated by normalized bounded gates (), the spectral radius of the state transition operator is strictly bounded by 1. Consequently, models trained on 2K context windows extrapolate to sequences exceeding 20K tokens without experiencing numerical overflow or perplexity explosion.
Training and Inference Throughput
Benchmarked against FlashAttention-2 and Mamba:
- Training Speed: On sequence lengths of 4K to 16K, FlashLinearAttention achieves 1.5x to 2.5x higher training throughput than pure recurrent implementations and matches or exceeds FlashAttention-2 throughput due to chunkwise tiling.
- Inference Decoding Speed: For single-token autoregressive generation, GLA achieves constant latency per step with zero KV cache allocation, delivering up to 3x higher decoding throughput at sequence lengths above 8K compared to standard Transformer baselines.
Architectural Trade-Offs and Limitations
While Gated Linear Attention narrows the expressivity gap between linear-time architectures and softmax attention, several engineering considerations remain:
- State Capacity Limits: A matrix state has a fixed numerical capacity. For complex in-context retrieval tasks requiring simultaneous retrieval of hundreds of arbitrary key-value bindings, softmax attention still maintains an expressivity advantage by storing exact historical states.
- Chunk Size Tuning: Chunkwise training performance depends on selecting optimal chunk dimensions () matched to GPU shared memory limits. Extremely small chunks increase inter-chunk state passing overhead, while oversized chunks increase intra-chunk quadratic compute costs.
- Head Configuration: Similar to Multi-Head Attention, GLA benefits from Multi-Head Gated Linear Attention configurations where independent gate projections govern separate representation subspaces.
Sources
- Gated Linear Attention Transformers with Hardware-Efficient Training (Yang et al., ICML 2024 / arXiv:2312.06635)
- FlashLinearAttention Library GitHub Repository
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention (Katharopoulos et al., ICML 2020)
- Retentive Network: A Successor to Transformer for Large Language Models (Sun et al., 2023 / arXiv:2307.08621)
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces (Gu and Dao, 2023 / arXiv:2312.00752)
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality (Dao and Gu, ICML 2024 / arXiv:2405.21060)
