HomeSIFT AI · Research Breakdown
Research Breakdown

Retentive Network.

A successor to the Transformer that trains in parallel, decodes recurrently at O(1) cost, and keeps the quality — the impossible triangle, made possible.

Sun, Dong, Huang, et al.Microsoft Research · Tsinghua UniversityarXiv:2307.08621
Advanced10 min read
Sₙfixed sizeLargemodelsneedcheaplongcontextnow

Retention — each token folds into one fixed-size state, the past decayed by γ. One O(1) step.

8.4×Faster decoding vs Transformer (7B, 8k)70%GPU memory saved at inference15.6×Lower inference latency (Fig. 1, 8k)O(1)Inference cost per decode step
How to read itDotted passages open the paper to that line.Solid terms explain on hover.
The whole paper in 20 seconds

TL;DR

The idea
A foundation architecture that hits training parallelism, low-cost inference, and good performance simultaneously.
The trick
Retention has a dual form — train it as a parallel matrix op, run it as an O(1) recurrence.
The payoff
A 7B model decodes 8.4× faster and saves 70% of memory versus a Transformer with a KV cache.
The claim
The authors position RetNet as an ideal successor to Transformers for large language models.
Why it exists

The impossible triangle

Training parallelism, cheap inference, strong performance — pick two. Every efficient Transformer alternative gives one up.

A Transformer trains in parallel and performs well, but decoding costs grow with sequence length because of the KV cacheKV cacheThe stored keys and values a Transformer keeps for every past token during decoding; it grows with sequence length. RetNet replaces it with a fixed-size state.Full definition →. Linear attention and recurrent neural network variants make inference cheap, but sacrifice parallel training or quality. None of the previous work can break through the impossible triangle, so none has been a clear winner against Transformers.

RetNet is a foundation architecture simultaneously achieving training parallelism, low-cost inference, and good performance.
Figure 2 · The Impossible Triangle
Penrose-triangle diagram: RetNet at the center sits inside the “impossible triangle” of training parallelism, strong performance, and low-cost inference, with Linear Transformer, Recurrent Network, and Transformer on the three edges.
Figure 2: RetNet makes the “impossible triangle” possible, which achieves training parallelism, good performance, and low inference cost simultaneously.
The mechanism

Retention: attention you can rewind

Replace softmax attention with retention — a decay-weighted mixture that can be written two mathematically equivalent ways.

RetentionretentionRetNet's replacement for attention — a decay-weighted mixture of past tokens that admits both a parallel and an O(1) recurrent form.Full definition → keeps a running, decay-weighted summary of the past. Its key property is a dual form of recurrence and parallelism: train it as one big parallel matrix multiply, then run inference as a cheap recurrence that carries a fixed-size state forward. Same weights, same outputs — two shapes.

Figure 3 · Dual form of RetNet
Two block diagrams: (a) the parallel representation computing (QKᵀ⊙D)V through a GroupNorm to output O, and (b) the recurrent representation updating state Sₙ from Sₙ₋₁ with γ, Vₙ, Kₙ, Qₙ to produce output Oₙ.
Figure 3: Dual form of RetNet. “GN” is short for GroupNorm.
Try it

One mechanism, three shapes

The same retention runs three ways — flip between them and watch the complexity readout change.

The retention mechanism supports three computation paradigms — parallel for fast training, recurrent for O(1) inference, and chunkwise recurrentchunkwise recurrentCompute retention in parallel inside each chunk, then carry a small state across chunks — parallel enough to train fast, cheap enough for long sequences.Full definition → to train efficiently on very long sequences.

ParallelTrainingtrain-parallelizable

Retention(X) = (QKᵀ ⊙ D) V

O(N²) compute · fully parallelizable

Three computation paradigms

The signature

Multi-scale decay: drag a head

Retention's memory is controlled by a per-head decay γ. Different heads remember over different horizons.

Head · γ

0.996094

Half-life

~177tokens

distance 0600 tokens

Each head gets its own decay rate γ = 1 − 2^(−5−h). Low heads forget fast (local detail); high heads remember far back — that spread is multi-scale decaymulti-scale decayEach head uses a different decay rate γ, so some heads remember far back and others focus locally — the ablated ingredient that lifts quality.Full definition →.

§3.6 · Ablation Studies

The scorecard

The only row that wins on every axis

Table 1 lines RetNet up against six alternatives across the four axes that matter.

ModelTrain parallelInferenceLow memoryPerformance
TransformerO(N)strong
Linear TransformerO(1)poor
Recurrent NNO(1)poor
RWKVO(1)ok
H3/S4O(1)ok
HyenaO(N)ok
RetNetO(1)strong

RetNet achieves training parallelization, constant inference cost, and linear long-sequence memory — the only row that wins on every axis.

Table 1 · Architecture comparison

The payoff

Inference stops scaling with length

A Transformer's KV cache grows every step. RetNet's fixed state does not — so cost goes flat.

Cost vs sequence length (7B model)

2k4k6k8k35.6
RetNet Transformer + KV cache(GB)
8.4×faster decode70%less memory15.6×lower latency~3%mem overhead

RetNet’s decoding latency keeps almost the same across different batch sizes and input lengths — flat because there is no growing KV cache. Curves are schematic, anchored to the reported 7B / 8k numbers.

Figure 6 · Inference cost

Because activations don’t grow with context, RetNet’s additional memory is almost negligible (about 3%) while model weights occupy 97%. The gains show up in training too: RetNet achieves 25-50% memory saving and 7× acceleration over the standard Transformer.

Does it hold up

Efficiency without giving up quality

The catch with efficient alternatives is usually accuracy. RetNet keeps it — and pulls ahead at scale.

At scale, it wins

RetNet tends to outperform Transformer when the model size is larger than 2B on validation perplexity.

Downstream tasks match

RetNet achieves comparable performance with Transformer on zero-shot and in-context learning settings.

Against efficient variants like RWKV, H3, and Hyena, RetNet outperforms other architectures on the in-domain set and various out-of-domain corpora. One caveat worth reading: the authors implement RetNet in vanilla PyTorch, leaving kernel fusion for future work — so the reported speedups are pre-optimization.

So what

Five things to remember

1

One architecture, all three corners.

RetNet is the first design to hit training parallelism, O(1) inference, and Transformer-level quality at once — the previously impossible triangle.

Three properties at oncePrior work can't break the triangleImpossible triangle made possible

2

One retention, three computation shapes.

The same math is written three ways: parallel for training, O(1) recurrent for inference, and chunkwise recurrent for long sequences.

Three computation paradigmsDual form of recurrence and parallelismHow training uses both forms

3

Inference cost stops scaling with length.

8.4× faster decoding, 70% less memory, ~3% overhead, and latency invariant to batch size and input length — because there is no growing KV cache.

8.4× faster, 70% less memory~3% memory overheadBatch- and length-invariant latency

4

Efficiency without giving up quality.

RetNet matches Transformer on zero/few-shot tasks, beats efficient variants across domains, and pulls ahead above 2B parameters. Multi-scale decay is load-bearing.

Outperforms above 2B paramsComparable downstream accuracyBeats efficient variantsMulti-scale decay matters

5

Positioned as a Transformer successor.

The authors close by framing RetNet as an ideal successor to Transformers — with kernel-fusion speedups still left on the table as future work.

An ideal successorVanilla PyTorch, kernels left for futureModel comparison table