# 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.

- URL: https://dmxsf.com/en/blog/retentive-network-a-successor-to-transformer-for-large-language-models/
- [DMXSF](https://dmxsf.com/en/about/)
- Published: 2023-07-27
- Updated: 2026-11-13
- Paper notes
- Paper: [Retentive Network: A Successor to Transformer for Large Language Models](https://arxiv.org/abs/2307.08621) (Yutao Sun, Li Dong, Shaohan Huang, et al. · arXiv, 2023)

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.

```python
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")
```

```text
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

- [Retentive Network: A Successor to Transformer for Large Language Models](https://arxiv.org/abs/2307.08621)
- [Mamba](https://arxiv.org/abs/2312.00752)
- [MiniMax-01](https://dmxsf.com/en/blog/minimax-01-scaling-foundation-models-with-lightning-attention/)

## 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.
