A Self-Pruning Transformer: Extreme KV-Cache Compression with Universal Attention

Davis Wertheimer, Haochen Shen, Ahan Gupta, Derrick Liu, Yu Chin Fabian Lim, Mudhakar Srivatsa, Raghu K. Ganti, Minjia Zhang, Naigang WangCOLM 2026

TL;DR

Universal Attention (UA) is a new transformer framework that uses a learned, multi-component "forget gate" to dynamically prune the KV-cache during inference. By combining query-aware, key-aware, and similarity-based decay mechanisms, UA achieves up to 25× compression in long-context scenarios while actually improving performance over unpruned Llama3 baselines.

What Problem Does This Paper Address?

As Large Language Models (LLMs) handle increasingly long sequences, the "KV-cache"—the memory used to store keys and values for every token in every layer—becomes a massive bottleneck. For a typical model, this cache can consume gigabytes or even terabytes of memory, often dwarfing the model parameters themselves.

Existing solutions generally fall into two camps:

  1. Sub-quadratic architectures (like Mamba or Linear Attention) which use a fixed-size state but often struggle with complex long-context retrieval.
  2. KV-cache eviction (like H2O or SnapKV) which use simple heuristics to drop tokens but often rely on "sliding window" patterns that lose important distant information.

The authors identify a gap: we need a mechanism that is as expressive as standard Softmax attention but as memory-efficient as linear models, without falling back on rigid, hand-crafted eviction rules.

Methods

The core innovation is Universal Attention (UA). Instead of a fixed causal mask, UA introduces a learned, content-aware decay bias ($\Lambda$) into the attention logits.

Figure 1: Overview of Universal Attention. (Left) Standard softmax attention with a fixed causal mask M. (Middle) UA augments the attention logits QK⊤with a learned, content- aware decay bias Λ, while applying L2-normalization to keys, and a low-rank sigmoid gate to the attention output. (Right) Construction of Λ from three decay mechanisms: similarity- based fsim, query-aware fq, and key-aware fk. These are combined via a geometric mean, transformed to log-space, and accumulated causally to produce the decay matrix.

The decay matrix is constructed from three complementary mechanisms:

  • Query-aware ($f^{(q)}$): Similar to Mamba, this lets the model decide how much of the past to "forget" based on the current query.
  • Key-aware ($f^{(k)}$): A novel gate that allows specific tokens to designate themselves as "important" (persisting longer) or "transient" (pruning quickly).
  • Similarity-based ($f^{(sim)}$): Inspired by DeltaNet, this decays a stored key if a new, highly similar key enters the cache, effectively "updating" the information.

These three gates are combined via a geometric mean. This is a critical design choice: it enforces a "veto" property where if any mechanism suggests a token is unimportant, the combined decay is driven toward zero, allowing for safe eviction. During inference, any KV pair whose cumulative decay falls below a threshold $p$ is permanently deleted from the cache.

Datasets

The authors trained 1B and 3B parameter models from scratch on 50B tokens of Dolma v1.7.

For evaluation, they used:

  • RULER: A benchmark for long-context retrieval, tracking, and aggregation.
  • LongBench-E: A multi-task benchmark for long-context understanding.
  • Common-sense reasoning: A suite of standard zero-shot tasks including LAMBADA, PIQA, HellaSwag, WinoGrande, ARC, SIQA, and BoolQ.
  • WikiText: For measuring language modeling perplexity.

Key Insights and Ideas

  • Pruning as Regularization: Surprisingly, UA models often outperform their unpruned "oracle" counterparts. The authors suggest that the learned pruning acts as an implicit regularizer, forcing the model to focus only on the most salient information.
  • The Power of the Veto: By using a geometric mean for the gates, the model can be "naturally parsimonious." It doesn't just use a sliding window; it learns complex, input-dependent sparsity patterns.
  • Hardware-Awareness is Mandatory: To make this practical, the authors co-designed custom Triton kernels. Standard deep learning frameworks struggle with float-valued biases and Grouped Query Attention (GQA) simultaneously; UA's custom implementation actually boosts training throughput by 1.13× compared to PyTorch 2.0.
  • Adaptive, Not Fixed: Unlike methods that force a 90% eviction rate, UA's pruning is dynamic. It keeps more tokens when the context is dense with information and prunes aggressively when it isn't.

Key Results

UA demonstrates a superior frontier in the memory-performance trade-off.

Table 1: RULER (4k sequence length) and LongBench-E (0-4k sequence length split).
  • Extreme Compression: On RULER (4k), UA achieved a score of 50.3 with a 21.4 MB cache, while the standard Llama3 baseline scored only 40.8 despite using a 143.7 MB cache.
  • Long-Context Scaling: At a 16k sequence length, UA achieved 25× compression compared to Llama3.
  • Reasoning Integrity: In zero-shot reasoning tasks, UA (at $p=0.15$) matched or exceeded Llama3's accuracy while using roughly 40% less cache memory even at short contexts.
Table 2: Language modeling perplexity and zero-shot common-sense reasoning accuracy.

Limitations and Future Work

  • Aggregation Weakness: UA is slightly weaker on "aggregation" tasks that require combining many weak signals from across a long sequence. The authors suggest hybridizing UA with standard attention or Mamba layers to mitigate this.
  • Training Cost: Currently, the best results come from training UA from scratch. While the authors showed that existing models can be "adapted" to UA through continued pretraining, a performance gap remains.
  • Inference Optimization: While the cache is smaller, fully realizing the speed benefits of dynamic sparsity requires specialized sparse matrix-vector kernels that are still an active area of systems research.

Summary updated

BibTeX
@inproceedings{wertheimer2026self,
  author = {Davis Wertheimer and Haochen Shen and Ahan Gupta and Derrick Liu and Yu Chin Fabian Lim and Mudhakar Srivatsa and Raghu K. Ganti and Minjia Zhang and Naigang Wang},
  title = {{A Self-Pruning Transformer: Extreme KV-Cache Compression with Universal Attention}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=7p4duCnIJy},
}
Figure