Learning to (Learn at Test Time): RNNs with Expressive Hidden States

Yu Sun, Xinhao Li, Karan Dalal, Jiarui Xu, Arjun Vikram +7 more
2/12/2026

No official code found. Best implementation: test-time-training/ttt-lm-pytorch (1,398 stars, MIT, last commit 2024-07-14). 3 more below.

Abstract

Self-attention performs well in long context but has quadratic complexity. Existing RNN layers have linear complexity, but their performance in long context is limited by the expressive power of their hidden states. We present a practical framework for instantiating sequence modeling layers with linear complexity and expressive hidden states. The key idea is to make the hidden state a machine learning model itself, and the update rule a step of self-supervised learning. Since the hidden state is updated by training even on test sequences, our layers are called Test-Time Training (TTT) layers. We consider two instantiations: TTT-Linear and TTT-MLP, whose hidden state is a linear model and a two-layer MLP respectively. We evaluate our instantiations at the scale of 125M to 1.3B parameters, comparing with a strong Transformer and Mamba, a modern RNN. Similar to Transformer, TTT-Linear and TTT-MLP can keep reducing perplexity by conditioning on more tokens, while Mamba cannot after 16k context. TTT-MLP still faces challenges in memory I/O, but shows larger potential in long context, pointing to a promising direction for future research.

View on arXivView PDF

Code Implementations(4)

MIT

Official PyTorch implementation of Learning to (Learn at Test Time): RNNs with Expressive Hidden States

1,39881PythonJun 28, 20242 years agoMIT

Official JAX implementation of Learning to (Learn at Test Time): RNNs with Expressive Hidden States

46337Shell, PythonJul 3, 202411 months ago
kyegomez/TTLCommunity58%
MIT

Pytorch Implementation of the paper: "Learning to (Learn at Test Time): RNNs with Expressive Hidden States"

251Shell, PythonJul 8, 20246 months agoMIT

Inference Speed Benchmark for Learning to (Learn at Test Time): RNNs with Expressive Hidden States

925C++, CudaJul 14, 20242 years ago

Similar Papers

Cite this paper

@article{sun2026learning,
  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 Oluwasanmi Koyejo and Tatsunori Hashimoto and Carlos Guestrin},
  year   = {2026},
  eprint = {2407.04620},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2407.04620},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2407.04620.svg)](https://codeofpaper.com/paper/2407.04620)

Discussion