Abstract
Large Language Models (LLMs) increasingly rely on long "Chain-of-Thought" (CoT) sequences to solve complex reasoning tasks. However, these sequences create a memory bottleneck due to the linear growth of the Key-Value (KV) cache. G-KV is a novel KV cache eviction method that enables LLMs to handle massive reasoning chains with up to 90% less memory. By replacing traditional "local" attention-based eviction with a "global" scoring mechanism that preserves historically important tokens, G-KV achieves state-of-the-art performance on complex math and coding tasks while significantly boosting generation throughput.
Introduction
Modern reasoning models, such as DeepSeek-R1, excel at complex tasks by generating extensive internal reasoning steps. These sequences can reach tens of thousands of tokens, causing the KV cache—the memory used to store previous token states—to expand beyond hardware limits.
Existing solutions typically evict "unimportant" tokens from the cache based on their most recent attention scores. This paper identifies a critical flaw in this approach: token importance is often intermittent. A token might be ignored for several steps but become vital again later in the reasoning process. Local eviction methods "forget" these tokens prematurely, leading to reasoning failures. Furthermore, standard models are not natively trained to handle the "sparse" attention patterns created when tokens are missing from the cache, leading to performance degradation.
Methodology
The authors introduce G-KV, which addresses these challenges through two primary components:
1. Global Scoring Mechanism
Instead of evaluating importance based solely on the current attention window, G-KV maintains a persistent historical score for each token. It utilizes a memory decay rate ($\alpha$) to balance past importance with current relevance. The framework supports multiple aggregation forms (max, average, and summation) to compute the final global score.
2. Sparse Post-Training
To bridge the gap between full-attention training and sparse-attention inference, the authors implemented two strategies:
- RL-Sparse: A reinforcement learning framework (based on GRPO) where the model is trained specifically under KV cache compression constraints.
- Distillation: A method to align the sparse-cache model's output distribution with that of the full-cache teacher model.
Experimental Setup
The researchers evaluated G-KV on challenging reasoning benchmarks, including AMC 2023 and AIME 2024 for mathematics, and LiveCodeBench for coding. Training was conducted using the DeepScaleR-40k dataset, which provides mathematical problems of varying difficulty levels suitable for RL and distillation.
Discussion and Insights
Intermittent Attention and Historical Significance
Empirical evidence suggests that the set of tokens an LLM requires shifts over time. However, tokens needed in the future are highly likely to have been important at some point in the past. Global scoring captures this "historical significance" that local methods miss, preserving a more even distribution of tokens across the entire sequence history.
The "Wait" Token as a Semantic Anchor
Through qualitative word cloud visualization, the authors discovered that specific tokens, such as "wait", are disproportionately important in reasoning models. These tokens act as semantic anchors or triggers for the model to begin reflection. G-KV successfully identifies and protects these critical carriers, whereas local methods might evict them during periods of low immediate attention.
Key Results
- Performance: On the AMC 23 benchmark, G-KV improved performance by 5% to 20% compared to other state-of-the-art eviction methods under a strict 512-token budget.
- Efficiency: G-KV achieved approximately a 90% reduction in KV cache memory usage for 16k context lengths.
- Throughput: For models like DeepSeek-Qwen-7B, G-KV increased throughput by up to 12.18x compared to using a full KV cache.
- SOTA Accuracy: In several test cases, G-KV with a limited budget performed as well as, or even better than, the original model using the full, uncompressed KV cache.
Conclusion and Future Work
G-KV demonstrates that global attention history is a superior metric for KV cache management in reasoning-heavy tasks. While highly effective, future work remains in refining reward functions for non-verifiable tasks and exploring more advanced RL exploration techniques to further optimize the training-inference alignment.
Summary updated