cs.CLOct 14, 2026

Latent Compaction with Test-Time Training

Authors: Yingfa Chen, Xingyu Shen, Chaojun Xiao, Xu Han

Organizations: NLP Group, DCST, IAI, BNRIST, Tsinghua University, Beijing, China

Abstract

Long contexts enlarge key--value (KV) caches, increasing memory use and attention costs during generation. Compressing these caches must preserve information for unseen questions. We introduce Latent Compaction, which learns a compact document-specific cache through test-time training. We initialize cache entries using reconstruction importance, teacher attention, and key-space diversity. Training first fits attention outputs and log-normalizers to those of the full cache, with reconstruction-selected entries held fixed. It then jointly optimizes the entire cache through end-to-end distillation from the full-cache model. Model weights remain frozen throughout, and training uses only generic prompts about the document, without access to downstream questions or answers. Experiments on RULER, LongBench, and Phonebook Lookup demonstrate substantial gains over budget-matched compression baselines. On a RULER, for example, our method achieves 96.7% accuracy at 32×\times compression, compared with 40.0% for KVZip+. The method also transfers across model scales and families, with retrieval gains on both Qwen3 and MiniCPM5. These results show that treating the KV cache as a neural network and optimizing it with test-time training can preserve retrieval accuracy under aggressive compression. The code is released at https://www.github.com/THUNLP/latent-compaction

Figures & tables

Appendix figures & tables14 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Fast KV Compaction via Attention Matching

    Feb 18, 2026Adam Zweiger, Xinghong Fu, Han Guo +1KV-Cache ManagementKV-Cache Compression

  2. Still: Amortized KV Cache Compaction in a Single Forward Pass

    Jun 5, 2026Charles O'Neill, Alex Sandomirsky, Harry Partridge +2KV CachingLong-Context Language Model Inference

  3. NestedKV: Nested Memory Routing for Long-Context KV Cache Compression

    May 26, 2026Hong Chen, Xiang Liu, Yubo Gao +5KV CachingLong-Context Language Modeling