Cache What Lasts: Token Retention for Memory-Bounded KV Cache in LLMs

Ngoc Bui, Shubham Sharma, Simran Lamba, Saumitra Mishra, Rex Ying

TL;DR

TRIM-KV introduces a learnable "retention gate" that decides which tokens are worth keeping in a Large Language Model's (LLM) memory (KV cache) and which can be safely evicted. By learning to predict a token's long-term utility at the moment it is created, this method significantly outperforms traditional heuristic-based memory management. In some cases, it even beats models with unlimited memory by filtering out noisy, uninformative tokens.

The Bottleneck: Managing LLM Memory

As LLMs tackle increasingly long documents and complex reasoning tasks, they hit a massive computational wall: the Key-Value (KV) cache. To avoid recalculating everything at every step, LLMs store past token data in GPU memory. However, this cache grows linearly with sequence length, quickly exhausting expensive VRAM.

Existing solutions usually fall into two camps:

  1. Heuristics: Simple rules like "keep the most recent tokens" (sliding window) or "keep tokens that were recently attended to." These often fail in complex reasoning where a fact from thousands of tokens ago suddenly becomes relevant again.
  2. Heavy Orchestration: Moving cache data between GPU and CPU (offloading), which creates massive latency bottlenecks.

The core gap is that current eviction strategies are "myopic"—they look at what is important now rather than what will be important for the entire duration of the generation.

Methods: Introducing TRIM-KV

The authors propose TRIM-KV (Token RetentIon for Memory-bounded KV Cache). Instead of using fixed rules, they teach the model to evaluate a token's "intrinsic importance" the moment it is generated.

TRIM-KV Architecture
  • The Retention Gate: A lightweight neural network (MLP) is added to every attention head. It takes a token's embedding and outputs a scalar retention score ($\beta$) between 0 and 1.
  • Exponential Decay: Importance isn't static. TRIM-KV models memory decay similarly to the human brain's forgetting curve. A token’s influence decays over time as $\beta^{t-i}$. A "critical" token will have a $\beta$ near 1 (decaying very slowly), while a "filler" token will have a $\beta$ near 0 (vanishing almost immediately).
  • The Eviction Policy: When the GPU memory budget is full, the model simply drops the token with the lowest current retention score.
  • Efficient Training: The authors freeze the base LLM and only train the tiny retention gates using two losses: a Distillation Loss (forcing the memory-constrained model to mimic the full-memory model) and a Capacity Loss (penalizing the model for exceeding the target memory budget).

Key Insights and Ideas

  • Selective Forgetting as Regularization: Surprisingly, TRIM-KV sometimes outperformed models with a full, unlimited cache. This suggests that the model learns to prune "noise"—uninformative tokens that might otherwise distract the attention mechanism.
  • Emergent Heuristics: Without explicit programming, the learned gates naturally "rediscovered" common manual heuristics. They learned to keep "sink tokens" (the very first tokens in a prompt) and "gist tokens" (like periods at the end of sentences) that summarize previous context.
  • Head-Specific Specialization: Qualitative analysis showed that different attention heads learn different roles. Some heads specialize in keeping numbers and operators for math, while others focus on pronouns or structural punctuation.

Key Results

TRIM-KV was evaluated across a diverse battery of benchmarks, including mathematical reasoning (GSM8K, MATH-500, AIME24), procedural generation (LongProc), and long-context memory (LongMemEval, LongBenchV2, SCBench).

Performance on Math Benchmarks
  • Massive Gains in Low-Memory Regimes: On difficult math tasks like AIME24, TRIM-KV achieved a 198.4% relative improvement over strong heuristic baselines (like SnapKV) when given the same small memory budget.
  • Beating Retrieval Baselines: It delivered a 58.9% gain in pass@1 compared to SeerAttn-R, a state-of-the-art learnable retrieval method, despite TRIM-KV being much simpler to implement.
  • Efficiency: Because the eviction logic is a simple score comparison, it adds negligible overhead. At a 32K context window, TRIM-KV achieved ~2x higher decoding throughput than full-cache decoding.

Limitations and Future Work

Currently, the LLM weights are frozen during training. The authors suggest that training the attention layers and retention gates together from scratch could lead to even more efficient "memory-native" models. Additionally, while the cache is smaller, the model still uses standard softmax attention. Future work could explore replacing standard attention with these retention-gated mechanisms entirely to further reduce computational complexity, or extending this importance-based memory to multimodal inputs.

Summary updated

BibTeX
@inproceedings{bui2026cache,
  author = {Ngoc Bui and Shubham Sharma and Simran Lamba and Saumitra Mishra and Rex Ying},
  title = {{Cache What Lasts: Token Retention for Memory-Bounded KV Cache in LLMs}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=qCaq3jGb0S},
}
Figure