1 00:00:01,000 --> 00:00:09,300 [Hal Turing] Alrighty! Thanks for tuning in! Hello AI world! I am your host, Hal Turing, and my co-host is Dr. Ada Shannon. 2 00:00:09,300 --> 00:00:41,200 [Hal Turing] Today we're looking at "Latent Compaction with Test-Time Training," a preprint from October 2026. The first author is Yingfa Chen, from the NLP group at Tsinghua University. The question is this. If you freeze the model and run gradient descent on a small, document-specific KV cache, without knowing what questions will come, can that cache keep the document usable at sixteen to thirty-two times less memory? And can it do better than picking a subset of the original entries, or writing a text summary? 3 00:00:41,200 --> 00:00:57,250 [Dr. Ada Shannon] The stakes are that long-context memory is mostly a storage problem, and the two standard fixes both lose information. Summaries drop details. Selection can only keep what already exists. This paper trains new entries instead. 4 00:00:57,250 --> 00:01:01,475 [Hal Turing] Start with the cache itself, since everything hangs on it. 5 00:01:01,475 --> 00:01:22,625 [Dr. Ada Shannon] For every token the model has read, each layer and each attention head stores a key vector and a value vector. New tokens attend over those instead of rereading the text. So the cache grows linearly with context. That limits how many requests you can batch on one GPU. It also means every decoded token has to stream the whole cache through memory, so bandwidth becomes a cost at each step. 6 00:01:22,625 --> 00:01:26,825 [Hal Turing] And compaction is the general name for shrinking that? 7 00:01:26,825 --> 00:01:49,900 [Dr. Ada Shannon] Shrinking what you carry forward once a session outgrows the window or the budget. The familiar form is the text summary. Anthropic and OpenAI both offer it, and agent harnesses do it when a session gets long. The failure is that the summarizer must guess what matters before it knows. A file path or an ID looks unimportant at summary time, then becomes the one thing you need. This paper compacts in KV space instead, inside the model's own representation. 8 00:01:49,900 --> 00:01:53,125 [Hal Turing] What's the existing option in that space? 9 00:01:53,125 --> 00:02:20,975 [Dr. Ada Shannon] Eviction. Keep a scored subset of the original key-value pairs and discard the rest. H2O keeps heavy-hitter tokens, the ones that accumulate the most attention. SnapKV and PyramidKV score entries using attention from the end of the prompt. KVZip scores each entry by how much attention it gets when the model reconstructs the context from the cache. The paper's strongest baseline, KVZip+, is a variant from the KVzap paper by Jegou and Jeblick, 2026. It rescales attention by value norm over hidden-state norm. 10 00:02:20,975 --> 00:02:26,725 [Hal Turing] So the structural limit is that every kept entry is a real token's pair. 11 00:02:26,725 --> 00:02:36,725 [Dr. Ada Shannon] Right. Eviction can only choose, never create. If one slot would be more useful as a blend of several tokens' information, selection can't build it. 12 00:02:36,725 --> 00:02:41,350 [Hal Turing] And SnapKV leans on the question being known, doesn't it? 13 00:02:41,350 --> 00:03:03,450 [Dr. Ada Shannon] Yes. That's the query-aware versus query-agnostic distinction. Query-aware compression knows what will be asked, so it keeps what that question needs. Query-agnostic compression happens before any question arrives, and the cache must serve many unseen ones. That's harder. SnapKV and PyramidKV are normally query-aware, so the authors adapted them to withhold the question. KVZip is already query-agnostic by design. 14 00:03:03,450 --> 00:03:07,625 [Hal Turing] Now the learned side. Where do trained caches come from? 15 00:03:07,625 --> 00:03:40,651 [Dr. Ada Shannon] Prefix-tuning, by Li and Liang in 2021, learns key and value vectors prepended at each layer for a task. Cartridges, by Eyuboglu and colleagues with Christopher Ré at Stanford in 2025, does it per corpus. The model generates synthetic conversations about the corpus, which they call self-study. Then context distillation trains the cache so the model with the cartridge matches the model with the full text. Training on raw next-token prediction works poorly. The synthetic data plus distillation is what makes it competitive. The paper cites Cartridges as closest prior work but does not compare against it. 16 00:03:40,651 --> 00:03:43,001 [Hal Turing] And Attention Matching? 17 00:03:43,001 --> 00:04:01,901 [Dr. Ada Shannon] Zweiger, Fu, Guo and Kim, 2026. It skips end-to-end training. It fits the compact cache so its attention outputs and its attention mass match the full cache's, with a learned bias per slot. It's faster, and it gives this paper its first stage. I'll define those terms when we get to the method. 18 00:04:01,901 --> 00:04:08,226 [Hal Turing] Then where does test-time training come in? That phrase usually means updating model weights. 19 00:04:08,226 --> 00:04:36,126 [Dr. Ada Shannon] It does. Sun and colleagues in 2020 adapted an image classifier to each test input with a self-supervised loss. Later, Akyürek and colleagues in 2024 fine-tuned LoRA adapters per task on ARC. Sun's TTT layers, and Google's Titans, make the recurrent state itself a small model updated by gradient steps. Here the weights stay frozen. The trained object is a set of KV slots for one document. And "test time" means after the document is known and before the questions arrive. 20 00:04:36,126 --> 00:04:39,876 [Hal Turing] So the cost gets amortized across questions. 21 00:04:39,876 --> 00:04:51,926 [Dr. Ada Shannon] Yes. A fixed-size cache optimized by gradient descent, instead of a cache that grows with the text. That pays off for a document reused many times, and never for a one-shot prompt. 22 00:04:51,926 --> 00:04:58,251 [Hal Turing] One thing before we dig in. What does "thirty-two times" mean here? Memory, or something else? 23 00:04:58,251 --> 00:05:18,077 [Dr. Ada Shannon] Something narrower. For a target length N0 and ratio r, each layer and KV head gets N0 divided by r slots. Every entry type counts against that budget. It counts pairs, not bytes. Per-slot bias metadata, padding and precision aren't counted, and the paper claims no speedup and measures no memory saving. 24 00:05:18,077 --> 00:05:20,477 [Hal Turing] So what are we going to hear? 25 00:05:20,477 --> 00:05:35,027 [Dr. Ada Shannon] A claim that training the cache keeps far more retrievable detail than selection at high ratios, with a thirty-two-times headline on RULER. That number deserves scrutiny, because the abstract leaves out some details we'll need. 26 00:05:35,027 --> 00:05:39,302 [Hal Turing] Let's get into how the cache gets built. What's the first step? 27 00:05:39,302 --> 00:06:00,027 [Dr. Ada Shannon] Set a budget of B slots for every layer and every KV head. Take a 4K document at thirty-two times. That's 128 slots per head. Three quarters of them, 96, are preservers. Those are real KV pairs from the document, chosen by one global KVZip+ ranking across all layers, heads and positions. So a head the ranking likes gets more slots than a head it doesn't. 28 00:06:00,027 --> 00:06:02,477 [Hal Turing] And the other 32? 29 00:06:02,477 --> 00:06:25,402 [Dr. Ada Shannon] Those are anchors and diversifiers. Eight are anchors: the first token, which often acts as an attention sink, plus entries the full-cache model attends to heavily when it's probed. The other 24 are diversifiers. They're picked by farthest-first traversal in key space. Each new key is the one farthest from everything already chosen, so the slots spread out instead of piling up where the preservers already sit. These 32 start as copies of real entries but are free to be trained. 30 00:06:25,402 --> 00:06:27,602 [Hal Turing] What does the training match? 31 00:06:27,602 --> 00:06:48,452 [Dr. Ada Shannon] Three terms first. The attention output is the softmax-weighted sum of value vectors. The log-normalizer is the log of the softmax denominator, which measures how much total attention mass the document draws. Each slot also carries a learned bias that scales its weight. With fewer slots, the mass changes, and the bias lets the cache compensate. 32 00:06:48,452 --> 00:06:52,202 [Hal Turing] Why does the mass matter? Isn't the output enough? 33 00:06:52,202 --> 00:07:13,702 [Dr. Ada Shannon] Because question tokens get appended after the document, and the model runs one softmax over both. If the compressed document claims the wrong share of mass, it either drowns the question or gets ignored. The paper combines the two sides weighted by their normalizers. When they swap that for a plain equal average, Phonebook accuracy falls to a quarter of a percent at most. That ablation says mass is essential. 34 00:07:13,702 --> 00:07:17,302 [Hal Turing] And the training signal? You said no questions. 35 00:07:17,302 --> 00:07:38,452 [Dr. Ada Shannon] Teacher rollouts. The frozen full-cache model answers 480 generic prompts about the document, 24 requests crossed with 20 response instructions, greedy, up to 24 tokens each. Things like summarize the main subject, answer briefly. No benchmark questions or answers. Note that this is 480 probes of one document, not 480 documents. 36 00:07:38,452 --> 00:07:42,702 [Hal Turing] So the queries it produces become the training data. 37 00:07:42,702 --> 00:08:07,652 [Dr. Ada Shannon] Yes. Stage 1 runs layer by layer. It fits the compressed attention output and log-normalizer to the full cache's, with preservers frozen and only anchors and diversifiers trainable. A thousand updates. Stage 2 trains every entry end to end through the model. The loss is KL on the teacher's top 20 tokens plus one lumped tail bucket, plus ordinary language-modeling loss on the teacher's greedy token. Another thousand updates. Full-vocabulary distillation gave no consistent gain. 38 00:08:07,652 --> 00:08:11,177 [Hal Turing] Why freeze the preservers in stage 1? 39 00:08:11,177 --> 00:08:27,327 [Dr. Ada Shannon] The ablation supports it. Let them train and Phonebook accuracy at 16x drops from about 81 out of 100 to about 33. The paper's reading is that the real entries are a good fixed base for the fit, and loosening them loses that. 40 00:08:27,327 --> 00:08:31,277 [Hal Turing] Now the headline. What is RULER, and what's the claim? 41 00:08:31,277 --> 00:08:53,777 [Dr. Ada Shannon] RULER is a synthetic long-context suite of 13 tasks: needle-in-a-haystack variants, variable tracking, common and frequent word extraction, and QA. Accuracy, higher is better. The abstract says that at 32x, Latent Compaction gets 96.7 percent against 40.0 for KVZip+, the best eviction baseline. That's a gap of 56.7 percentage points, on Qwen3-1.7B. 42 00:08:53,777 --> 00:08:56,077 [Hal Turing] Which context length? 43 00:08:56,077 --> 00:09:09,377 [Dr. Ada Shannon] The abstract doesn't say. The number appears to be read off Figure 1, since it isn't in a table or the text. There are 20 documents per task and length, one seed per document, and no confidence intervals. 44 00:09:09,377 --> 00:09:16,952 [Hal Turing] Then I want to know which tasks carry that average. A lookup task and a counting task fail in different ways. 45 00:09:16,952 --> 00:09:33,327 [Dr. Ada Shannon] Per-task curves exist in Appendix E, but only as plots. I can't quote CWE, FWE or QA values, so I won't. Those aggregation and QA tasks would tell us the most, and the paper gives no numbers for them. I'll come back to that. 46 00:09:33,327 --> 00:09:36,527 [Hal Turing] Then the ablations. Which parts matter? 47 00:09:36,527 --> 00:09:57,952 [Dr. Ada Shannon] On Phonebook at 16x, averaged over 4K, 8K and 16K, the full method scores 80.67. Remove stage 1 and it falls to 13.92. Remove just the log-normalizer term and it's 36.50. Stage 2 adds about ten points on top. And the slot mix matters. Replace diversifiers with random vectors and it's about 20. 48 00:09:57,952 --> 00:10:00,127 [Hal Turing] Does more training help? 49 00:10:00,127 --> 00:10:14,102 [Dr. Ada Shannon] Not much. Doubling stage 1 from 1,000 to 2,000 steps moves 61.00 to 61.25. Stage 2 peaks at 1,000 steps and then declines slightly, which looks like overfitting. 50 00:10:14,102 --> 00:10:18,402 [Hal Turing] Wait, 61? Your default was 80.67. 51 00:10:18,402 --> 00:10:38,127 [Dr. Ada Shannon] The paper doesn't explain that. The setup or document set may differ, but that's a guess. There's a second oddity. Table 4's top row, 33.42, is identical to the trainable-preservers row in Table 2, not the 80.67 default. So the reference configuration there is unclear, and I can't resolve it from the text. 52 00:10:38,127 --> 00:10:43,627 [Hal Turing] So the relative effects look informative, but the absolute numbers need care. 53 00:10:43,627 --> 00:11:01,502 [Dr. Ada Shannon] Yes. Everything here is Phonebook on one model, one seed per document, so differences of a fraction of a point shouldn't be read as wins. Stage 1 versus nothing is not a small difference. And it's an ablation against no stage 1, not against a stronger Attention Matching baseline. 54 00:11:01,502 --> 00:11:05,902 [Hal Turing] Back to the headline, then. What would settle which tasks drive it? 55 00:11:05,902 --> 00:11:28,202 [Dr. Ada Shannon] Lookup and copy tasks, meaning single-needle retrieval, variable tracking and multi-value retrieval, reward keeping exact tokens retrievable, which is what this method is built for. Common word extraction, frequent word extraction and the two QA tasks need information spread across the whole document. I won't guess their values. Per-task numbers with intervals for those would settle it, and with twenty documents per task and length, a bare average hides a lot. 56 00:11:28,202 --> 00:11:35,252 [Hal Turing] The paper also concedes something. Text summaries beat it on RULER at the most aggressive ratios. 57 00:11:35,252 --> 00:12:03,577 [Dr. Ada Shannon] Right, and that shapes when you'd use it. On Phonebook, every method, this one included, goes to near zero at 64x and beyond. A 4K document at 32x keeps 128 slots per head. So 32x sits one doubling before that collapse. But the paper shows 16x, 32x and 64x and nothing between, so where the break lies is unknown. I'd guess capacity depends on how many distinct facts the document holds, but that's my inference, not a measurement. 58 00:12:03,577 --> 00:12:14,352 [Hal Turing] Phonebook is a pure exact-copy test, and the training prompts are generic. Things like summarize the main subject. Why would that preserve a ten-digit number? 59 00:12:14,352 --> 00:12:36,752 [Dr. Ada Shannon] The paper doesn't separate it. The ablations say attention fitting is critical, but they don't say whether the 480 prompts happen to touch the relevant keys, or whether the cache learns something general. Nor do they separate learned slots from the three-quarters that are original entries chosen by KVZip+. The paper says the prompts contain no benchmark questions or answers. But I'd want a shifted prompt bank, fewer prompts, and a check on facts that no prompt ever probes. 60 00:12:36,752 --> 00:12:40,202 [Hal Turing] Then the comparisons. Where is Cartridges? 61 00:12:40,202 --> 00:13:02,752 [Dr. Ada Shannon] Cited, not run. It's the closest method, and an equal-compute head-to-head would show whether this recipe beats it, and whether a generic prompt bank substitutes for self-study data. The Attention Matching baseline is also a weakened variant, without the orthogonal matching pursuit step or on-policy queries. Stage 1 is close to that loss trained by gradient descent. So the new part is Stage 2 and the initialization, and the full comparison is missing. 62 00:13:02,752 --> 00:13:05,152 [Hal Turing] What does preparation cost? 63 00:13:05,152 --> 00:13:37,777 [Dr. Ada Shannon] A thousand updates per layer, a thousand end-to-end updates, and 480 rollouts per document. No wall-clock or GPU time is reported, and the authors say per-document fitting remains costly. Compaction ratios are logical counts of KV pairs. Bias metadata, padding and precision aren't counted. No memory or speed is measured, and the explicit attention path doesn't use FlashAttention. Smaller learned compressors, like AutoCompressors from Chevalier and colleagues in 2023, skip per-document training entirely. So where does this fit? 64 00:13:37,777 --> 00:13:40,952 [Hal Turing] Documents reused many times? 65 00:13:40,952 --> 00:14:01,152 [Dr. Ada Shannon] Yes. A long manual or tool corpus queried repeatedly could amortize the cost. A one-off prompt can't. The cache is also fixed after training, so the agent-session case that motivates the paper, where context keeps growing, isn't tested. It's also opaque. A summary you can read; with a learned cache, nothing tells you which facts survived. 66 00:14:01,152 --> 00:14:02,777 [Hal Turing] And scale? 67 00:14:02,777 --> 00:14:26,477 [Dr. Ada Shannon] Main results are on Qwen3-1.7B. Other sizes up to 8B and a second model family were tested on Phonebook only, at 4K to 16K contexts. That suggests the pattern isn't one model's quirk. It says nothing about much longer sessions on large models. On LongBench the gain over KVZip+ is small at 4x and larger at 16x and 32x, with a gap to the uncompressed model throughout. Exact values are only plotted. 68 00:14:26,477 --> 00:14:28,627 [Hal Turing] What would you want next? 69 00:14:28,627 --> 00:14:45,727 [Dr. Ada Shannon] Cheaper preparation, which the authors name as future work. Beyond that, aggregation-heavy tasks, larger models, a fact-count sweep to find the capacity limit, and a byte-level comparison with quantization such as KIVI, since the paper counts pairs rather than bytes. 70 00:14:45,727 --> 00:15:12,077 [Hal Turing] So the takeaways. Training the cache, not just selecting entries, keeps far more retrievable detail at moderate ratios on lookup-style tasks, and the attention-and-mass fitting in stage one is the key ingredient. The boundary is that it isn't shown for aggregation-heavy tasks, extreme ratios, measured memory or speed, or against Cartridges. A promising proof of concept at small scale. Thanks for listening, everyone.