RetNet

RetNet proposes retention as a sequence mixing mechanism with three compatible computation modes: parallel training, recurrent inference, and chunkwise recurrent long-sequence processing.

Metadata

FieldValue
PaperRetentive Network: A Successor to Transformer for Large Language Models
AuthorsYutao Sun, Li Dong, Shaohan Huang, Shuming Ma, Yuqing Xia, Jilong Xue, Jianyong Wang, Furu Wei
Year2023
VenuearXiv preprint
arXiv2307.08621
Microsoft ResearchPublication page
Statusfull note started

Question

The Transformer solved a training problem of earlier recurrent models: it lets all tokens in a sequence be processed in parallel. The cost is that causal decoding stores a growing key-value cache:

Classic RNNs have cheaper streaming inference:

but they historically gave up the training parallelism and scaling behavior that made Transformers dominant.

RetNet asks:

The proposed answer is a retention mechanism with three equivalent or compatible forms:

ModeUse
parallel retentiontrain over tokens in parallel
recurrent retentiondecode with a compact recurrent state
chunkwise recurrent retentionencode local chunks in parallel while passing global state across chunks

Main Claim

The durable architecture claim is:

RetNet does not only propose another sparse attention pattern. It changes the sequence mixer from explicit softmax attention:

to retention, where query-key interactions are modulated by causal decay and can be rewritten as a recurrent update.

In simplified form:

where is a causal decay matrix. The recurrent version keeps a running key-value state:

The important point is not the exact notation. It is the contract:

Architecture Contract

ItemContract
Inputcausal token sequence
Outputcontextual token representations or next-token logits
Target replacementmulti-head self-attention in decoder-style language models
Sequence mixermulti-scale retention
Training formparallel or chunkwise recurrent
Inference formrecurrent retention state
Inference memory targetconstant or nearly constant state rather than growing KV cache
Natural comparisondecoder-only Transformer, efficient attention, RWKV, SSM-style sequence models

The block scaffold remains close to a modern Transformer:

This is why RetNet belongs in the same reading route as Attention Is All You Need, RWKV, S4, Hyena, and Mamba.

Retention Mechanism

Retention can be read as attention without softmax normalization and with a causal decay structure.

For token activations:

project:

Parallel retention has the shape:

The decay matrix enforces two things:

PropertyMeaning
causal maskposition cannot use future positions
exponential decayolder tokens are discounted by distance

A useful simplified decay is:

where controls the retention horizon.

Recurrent Form

The same computation can be written as a recurrent state update:

This makes autoregressive decoding closer to an RNN:

The inference state stores accumulated key-value information instead of all past token keys and values.

FamilyStored During Decoding
Transformerprevious for each layer and token
RetNetrecurrent retention state
RWKVrecurrent weighted key-value state
SSM/Mambascan state or selective state

This is the practical reason RetNet is important for deployment-oriented architecture reading.

Chunkwise Recurrent Form

The chunkwise form is the bridge between fully parallel training and fully recurrent inference.

Split a long sequence into chunks:

Within a chunk, compute retention in parallel:

Across chunks, pass a recurrent state:

This gives a useful long-sequence pattern:

That is a different tradeoff from sparse attention windows, FlashAttention, or standard KV-cache decoding.

Multi-Scale Retention

RetNet uses multiple retention heads with different decay rates. The idea is similar to using several memory horizons:

Head TypeIntuition
fast decaylocal or short-range information
medium decayphrase or segment-level memory
slow decaylonger-range state

With heads :

Then each head computes:

The outputs are normalized and combined. This makes retention less like a single fixed recurrence and more like a bank of decaying memory traces.

Relation to Attention

Self-attention computes:

Retention computes a causal decayed interaction:

The biggest conceptual differences:

AxisTransformer AttentionRetention
interactionpairwise token-token scorespairwise form with decay, plus recurrent rewrite
normalizationsoftmax over accessible tokensretention-specific normalization/stabilization
inference cachegrowing KV cacherecurrent state
long sequence pathsparse/linear attention, FlashAttention, chunking, retrievalchunkwise recurrence
inductive biasdirect content addressingdecayed memory with multiple horizons

RetNet therefore should be read as a sequence architecture, not just an implementation optimization.

Relation to RWKV, S4, Hyena, and Mamba

PaperCore Sequence MixerWhy Compare
RWKVrecurrent weighted key-value updatealso aims for Transformer-like training and RNN-like inference
S4structured state-space sequence layerefficient long-range state dynamics
Hyenagated implicit long convolutiondense-attention-free long-context mixing
Mambaselective state-space scaninput-dependent recurrent sequence state
RetNetmulti-scale retentionparallel, recurrent, and chunkwise recurrent forms

RetNet is closest to the question:

RWKV is closest to:

Mamba is closest to:

These papers should be read together rather than as isolated “Transformer killers”.

Evidence to Read Carefully

The paper reports language modeling, scaling behavior, training memory/speed, and inference efficiency. The evidence should be read through separate questions.

EvidenceWhat It SupportsWhat It Does Not Prove Alone
language-model scaling curvesRetNet can compete with Transformer-style baselines under reported settingsuniversal dominance over attention
recurrent inference measurementslower memory and latency from avoiding growing KV cachebetter reasoning or retrieval at all context lengths
chunkwise training resultslong-sequence training can exploit local parallelism and global recurrencethat chunking policy is optimal for every workload
ablations on decay/gating/multi-scale choicesretention design details matterexact component importance in all model sizes
comparison with FlashAttentionRetNet has a different memory/computation paththat kernel engineering differences are fully isolated

The key audit is:

Practical Interpretation

Use RetNet as a reference when a paper claims:

  • constant-state or low-cost autoregressive decoding;
  • no KV cache or reduced KV-cache pressure;
  • Transformer-comparable language modeling with recurrence;
  • chunkwise sequence modeling;
  • long-context efficiency without dense attention.

Do not use RetNet as a generic proof that attention is obsolete. It is a concrete architecture point in a broader design space:

Implementation Checks

When reading RetNet implementations or follow-up papers, check:

CheckWhy It Matters
recurrent and parallel equivalenceclaimed training/inference forms should compute compatible outputs
decay parameterizationretention horizon depends on choices
normalizationretention scores can need stabilization
chunk policychunk size affects memory, latency, and quality
causal maskingleakage can appear if parallel form is implemented incorrectly
comparison baselineTransformer baseline should match parameter count, data, training tokens, and kernel budget

Why It Belongs in Architecture Papers

RetNet contributes a reusable sequence mixing primitive. It is not mainly a benchmark paper, dataset paper, or application paper.

Its durable architectural idea is:

That makes it a canonical architecture note for the sequence-model shelf.