Abstract
KV cache eviction has emerged as an effective solution to alleviate resource constraints faced by LLMs in long-context scenarios. However, existing token-level eviction methods often overlook two critical aspects: (1) their irreversible eviction strategy fails to adapt to dynamic attention patterns during decoding (the saliency shift problem), and (2) they treat both marginally important tokens and truly unimportant tokens equally, despite the collective significance of marginal tokens to model performance (the marginal information over-compression problem). To address these issues, we design two compensation mechanisms based on the high similarity of attention matrices between LLMs of different scales. We propose SmallKV, a small model assisted compensation method for KV cache compression. SmallKV can maintain attention matching between different-scale LLMs to: 1) assist the larger model in perceiving globally important information of attention; and 2) use the smaller model's attention scores to approximate those of marginal tokens in the larger model. Extensive experiments on benchmarks including GSM8K, BBH, MT-Bench, and LongBench demonstrate the effectiveness of SmallKV. Moreover, efficiency evaluations show that SmallKV achieves 1.75 - 2.56 times higher throughput than baseline methods, highlighting its potential for efficient and performant LLM inference in resource constrained environments.
Introduction: The KV Cache Bottleneck
As Large Language Models (LLMs) tackle increasingly long sequences—driven by complex reasoning tasks—the Key-Value (KV) cache becomes a massive bottleneck. The KV cache stores previous token representations to avoid redundant computation, but it grows linearly with sequence length, quickly exhausting GPU memory.
Existing "eviction" strategies (like H2O) try to solve this by dropping unimportant tokens. However, they suffer from two major flaws. First is Saliency Shift: a token that seems unimportant now might become critical later in the generation. Once a token is evicted, it is gone forever, leading to a "local" view that misses global context. Second is Marginal Information Over-compression: current methods categorize tokens as either "critical" or "unimportant," ignoring "marginal" tokens—those that aren't "heavy hitters" individually but collectively contribute significantly to the model's performance.
Methodology: Small Model Assisted Compensation
The core innovation of SmallKV is using an Assisted Small Language Model (SLM) from the same model family to "anchor" the attention mechanism of the larger model. This is based on the insight that models in the same series (e.g., Qwen2-0.5B and Qwen2-7B) exhibit highly consistent attention patterns, with an average cosine similarity of 0.947.
Compensation Mechanisms
SmallKV implements two primary strategies to maintain performance under high compression:
- Saliency Shift Compensation: Because the SLM is tiny, it can afford to keep a full KV cache. The LLM uses the SLM’s global attention patterns to decide which tokens to keep in its own high-fidelity cache, preventing the permanent loss of tokens that might regain importance.
- Marginal Information Compensation: SmallKV introduces a hierarchical compression strategy. While "Critical" tokens keep full K and V caches in the LLM, "Marginal" tokens evict the K-cache to save space but retain the V-cache. The LLM then approximates the attention scores for these tokens using the scores generated by the SLM.
During the "prefill" stage, SmallKV calculates the Jaccard similarity between the attention heads of the SLM and the LLM to create a mapping function, ensuring the SLM heads correctly "mimic" the LLM heads during decoding.
Experimental Results
The authors evaluated SmallKV across a diverse set of benchmarks, including GSM8K (math), BBH (reasoning), MT-Bench (conversation), and LongBench (long-context tasks).
Key Findings
- Accuracy at Low Budgets: On the GSM8K benchmark with only a 5% KV cache budget, standard eviction methods like H2O saw accuracy plummet to ~36%. In contrast, SmallKV maintained a robust 73%, nearing the full-cache baseline of 79.4%.
- Throughput Gains: SmallKV achieves 1.75x to 2.56x higher throughput than baseline eviction methods like H2O and PyramidInfer. This is achieved by migrating evicted tokens between GPU HBM and CPU memory in parallel with the LLM's forward pass.
- Long-Context Stability: In LongBench tests, SmallKV consistently outperformed baselines across all subtasks (QA, Summarization, Code) at 5% and 10% budgets, demonstrating its ability to handle massive contexts without losing coherence.
Discussion and Limitations
While SmallKV offers a significant leap in efficiency, it relies on the availability of an SLM from the same model family. While cross-family similarity exists, it is lower, potentially limiting the "plug-and-play" nature for bespoke models. Additionally, while the SLM is small, it does introduce a compute overhead. The authors suggest mitigating this by sharing the SLM with a speculative decoding setup. Future work remains to provide a formal theoretical proof explaining why these attention patterns persist so consistently across model scales.
Summary updated