RetNet: Parallel training and recurrent inference through retention
RetNet replaces softmax attention with multi-scale retention, supporting parallel training, recurrent decoding and chunkwise processing with fixed-size inference state.
On this page
Microsoft’s RetNet seeks Transformer-style parallel training and RNN-style constant-state inference. Retention with decay replaces all-pairs content matching.
How it works
Heads use different decay rates to cover multiple time scales. The parallel form trains efficiently, the recurrent form updates state token by token, and the chunkwise form combines intra-block parallelism with inter-block recurrence.
What the evidence shows
The paper reports competitive language modeling and downstream results plus decoding throughput and memory advantages. Fixed decay summarizes history efficiently but does not provide softmax’s independent exact addressing of every token.
A reproducible check
This snippet checks a public formula or configuration; it does not reproduce full training.
gamma = 0.5
state = 0.0
for t, x in enumerate([1, 2, 3, 4], 1):
state = gamma * state + x
print(t, state)
print("history state size remains one scalar")
1 1.0
2 2.5
3 4.25
4 6.125
history state size remains one scalar
The arithmetic is reproducible, but model quality still depends on the full experiments in the paper.
Limitations and common misreadings
O(1) refers to state size relative to history, not zero or constant total sequence cost. Actual gains depend on kernels, state dimensions and tasks.
The key takeaway
RetNet’s lasting contribution is one retention mechanism expressed in parallel, recurrent and chunkwise forms.
Further reading
FAQ
- What are RetNet’s three forms?
- Parallel training, recurrent token-by-token inference and chunkwise long-sequence processing.
- What does multi-scale mean?
- Different heads use different decay rates to cover different time ranges.
- Is inference memory really O(1)?
- It is constant with respect to history length, but still grows with layers, heads and state dimensions.