Gated Linear Attention

Gated Linear Attention is important because it revisits linear attention after FlashAttention and Mamba: the paper treats the attention formula, recurrent inference form, and GPU memory movement as one architecture problem.

Metadata

FieldValue
PaperGated Linear Attention Transformers with Hardware-Efficient Training
AuthorsSonglin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, Yoon Kim
Year2024
VenueICML 2024
PMLRPMLR 235:56501-56523
arXiv2312.06635
OpenReviewia5XvxFUJT
Statusfull note started

Question

Softmax attention gives strong content-based retrieval:

But it forms a token-token matrix:

which creates quadratic sequence cost. Linear attention tries to avoid this by replacing the softmax kernel with feature maps:

Then the computation can be rearranged:

without materializing the full attention matrix.

The problem is that earlier linear attention often had two practical weaknesses:

ProblemWhy It Matters
quality gapsoftmax attention remained stronger on language modeling
hardware gaplinear asymptotic complexity did not automatically mean faster wall-clock training

GLA asks:

Main Claim

The paper makes two connected architecture claims:

and:

The durable idea is:

For this wiki, GLA belongs between Performer, Mega, RetNet, Mamba, and FlashAttention.

Architecture Contract

ItemContract
Inputcausal token sequence
BaselineTransformer attention layer
Replacementgated linear attention layer
Main statematrix-valued recurrent hidden state
Gatedata-dependent forget gate over recurrent state
Training targetparallel/chunkwise hardware-efficient algorithm
Inference targetlinear-time recurrent decoding
Main comparisonsoftmax attention, RetNet, Mamba, FlashAttention-style kernels

The language-model objective is unchanged:

The architecture change is in the sequence mixer.

Linear Attention Recurrence

Unnormalized linear attention can be written with a recurrent state:

Here is matrix-valued. If:

then:

This recurrence gives linear-time inference because the past is compressed into rather than stored as all previous keys and values.

The tradeoff is compression:

If the compressed state cannot preserve the needed retrieval information, quality can drop relative to softmax attention.

Gating

GLA adds data-dependent forgetting. A simple way to read the update is:

where is an input-dependent gate and is elementwise multiplication or a structured gating operation depending on the exact implementation.

The gate gives the model a learned way to control memory:

Gate BehaviorEffect
keep previous state
forget previous state
feature-dependent forget some dimensions more than others

This is why GLA belongs near Gating and state-space models, not only near classic attention.

Parallel, Recurrent, and Chunkwise Forms

The paper emphasizes that the same layer should be read in several equivalent or related forms.

FormUse
parallel formtraining over many sequence positions
recurrent formautoregressive inference
chunkwise formhardware-aware training and memory movement control

This mirrors a broader pattern in modern sequence architecture:

A layer with arithmetic can still be slow if it moves too much data through high-bandwidth memory or fails to use tensor cores effectively.

Hardware-Aware Lesson

FlashAttention showed that exact softmax attention can become much faster by reducing memory traffic and tiling the computation.

GLA applies a similar lesson to linear attention:

The paper reports FlashLinearAttention as a hardware-efficient linear attention implementation and then generalizes it to the gated case.

For architecture reading, the important distinction is:

Claim TypeEvidence Needed
asymptotic complexityformulas in
kernel efficiencywall-clock throughput under hardware, dtype, batch, and sequence settings
model qualityperplexity, downstream benchmark, and length generalization
inference benefitrecurrent decoding state size and latency

Do not read “linear attention” as automatically faster than FlashAttention. The implementation path matters.

Relation to Softmax Attention

Softmax attention keeps an explicit distribution over previous tokens:

GLA compresses the prefix into recurrent state. This changes the retrieval contract:

FamilyPast RepresentationStrengthRisk
softmax attentionexplicit KV cacheprecise token-token retrievalquadratic training memory; large KV cache
linear attentionrecurrent matrix statelinear recurrent inferencecompressed-state bottleneck
GLAgated recurrent matrix stateadaptive forgetting and better qualitystill may struggle with recall-heavy tasks

This makes GLA a sequence mixer alternative, not a drop-in semantic equivalent to softmax attention.

Relation to RetNet and Mamba

GLA sits in the same design pressure as RetNet and Mamba:

PaperSequence State
RetNetretention state with decay
Mambaselective SSM state
Mamba-2structured state-space dual matrix view
GLAgated linear-attention matrix state
DeltaNetdelta-rule matrix memory update

The useful comparison is not “which one replaces Transformers.” The useful comparison is:

Evidence to Read Carefully

The paper reports competitive moderate-scale language modeling, length generalization, and training throughput relative to efficient sequence baselines.

Read each evidence type separately:

EvidenceSupportsDoes Not Prove Alone
perplexityGLA can be competitive at reported scaleuniversal replacement for softmax attention
length generalizationtrained-short tested-long behavior can be strongrobust retrieval on every long-context task
throughputimplementation is hardware-awarearchitecture-only speed independent of kernels
comparison to Mamba/RetNetGLA is in the same modern sequence familydominance under all parameter/data budgets
standalone layer speedkernel can be efficientfull model serving is automatically faster

The strongest durable lesson is the combination of gating and hardware-aware linear attention.

Practical Checks

  • Identify whether a paper uses softmax attention, kernel linear attention, gated linear attention, retention, or SSM.
  • Track recurrent state size: vector state, matrix state, KV cache, or structured SSM state.
  • Separate training parallelism from inference recurrence.
  • Compare wall-clock speed under the same dtype, hardware, sequence length, batch size, and implementation.
  • Check whether long-context results test recall, summarization, perplexity, or synthetic extrapolation.
  • Verify whether “linear” means arithmetic complexity, memory complexity, or actual measured throughput.

Where It Fits

GLA fills a missing slot in the architecture shelf:

It is especially useful before reading newer linear-attention and Transformer-to-RNN papers such as DeltaNet, gated slot attention, and hybrid SSM/attention models.