End-to-End Test-Time Training for Long Context
Arnuv Tandon, Karan Dalal, Xinhao Li, Daniel Koceja, Marcel Rød, Sam Buchanan, Xiaolong Wang, Jure Leskovec, Sanmi Koyejo, Tatsunori Hashimoto, Carlos Guestrin, Jed McCaleb, Yejin Choi, Yu Sun
TL;DR
The paper reframes long-context language modeling as a continual-learning problem and introduces End-to-End Test-Time Training (TTT-E2E) using a sliding-window Transformer. It trains a meta-learned initialization so that test-time gradient updates compress the given context into model weights, with inner loops targeting next-token prediction and outer loops optimizing the initialization. Empirical results on 3B models trained with 164B tokens show that TTT-E2E scales with context length comparably to full attention while delivering constant inference latency and substantial speedups for very long contexts; ablations reveal crucial design choices in which layers to update and how to structure mini-batches. Needle-in-a-Haystack evaluations reveal limits on recall tasks, while decoding long sequences demonstrates practical gains in efficiency and maintaining reasonable text quality. The work provides a scalable, end-to-end framework for long-context modeling with open-source code, and situates this approach within a broader landscape of continual learning and fast-weight meta-learning literature.
Abstract
We formulate long-context language modeling as a problem in continual learning rather than architecture design. Under this formulation, we only use a standard architecture -- a Transformer with sliding-window attention. However, our model continues learning at test time via next-token prediction on the given context, compressing the context it reads into its weights. In addition, we improve the model's initialization for learning at test time via meta-learning at training time. Overall, our method, a form of Test-Time Training (TTT), is End-to-End (E2E) both at test time (via next-token prediction) and training time (via meta-learning), in contrast to previous forms. We conduct extensive experiments with a focus on scaling properties. In particular, for 3B models trained with 164B tokens, our method (TTT-E2E) scales with context length in the same way as Transformer with full attention, while others, such as Mamba 2 and Gated DeltaNet, do not. However, similar to RNNs, TTT-E2E has constant inference latency regardless of context length, making it 2.7 times faster than full attention for 128K context. Our code is publicly available.
