TL;DR
KVCompose is a novel structured key-value (KV) cache compression framework that significantly reduces the memory footprint of Large Language Models (LLMs) during long-context inference. By independently selecting important tokens per attention head and packing them into "composite tokens," it dynamically allocates memory budgets across layers while remaining fully compatible with standard inference engines like vLLM without requiring custom compute kernels.
What Problem Does This Paper Address?
As LLMs are deployed for tasks involving massive contexts—such as long-document analysis or extended multi-turn conversations—the KV cache grows linearly with both sequence length and model depth. This scaling behavior creates a severe memory bottleneck, especially in resource-constrained serving environments.
Existing KV cache compression strategies generally fall into two categories, both involving tough trade-offs:
- Structured Eviction: These methods drop entire tokens across all heads and layers to maintain uniform tensor layouts. While highly compatible with standard hardware and inference engines, they rely on rigid heuristics that can discard crucial information.
- Unstructured/Semi-Structured Eviction: These methods allow different attention heads to retain different numbers or sets of tokens. While more accurate, they disrupt uniform tensor layouts, requiring specialized, non-standard CUDA kernels to achieve actual hardware acceleration.
The authors of KVCompose bridge this gap, answering the question: How can we allow flexible, head-specific token eviction while maintaining the strict, uniform tensor structure required by standard inference pipelines?
Methods
KVCompose introduces two primary innovations to achieve efficient, deployable cache compression:
1. Composite Tokens
The core insight of the paper is a mathematical loophole in the self-attention mechanism: while standard inference engines require the sequence length dimension to be uniform across all heads within a layer, there is no rule stating that a specific position index must map to the same original context token across all heads.
KVCompose leverages this by allowing each attention head to independently rank and select its most important tokens based on aggregated attention scores. It then aligns these disparate selections into shared tensor positions to form composite tokens. As illustrated below, position $k$ in the compressed cache might store Token A for Head 1, but Token B for Head 2. This preserves the uniform tensor layout while enabling fine-grained, head-level pruning.
2. Layer-Adaptive Budget Allocation
Instead of using hand-crafted schedules (such as allocating more budget strictly to earlier layers), KVCompose pools the importance scores of these composite tokens globally across all layers. Given a target compression ratio, it dynamically shifts the memory budget toward the specific layers that contain the most informative tokens.
The token importance scores can be gathered in either a task-aware setting (calibrated on specific downstream tasks) or a task-agnostic setting (relying solely on the input context itself).
Datasets
The authors evaluated KVCompose using the Ruler-4096 benchmark from the kvpress framework. This dataset consists of 6,500 context-question pairs with sequence lengths up to 4,096 tokens. It covers 13 distinct task types divided into four core categories:
- Needle in a Haystack (NIAH): Single/multi-key, multi-value, and multi-query retrieval tasks.
- Aggregation: Common and frequent word extraction from noisy token distributions.
- Multi-hop Tracing: Variable tracking across chains of assignments.
- Question Answering (QA): Standard SQuAD-style and distractor-heavy QA.
Experiments were conducted across three prominent open-source LLMs: LLaMA-3.1-8B, Qwen2.5-7B-Instruct, and Qwen3-14B.
Key Insights and Ideas
- The Flexibility of the Sequence Dimension: Pruning algorithms previously assumed that structured eviction meant dropping the same token across all heads. Realizing that heads can hold entirely different tokens at the same index position unlocks unstructured-like accuracy within a structured format.
- Attention Alone is Enough: Prior work suggested that factoring in the mathematical norm of the Value vectors ($V$) is critical to accurately ranking token importance. However, the authors found that weighting attention by value norms is highly model-dependent and actually degraded performance on LLaMA-3.1-8B. An attention-only criterion proved to be the most reliable and simple approach.
- Data-Driven Budgets Beat Heuristics: Dynamically shifting cache capacity across layers based on global token importance consistently outperforms popular static heuristics like "pyramid" schedules.
Key Results
KVCompose consistently outperformed state-of-the-art structured and semi-structured baselines (such as TOVA, SnapKV, and DuoAttention) across all models and evaluation setups:
- High Compression under Loose Tolerance: At a performance degradation tolerance of $\epsilon_0 = 20\%$, KVCompose achieved an average compression ratio of 79.8%, outperforming the best deployable baseline (TOVA at 61.1%) by over 18 percentage points.
- Robustness under Strict Tolerance: When the error tolerance was tightened to $\epsilon_0 = 10\%$, KVCompose still sustained an average compression ratio of 70.1%, far ahead of the next-best deployable method (DuoAttention at 54.0%).
- Graceful Degradation: KVCompose achieved the highest Area Under the Curve (AUC) score in 5 out of 6 evaluation settings, yielding an overall average AUC of 82.3.
Limitations and Future Work
- Context Window Bounds: Due to the constraints of the Ruler-4096 benchmark, the evaluation was limited to context lengths of 4,096 tokens. Testing KVCompose on ultra-long contexts (e.g., 32k to 100k+ tokens) is necessary to fully verify its scalability.
- The Unstructured Gap: While KVCompose bridges much of the performance gap between structured and unstructured methods, pure unstructured eviction (like KVzip) still holds a slight theoretical accuracy advantage because it can vary budgets completely freely across heads. Future work could explore narrowing this remaining gap without sacrificing standard engine compatibility.
Summary updated