| End-to-End TTT | |
|---|---|
| context length in tokens; the paper writes | |
| token of the context, | |
| fast weights, the weights written at test time; the MLPs of the last quarter of blocks | |
| attention window, 8K tokens in the main runs; the paper writes | |
| the model's next-token distribution with fast weights | |
| , the next-token loss at token | |
| mini-batch size of the test-time steps, 1K tokens | |
| the -th mini-batch of consecutive tokens | |
| learning rate of the test-time steps | |
| starting fast weights, learned in training; fast weights after steps | |
| outer loss: each token's loss under the fast weights held when it arrived | |
| Encoding context (Wang et al.) | |
| chunk of the context, at most 1,024 tokens; the paper writes | |
| random identifier of chunk ; the paper writes | |
| sentence from a fixed template naming chunk as conversational context; the paper writes | |
| also the fast weights here, the final MLP layer by default; the paper writes | |
| In-Place TTT (Feng et al.) | |
| output matrix of an MLP after chunks; the paper writes | |
| MLP hidden activations of chunk , one row per token | |
| targets of chunk , a learned convolution and projection of token embeddings | |
Context. A transformer stores every earlier token's key and value so it can attend back to any detail. Memory and step time grow with context length. Linear attentionattention whose exponential score is replaced by a product of feature maps of query and key, so that the past is summed into one matrix of fixed size, updated by one outer product per token (Katharopoulos et al., 2020) and state-space layers hold a fixed-size state instead, at the cost of long-range accuracy. Test-time trainingtraining a model on the input it is currently processing, while it makes its predictions; for a sequence, gradient steps on the tokens already read (Sun et al., 2024) takes a third route. As the model reads the context, it takes gradient steps on those tokens and writes the context into a subset of its weights, called fast weightsthe weights that are changed at test time for the current input and reset before the next one; all other weights stay as training left them. Per-token cost stays constant, as in a recurrent layer, while the state can be as large as the chosen weights.
Storing context in weights compresses it, and compression loses exact recall. End-to-End test-time training (End-to-End TTT; Tandon et al., 2025) adds next-token gradient steps to a transformer with an 8K sliding attention window. Its starting weights are meta-learned for those updates. At 3B parameters, its loss drops from 8K to 128K tokens about as much as full attention's while keeping per-token cost constant. Yet at 128K tokens it retrieves a single hidden string only 6% of the time, against 99% for full attention. That matches the 6.25% chance that an evenly placed string lands inside its 8K window.
Wang et al. (2026) write context into released models with no meta-training. On three Qwen3.5 models, the address under which a chunk is written largely decides whether the model can use it. After a plain next-token write of a short statement, the models answer a direct question about it in at most 6.1% of cases. Writing each chunk after a random identifier and a sentence naming it as context, then listing the identifiers in the prompt, makes the text retrievable. On the same written weights, the correct identifier retrieves a single string hidden in repetitive filler in 84% to 100% of cases, against 1% to 8% for a decoy identifier of the same length. Weights work as gist memory, not as lookup. Unaddressed, a write keeps exact strings only on that easy task, and even addressed writes fall well short of in-prompt context on harder needles and real documents.
Setting: End-to-End TTT. Write for a context of tokens and for the fast weights, here the MLP weights of the transformer's last quarter of blocks. All other weights stay fixed while the model reads the context. The model reads earlier tokens through sliding-window attentioncausal attention restricted to the last tokens, so each head caches at most keys and values (Beltagy et al., 2020) over the last tokens (8K in the main runs) and through . Write for the next-token distribution under fast weights , and for the loss at token . The context splits into mini-batches of consecutive tokens (1K in the main runs). At test time, the inner loop takes one gradient step with learning rate per mini-batch. During training, the outer loss scores each token with the fast weights held when it arrived:
Training minimizes over and the fixed layers by differentiating through the inner updates. That requires gradients of gradients, as in MAMLmodel-agnostic meta-learning: the starting point of a few gradient steps is trained by differentiating the loss after those steps with respect to it (Finn et al., 2017). Every token in mini-batch is scored with , which has seen none of its own mini-batch. The attention window must therefore be at least as long as a mini-batch, why: without it, tokens early in a mini-batch would be invisible to later tokens of the same mini-batch, since the weights update only after it ends.
Meta-learning the starting weights makes the test-time steps useful. Dynamic evaluationcontinuing to train an ordinary pretrained language model on the test text as it is read, with no change to how it was trained (Krause et al., 2018) takes the same kind of test-time steps, but trains as if no update will follow. For , the two training objectives differ only in which weights score token :In a two-block transformer stripped of attention so it sees only the previous token, the naive objective barely improves over no memory. Meta-learning through brings the model close to the same model with full attention.
The written state must be large enough to hold long context. Past the 8K window, tokens reach predictions only through . In a 760M model with 24 blocks, updating the MLPs of only the last 1 or 3 blocks fails to keep pace with full attention as context grows. Updating 6 or 12 blocks does keep pace, and 12 does no better than 6. The paper therefore updates the last quarter of blocks at every scale.
Loss tracks full attention across context lengths. Each 3B model is pretrained on DCLMDataComp for Language Models, a filtered web-text corpus; the runs use its 3.8T-token DCLM-Baseline subset, keeping documents of at least 8K tokens at 8K tokens and fine-tuned separately on Booksa standard academic corpus of long books, used here for long-context fine-tuning and, through a held-out part, for evaluation at each length from 8K to 128K. Evaluation measures mean next-token loss in nats on held-out books. From 8K to 128K, End-to-End TTT's loss falls from 2.314 to 2.249 and stays 0.012 to 0.014 nats below full attention at every length. Every other fixed-cost architecture tested has a higher loss at 128K than at 32K. That includes sliding-window attention alone and hybrids mixing sliding windows with Mamba 2a state-space layer that keeps a fixed-size state with a learned, input-dependent decay (Dao and Gu, 2024), Gated DeltaNeta linear-attention layer whose update reads the value stored under the current key and moves it toward the new value, with a learned decay (Yang et al., 2025), or TTT-KVBtest-time training with key-value binding: each block has its own small network, trained at test time to map each token's key projection to its value projection; with a linear network this is DeltaNet's update (Sun et al., 2024; Zhang et al., 2025). Prefillprocess the given context before the first new token is generated time per token stays flat with length, running 2.7 times faster than full attention at 128K on an H100.
The loss advantage of End-to-End TTT over full attention is largest early in the context and is already there before the first weight update. On the 128K model, End-to-End TTT sits below full attention at every token position, by about 0.05 nats over the first 1,000 tokens and about 0.01 past 32K. No update occurs before token 1,024, so both models attend over the exact same tokens with different trained weights. That early gap comes from the meta-learned weights rather than stored context. Past the 8K window, the writes do carry context. Sliding-window attention nearly flattens past 8K, while End-to-End TTT keeps falling alongside full attention. Its lead over the window-only model widens from about 0.04 nats before 8K to about 0.06 past 32K. Weighted by token count, about half of the 128K model's average lead over full attention still comes from tokens past 32K, by a rough integration of the curves computed here.
| Model | 16K | 32K | 64K | 128K |
|---|---|---|---|---|
| Full attention | 1.00 | 1.00 | 1.00 | 0.99 |
| Sliding window | 0.50 | 0.26 | 0.13 | 0.07 |
| End-to-End TTT | 0.46 | 0.24 | 0.13 | 0.06 |
| 8K ÷ length | 0.50 | 0.25 | 0.125 | 0.0625 |
Plain writes into released models rarely answer direct questions. Wang et al. (2026) instead write context into already-released models with no meta-training. They split a context into chunks of at most 1,024 tokens and update the fast weights, by default the final MLP layer. On each chunk, Adam steps minimize the next-token loss until every token's loss falls below 0.1 or 256 steps finish. The text is then removed from the prompt. Their recall test uses 197 synthetic 11-token statements such as "The registry code of Korvustre Wharf is GC-483". When the statement stays in the prompt, Qwen3.5 models at 4B, 9B, and 27B answer "What is the registry code of Korvustre Wharf?" nearly perfectly. After a plain write, they answer correctly in only 1.5% to 6.1% of cases.
Addressable writes raise recall by pairing an identifier with a context sentence. Addressable context encodingACE, the method of Wang et al. (2026): each chunk is written conditioned on a random identifier and on a sentence that names it as conversational context, and the prompt at question time lists the identifiers (ACE) assigns chunk a random identifier , such as ctx-573277c6, and prepends a framing sentence from a fixed template. The template reads: "The following text is a context chunk from the current conversation at [time], identified by []. It has been encoded into the model and should be treated as conversational context whenever it is invoked:" The write loss sums two terms:The first trains the chunk to follow its identifier, and the second trains it to appear with the framing sentence. Listing the identifiers in the prompt with an instruction to use them lifts recall from at most 6.1% to between 35.5% and 75.6%, depending on the model and wording. Both terms are necessary. Dropping either cuts recall, and an identifier trained with only the first term and named without an instruction leaves recall at 0.5% to 5.6%.
Fixed-weight decoy test: the identifier gates retrieval. Wang et al.'s sharpest control holds the ACE-written weights fixed and swaps only the cue on RULER's simplest needle task, across 100 cases of 1,024 tokens with no instruction prompt. On Qwen3.5-4B, 9B, and 27B, the correct identifier retrieves 84% to 100% of needles, while a decoy identifier of equal length retrieves 1% to 8%. The needle sits in the weights in both runs. Yet the wrong cue scores far below a plain write read with no identifier, which retrieves 85% to 98% of needles on the same models and task.
Harder needles and real documents expose the gap to in-prompt context. RULER's two harder needle tasks use more realistic filler and more complex needles. Plain writes retrieve 7% on the first and at most 1% on the second, while ACE reaches 17% to 40% and 15% to 29%, against 100% with the text in the prompt. On 100 LongBencha benchmark of question answering over long documents; this test uses 100 questions with contexts of 2K to 7K tokens, scored by the word overlap (F1) between answer and reference (Bai et al., 2024) questions, ACE reaches 9.0 to 9.8 F1 on Qwen3.5, barely above plain writes at 7.9 to 8.8 and about half the 18.9 to 20.8 with the document in the prompt. A 30B model from another family, Muse-Glimmer-30B, comes much closer at 19.2 against 21.2. At 64K tokens on RULER's simplest needle, written in roughly 1,024-token chunks, ACE retrieves 30% to 80% across three models against 100% with the full context. Every 64K score is a multiple of 10 points, suggesting roughly ten cases per model.
A contradicting write seems to override a known fact in most cases. In Wang et al.'s counterfactual test, the written statement contradicts world knowledge, such as "The capital of Peru is Arequipa." Asked for the capital according to the context, ACE models answer Arequipa in 86.5% to 96.0% of 200 cases. Asked with the same weights for the generally known capital while setting the context aside, they answer Lima in only 25.5% to 39.0% of cases. On paired control questions about uncontradicted facts, they answer correctly in 76.0% to 82.5% of cases. Dropping the instruction prompt yields Lima in 29.0% to 35.5% of cases, so the prompt does not explain the drop.
In-Place TTT: additive chunk writes without reading the stored weights. Feng et al. (2026) add test-time writes to pretrained transformers that keep full attention. Their update modifies the MLP output matrix in every sixth block. For chunk , write for the MLP hidden activations, with one row per token. A learned convolution and projection map token embeddings to targets that can look ahead to next tokens. After the model processes chunk with the current weights, one gradient step on writesThis step ignores what already holds. After chunks, the matrix equals plus a sum of outer products, matching a chunk-wise linear-attention state (observed here). The delta rule: read the value stored under the key , and move it toward the new value by a fraction (Schlag et al., 2021) instead reads what is stored under each key before replacing it.
When full attention stays in place, recall can rely on attention. Training and running with In-Place TTT still adds a few RULER points: on continually trained Qwen3-4B-Base at 64K, the score rises from 74.3 to 78.7. The writes matter more without full attention. A 4B model pretrained from scratch at 8K with sliding-window attention jumps from 9.91 to 26.80 on RULER at 8K when writes are added. It still trails the 38.09 of full attention without writes.
In practice. End-to-End TTT cannot replace attention when exact distant strings matter. The authors treat the fast weights as long-term memory paired with the sliding window as short-term memory. Meta-training is slow at short contexts because gradients of gradients rule out fused attention kernels. On an H200, it takes 3.4 times as long per token as full attention at 8K and turns 1.2 times faster only at 128K. To write a document into a released model's weights, Wang et al.'s results recommend pairing a random identifier with a framing sentence and naming that identifier at query time. Expect a contradicted world fact to return in only a minority of cases. Writing pays off only when many queries reuse the same context. On one LongBench v2 example, encoding costs 6 to 19 times the FLOPs of answering one question with full context and no cached prefill. Each subsequent query then costs 20 to 24 times fewer FLOPs (computed here from the paper's table).
What is well controlled. Tandon et al. run the recurrent baselines with their authors' code and configurations. They sweep the fine-tuning learning rate only for full attention and reuse it for every method, including End-to-End TTT, which if anything favors full attention. Setting to the 8K pretraining length switches off test-time updates and leaves the modified architecture at 2.825 against 2.827 for full attention. That isolates the gain to the updates and meta-learned weights. Both the needle collapse, which tracks the 8K-window share, and Wang et al.'s fixed-weight decoy swap are direct, large effects.
Where the evidence stops. Tandon et al.'s loss margins are small, with no repeated runs or error bars reported. Their results stop at 3B parameters and omit downstream tasks. Wang et al. test templated synthetic statements on four released models with no repeated runs and compare only against plain writes rather than prompt retrieval. They report the best of three instruction wordings, and the winner varies by model. On Qwen3.5-27B, recall reaches 75.6% with the shortest wording against 39.1% with the default. Their counterfactual test reports no score for unmodified models and does not distinguish erasing an old fact from outweighing it. In-Place TTT reports one training run per model and never separates test-time writes from training with them. None of these papers yet has an independent replication.
Terms
- Test-time training
- gradient steps on the context while reading it, so the context is stored in fast weights
- End-to-End TTT
- next-token loss in the inner loop; starting weights trained through the inner steps (gradients of gradients)
- Outer loss
- ; the naive recipe scores
- Recipe
- 8K sliding window, one step per 1K tokens, MLPs of the last quarter of blocks updated
- Loss scaling
- 3B: 2.314 to 2.249 from 8K to 128K, 0.012 to 0.014 below full attention at every length
- Needle at 128K
- full attention 0.99, End-to-End TTT 0.06, window alone 0.07; 8K/128K is 0.0625
- Early-token gap
- present before the first update at token 1,024, so that part comes from the trained weights
- Plain write
- on each chunk; a direct question about a short statement is answered in 1.5% to 6.1% of cases
- ACE
- , identifiers named in the prompt
- Decoy test
- same weights: correct identifier 84% to 100%, decoy of equal length 1% to 8%; a plain write gets this easy needle 85% to 98%
- Harder tasks
- harder needles: ACE 17% to 40% and 15% to 29%, against 100% in the prompt; LongBench F1 about half the in-prompt score
- Overwrite
- after a counterfactual write, the real fact comes back in 25.5% to 39.0% of cases
- In-Place TTT
- ; additive write, update capped at norm in evaluation
Sources
- 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, and Yu Sun. End-to-End Test-Time Training for Long Context. arXiv preprint, 2025.
- Yue Wang, Qizhou Wang, Feng Liu, Gang Niu, Masashi Sugiyama, and Bo Han. Encoding Context into LLM Weights: What Makes It Context? arXiv preprint, 2026.
- Guhao Feng, Shengjie Luo, Kai Hua, Ge Zhang, Di He, Wenhao Huang, and Tianle Cai. In-Place Test-Time Training. ICLR, 2026.
Connected notes
- Cross-layer connectionsNanoGPT speedrun · Additive paths carry signal through depth and time
The ordinary residual stream already carries early layers forward. In an 8-layer model a value shortcut from layer 2 or later adds little, because is reachable through the stream, and it helps once the residual chain is started at . Deep layers want the first-layer shortcut most, so a direct path helps where the single running sum no longer carries that information cleanly.
- Parametrization across width and depthDeep Learning Alchemy · Additive paths carry signal through depth and time
In five-step stress tests at width 64, the branch outputs of standard P add up to a residual stream with RMS about 33 at depth 1,000 at initialization, while Depth-P's branch multiplier holds it near 1.3 and gives the lowest loss at large depth after five updates. CompleteP's holds it at 1.0 but overcorrects, since independently initialized blocks add like independent terms.
- Matrix scaling and Sinkhorn's theoremMatrix scaling and optimal transport · Additive paths carry signal through depth and time
Sinkhorn-Knopp projects any positive matrix onto a unique doubly stochastic scaling , which mHC runs for 20 iterations on the entrywise exponentials of its learned mixing matrices so multi-stream products stay bounded across depth.
PreNorm's unweighted running sum grows with depth and dilutes every earlier output, so Attention Residuals replace it with softmax-weighted averages over earlier block sums, bounding the mixed input by while keeping direct shortcuts across depth without the matrix-product instability of multi-stream mixing.