All models

Retentive Network (RetNet)

Retention instead of attention: parallel for training, recurrent for cheap inference, chunkwise for long inputs.

Language · 518 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (26 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
RetNet
Parameters
84.6M
Operations
518
Framework
PyTorch
Recurrent
No
Published
2023
Cited by
1,167 (as of 30 November 2026)
Authors
Yutao Sun, Li Dong, Shaohan Huang and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m19837
Graph hash
07bf62765a53abf37676cd5dae3f9a306fc1504d2320173d89456683cffdc3f0
Skeleton hash
9fb53a307cc1b1922e72383aafd1a94d89fc5d648bb834b31b09222650cb7e31
Architecture hash
055a40e3d8dd726efdd10448395de9dde4d375044154363040f6102d128ad1e7
Diagram SHA-256
ea9570ebd898514db3082bd6a6665ada03775b92b22b1492cc98c3dd2368400d
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

RetNet, the Retentive Network, is proposed as a foundation architecture for large language models that aims to get training parallelism, low-cost inference and good performance at the same time. Its core is the retention mechanism, which the authors derive from a connection between recurrence and attention and which supports three computation paradigms: parallel, recurrent and chunkwise recurrent. The parallel form gives training parallelism, the recurrent form gives O(1) per-token inference, and the chunkwise form encodes each chunk in parallel while recurrently summarising the chunks for linear-complexity long sequences.

A third-party implementation describes the payoff as the 'impossible triangle' of language-model design: accuracy comparable to Transformers, high training throughput from the parallel form and high inference throughput from the recurrent form. The three forms are numerically equivalent, and that repository's tests check the parallel, recurrent and chunkwise outputs against each other, noting only small floating-point drift in the recurrent path. Since October 2023 the official torchscale implementation uses RMSNorm and SwiGLU as RetNet's default modules.

The official implementation lives in Microsoft's torchscale library, where a RetNet model is created from a RetNetConfig in several lines of code. The yet-another-retnet port also ships preconfigured, untrained 1.3B, 2.7B and 6.7B models matching the paper's configurations.

Key idea. RetNet replaces attention with a retention mechanism whose parallel, recurrent and chunkwise forms are equivalent, giving Transformer-level training parallelism together with O(1)-cost recurrent inference.

  • RetNet
  • Retentive Network
  • retention
  • multi-scale retention
  • MultiScaleRetention
  • torchscale
  • RetNetDecoder
  • yet-another-retnet
  • successor to Transformer
  • large language model
  • recurrent inference
  • chunkwise recurrent

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{sun2023retentivenetworksuccessortransformer,
      title={Retentive Network: A Successor to Transformer for Large Language Models}, 
      author={Yutao Sun and Li Dong and Shaohan Huang and Shuming Ma and Yuqing Xia and Jilong Xue and Jianyong Wang and Furu Wei},
      year={2023},
      eprint={2307.08621},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2307.08621}, 
}