All models

ttt_linear

A language model built from test-time training layers whose hidden state is a linear model.

Language · 175 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 (170 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

Parameters
8.6K
Operations
175
Framework
PyTorch
Recurrent
Yes
Published
2024
Cited by
390 (as of 22 November 2026)
Authors
Yu Sun, Xinhao Li, Karan Dalal 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
m12201
Graph hash
c27517b7476daabbd387471f564b36d6bd5463ad02710d444220c6c930573627
Skeleton hash
233d8200cfc6e1f78e536d5ccb59b35fecdd1714f8f0abd5a48bde8a3a09b58c
Architecture hash
1eee6f47d9d6c9c5fe335dcbd4a98e96f2ec187084c3a2a92399ba8c1d391369
Diagram SHA-256
e9ad46d5ccd5847e8831d7f80e4cbd5e599425706e6bd0ffe5a2d1bded029202
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

menagerie.classics.reimpl3_11_compact:build_ttt_linear: build({})

What it is

About this model's family

TTT-Linear is a language model built from Test-Time Training (TTT) layers, sequence modeling layers whose hidden state is itself a machine learning model. Its paper starts from a trade-off: self-attention performs well in long context but has quadratic complexity, while existing RNN layers have linear complexity but are limited in long context by the expressive power of their hidden states.

In a TTT layer the hidden state is the weights of a model f, and the update rule is a step of gradient descent on a self-supervised loss. Because the hidden state is updated by training even on test sequences, the authors call these layers Test-Time Training layers. One choice of loss the paper describes is reconstructing the input token from a corrupted version of it. In TTT-Linear the hidden state is a linear model, and in the companion TTT-MLP it is a two-layer MLP. Both use the Mamba backbone, which contains temporal convolutions before the RNN layers, unless the paper notes otherwise.

The paper evaluates both at the scale of 125M to 1.3B parameters against a Transformer and Mamba. It reports that, similar to Transformer, TTT-Linear and TTT-MLP can keep reducing perplexity by conditioning on more tokens, while Mamba cannot after 16k context. The authors do not recommend training with the PyTorch implementation, because it is written in pure PyTorch without any systems optimization.

Key idea. The paper makes the hidden state of a sequence layer a machine learning model and its update rule a step of self-supervised learning, giving linear-complexity layers with expressive hidden states.

  • TTT-Linear
  • Test-Time Training layers
  • TTT layers
  • Learning to (Learn at Test Time)
  • RNNs with Expressive Hidden States
  • test-time training
  • language model
  • long context
  • ttt-lm-pytorch

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

Cite the paper

@misc{sun2025learninglearntesttime,
      title={Learning to (Learn at Test Time): RNNs with Expressive Hidden States}, 
      author={Yu Sun and Xinhao Li and Karan Dalal and Jiarui Xu and Arjun Vikram and Genghan Zhang and Yann Dubois and Xinlei Chen and Xiaolong Wang and Sanmi Koyejo and Tatsunori Hashimoto and Carlos Guestrin},
      year={2025},
      eprint={2407.04620},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2407.04620}, 
}