<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://ren-xubin.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ren-xubin.github.io/" rel="alternate" type="text/html" /><updated>2026-08-14T01:52:25+09:00</updated><id>https://ren-xubin.github.io/feed.xml</id><title type="html">Xubin Ren</title><subtitle>Personal homepage and research notes by Xubin Ren.</subtitle><author><name>Xubin Ren</name></author><entry xml:lang="en"><title type="html">Test-Time Training: Writing Context into Weights</title><link href="https://ren-xubin.github.io/blog/2026/08/13/ttt-writing-context-into-weights/" rel="alternate" type="text/html" title="Test-Time Training: Writing Context into Weights" /><published>2026-08-13T00:00:00+09:00</published><updated>2026-08-13T00:00:00+09:00</updated><id>https://ren-xubin.github.io/blog/2026/08/13/ttt-writing-context-into-weights</id><content type="html" xml:base="https://ren-xubin.github.io/blog/2026/08/13/ttt-writing-context-into-weights/"><![CDATA[<p>When Test-Time Training (TTT) first came up, the first question was practical: if a model changes its weights while generating tokens, does this actually run? If the update costs more than the problem it is meant to solve, the idea is not very useful.</p>

<p>Most discussions about language models keep a clean line between training and inference. Training changes the parameters; inference uses them. TTT draws a line through that boundary. A sequence can be kept in a growing KV cache, or some of its structure can be written into temporary weights while the model is reading it.</p>

<p>The short version is: if training can compress a dataset into weights, perhaps weights can also absorb the context in front of the model. That sounds simple. The interesting part is working out what “absorb” means, and what gets lost along the way.</p>

<h2 id="a-different-kind-of-memory">A different kind of memory</h2>

<p>One useful way to look at TTT is to stop treating a sequence model as only a predictor. It is also a memory system, and different architectures make different choices about what to keep.</p>

<p>Self-attention leaves the past in an explicit table of keys and values. The current query can go back and retrieve a particular piece, which is why attention is so good at using source material. The table grows with the context, though, and reading from it becomes increasingly expensive.</p>

<p>An RNN or SSM makes the opposite choice. It repeatedly rewrites a fixed-size state. This is cheap and neat, but every new observation has to pass through the same update rule and fit into the capacity of that state.</p>

<p>TTT changes the update rule itself. During pretraining, the outer model learns how a small inner learner should update; at inference time, that learner changes as it reads the current sequence. The first TTT paper describes this as a hidden state with expressive, learnable dynamics <a href="#ref-1">[1]</a>.</p>

<p>So the rough picture is simple: attention keeps the past as a table that can be searched, an RNN keeps it as a fixed state that is repeatedly rewritten, and TTT keeps it in a small model that is trained for a moment.</p>

<p>That last option is the reason the idea stays interesting. Training is no longer only something that happened before deployment. It becomes one possible way of storing the current context.</p>

<h2 id="when-the-state-can-learn">When the state can learn</h2>

<p>The update in the original TTT layer is compact:</p>

\[W_t = W_{t-1} - \eta\nabla_W \ell(W_{t-1}; x_t).\]

<p>Here $W_t$ is not the full parameter set of the language model. It is the state of a small learner inside the TTT layer. After each token representation arrives, the learner takes a self-supervised step and is then queried to produce the layer output. From an RNN point of view, $W_t$ is the hidden state, gradient descent is the state transition, and the current learner is the readout.</p>

<p>This creates two time scales. The slow weights learn the representation, the initialization, and the update rule during ordinary pretraining. The fast weights learn patterns from the sequence currently being processed. In the original setup, those fast weights are normally reset when the sequence is over.</p>

<p>That distinction matters. It is not “retrain the whole 7B or 70B model every time a token arrives.” The online learner is deliberately small <a href="#ref-1">[1]</a>. In-Place TTT takes a different route and reuses a projection matrix inside an existing MLP block as the fast weights <a href="#ref-4">[4]</a>. In both cases, only part of the model is allowed to change online.</p>

<p>The appealing mental model is that the hidden state is no longer just a vector. It is a little model that can learn something, and can immediately be asked about what it learned.</p>

<h2 id="it-looks-like-attention-until-it-does-not">It looks like attention, until it does not</h2>

<p>The original TTT work uses a reconstruction-style inner objective:</p>

\[\ell(W;x_t)=\left\|f(\theta_Kx_t;W)-\theta_Vx_t\right\|^2.\]

<p>The key-like view is the input to the inner learner, the value-like view is the target it is asked to reconstruct, and the query-like view is used to read the updated learner. Attention writes an explicit key–value record and later looks it up. TTT writes by taking an optimization step and later asks the small model to make a prediction.</p>

<p>This is also where the connection to linear attention appears. With a linear inner model, zero initialization, and the update used in the paper, the TTT layer becomes equivalent to linear attention <a href="#ref-1">[1]</a>. A later analysis shows that a broad family of key–value-binding TTT layers can be rewritten in the same language <a href="#ref-3">[3]</a>.</p>

<p>That result makes the proposal less mystical, not less useful. “Writing into weights” is not automatically a new capability. The difference comes from the learner, the objective, the optimizer, and—most importantly—what the outer training process teaches the inner loop to preserve.</p>

<h2 id="the-part-that-gets-messy-in-practice">The part that gets messy in practice</h2>

<p>The token-by-token version is easy to describe and awkward to run. Each token creates a training view, updates the fast weights, and then gets used to predict the next token. The updates depend on one another, so a naive implementation is almost entirely sequential.</p>

<p>Linear FLOPs do not guarantee low latency. Accelerators are happiest with large matrix multiplications; a long chain of small, dependent updates is a different kind of workload. The original TTT implementation groups tokens into mini-batches and uses a dual form. Gradients can be computed in parallel relative to the parameters at the start of a block, while their effects are still accumulated in causal order. The dual form substitutes those accumulated gradients into the output calculation instead of materializing every intermediate $W_t$ <a href="#ref-1">[1]</a>.</p>

<p>Block size is the practical knob. Small blocks stay closer to token-by-token adaptation but expose less parallelism. Large blocks use the hardware better and behave more like a batch update. The dual form rearranges the work; it does not make the learning step disappear.</p>

<p>The original paper used blocks of 16 and reported a wall-clock improvement on its TPU setup <a href="#ref-1">[1]</a>. TTT-E2E reports constant inference latency as context grows and a $2.7\times$ advantage over full attention at 128K in a 3B-model experiment <a href="#ref-2">[2]</a>. Those are useful measurements, but they belong to particular implementations and workloads.</p>

<p>The memory trade-off is just as important. In a pure TTT layer, fixed-size fast weights can replace the context-growing KV cache <a href="#ref-1">[1]</a>. In a hybrid design such as TTT-E2E, sliding-window attention keeps local context while weight updates compress more distant history <a href="#ref-2">[2]</a>. Fast weights, gradients, optimizer state, and temporary activations still take space; memory has not vanished, it has changed shape.</p>

<p>And fixed state has a limit. A model can keep reading without keeping everything it has read. New information can overwrite old information, unrelated facts can interfere in parameter space, and a bad update can stay around long enough to affect later predictions. The KV cache is closer to an archive. Fast weights are closer to a notebook with a fixed number of pages.</p>

<p>That leaves the most interesting question: what should be kept? Test-Time Context Distillation (TTCD) uses a long-window teacher to train short-window fast weights to retain information that will be useful for future prediction <a href="#ref-5">[5]</a>. The problem is no longer just how to store more context, but how to decide what deserves to survive compression.</p>

<h2 id="is-this-continual-learning-yet">Is this continual learning yet?</h2>

<p>The word “continual” can cover several rather different things here.</p>

<p>At the smallest scale, there is adaptation within one sequence. This is the clearest result of the original TTT layers: fast weights change while a context is being processed and are usually reset afterward <a href="#ref-1">[1]</a>. It looks more like working memory than lifelong learning.</p>

<p>The next scale is learning within a task. TTT-E2E uses next-token prediction on the current context as its inner objective and meta-learns an initialization that works well after those updates <a href="#ref-2">[2]</a>. TTT-Discover takes another route, using verifiable rewards and test-time reinforcement learning to improve a policy for one scientific or engineering problem <a href="#ref-6">[6]</a>. Both involve real weight updates, but neither is yet a general mechanism for learning across an open-ended stream of tasks.</p>

<p>The largest scale would be population-level continual learning: using experience from many deployed users and agents to improve shared capabilities without spreading noise, private preferences, or attacks to everyone else. Leaving an optimizer on is not enough. Experience has to be checked, consolidated, evaluated, versioned, and sometimes rolled back. Privacy, ownership, poisoning, and incentives are part of the learning system too.</p>

<p>TTT supplies runtime plasticity. Continual learning still has to decide which changes are worth keeping, which should stay local, and how a validated change can be shared without destabilizing the model.</p>

<h2 id="a-few-half-formed-thoughts">A few half-formed thoughts</h2>

<p>TTT has not shown that it will replace the Transformer, but “replace” may be the wrong question. The more important shift is that it loosens a long-standing assumption: after training, the model’s parameters are fixed and inference merely runs the function they define. TTT gives the running model another possibility—a state that can learn, change, and carry something forward.</p>

<p>The existing results, from 1.3B to 4B parameters and up to 128K context <a href="#ref-1">[1]</a>, <a href="#ref-2">[2]</a>, <a href="#ref-4">[4]</a>, are better read as the first coordinates on this map than as a verdict. The larger question is whether an online state can grow from short-term context into task experience, and from task experience into capabilities that transfer across tasks and instances—while remaining verifiable, controllable, and reversible.</p>

<p>That is close to the part of the AGI problem that matters here. A useful system should not only predict the next token; it should acquire knowledge while interacting with the world, form skills, adjust its internal machinery, and bring the useful parts of experience into the next task. TTT is one possible way to update memory. Retrieval, recurrent state, and parameter updates may eventually work together as a larger learning system.</p>

<p>Whether the final mechanism is still called TTT is secondary. The harder and more consequential question is whether a model can keep forming online state without becoming unstable, and turn enough of that state into reusable ability. There is no settled answer yet, but this is a direction worth making much larger.</p>

<h2 id="references">References</h2>

<ol>
  <li><span id="ref-1"></span>Y. Sun et al., “<a href="https://proceedings.mlr.press/v267/sun25h.html">Learning to (Learn at Test Time): RNNs with Expressive Hidden States</a>,” in Proceedings of the 42nd International Conference on Machine Learning (ICML), PMLR 267, pp. 57503–57522, 2025. <a href="https://github.com/test-time-training/ttt-lm-pytorch">Code</a>.</li>
  <li><span id="ref-2"></span>S. Tandon et al., “<a href="https://arxiv.org/abs/2512.23675">End-to-End Test-Time Training for Long Context</a>,” arXiv preprint arXiv:2512.23675, 2025. <a href="https://github.com/test-time-training/e2e">Code</a>.</li>
  <li><span id="ref-3"></span>J. Liu et al., “<a href="https://arxiv.org/abs/2602.21204">Test-Time Training with KV Binding Is Secretly Linear Attention</a>,” in Proceedings of the 43rd International Conference on Machine Learning (ICML), 2026.</li>
  <li><span id="ref-4"></span>Y. Feng et al., “<a href="https://openreview.net/forum?id=dTWfCLSoyl">In-Place Test-Time Training</a>,” in International Conference on Learning Representations (ICLR), 2026, oral presentation. <a href="https://github.com/ByteDance-Seed/In-Place-TTT">Code</a>.</li>
  <li><span id="ref-5"></span>Y. Wang et al., “<a href="https://arxiv.org/abs/2608.01672">Learning What to Remember: Test-Time Training via Context Distillation</a>,” arXiv preprint arXiv:2608.01672, 2026.</li>
  <li><span id="ref-6"></span>B. Yuksekgonul et al., “<a href="https://arxiv.org/abs/2601.16175">Learning to Discover at Test Time</a>,” in Proceedings of the 43rd International Conference on Machine Learning (ICML), 2026. <a href="https://github.com/test-time-training/discover">Code</a>.</li>
</ol>]]></content><author><name>Xubin Ren</name></author><category term="Test-Time Training" /><category term="Continual Learning" /><category term="Long Context" /><summary type="html"><![CDATA[A first-principles note on test-time training, long context, and the uneasy boundary between runtime adaptation and learning.]]></summary></entry></feed>