RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression

Payman Behnam, Yaosheng Fu, Ritchie Zhao, Po-An Tsai, Zhiding Yu, Alexey Tumanov

Introduction

As Large Language Models (LLMs) evolve to handle increasingly vast context windows, the computational and memory overhead associated with the Key-Value (KV) cache has become a critical bottleneck. RocketKV introduces a training-free, two-stage compression strategy designed to mitigate this "memory wall." By combining coarse-grained permanent eviction with fine-grained dynamic token selection, RocketKV achieves up to 400× compression of the KV cache and up to a 3.7× end-to-end inference speedup, all while maintaining near-perfect accuracy on long-context benchmarks.

The KV Cache Bottleneck

To avoid redundant computations during inference, LLMs store the keys and values of past tokens in a KV cache. However, this cache grows linearly with both sequence length and batch size. For instance, a model like Llama 3.1-70B with a 32K context requires approximately 320GB for its KV cache—a footprint that exceeds the memory capacity of flagship GPUs like the NVIDIA H100.

Existing mitigation strategies typically fall into two categories:

  1. Permanent Eviction: Deleting "unimportant" tokens to save physical space, which risks permanent information loss.
  2. Dynamic Selection: Keeping all tokens in memory but only attending to a subset during each step to save bandwidth, which fails to solve the underlying storage capacity problem.

RocketKV bridges this gap by demonstrating that a hybrid approach can achieve significantly higher compression and efficiency than either method in isolation.

Methodology: The Two-Stage Pipeline

RocketKV employs a novel two-stage architecture to optimize the KV cache without requiring additional training.

Stage 1: Coarse-Grain Permanent Eviction (SnapKV)

During the prefill phase, RocketKV utilizes an observation window at the end of the prompt to identify clusters of important tokens. Tokens deemed unimportant are permanently evicted from the GPU memory. This stage drastically reduces the physical storage footprint required for the remainder of the generation process.

Stage 2: Fine-Grain Dynamic Selection (Hybrid Sparse Attention)

For the tokens that survive the first stage, RocketKV applies Hybrid Sparse Attention (HSA). This stage performs a "top-k" selection at every decoding step using a novel two-dimensional reduction across both sequence and head dimensions. This allows the model to quickly estimate token relevance without the need to fetch full high-dimensional vectors from memory, further reducing latency.

Adaptive Decomposition and Multi-Turn Support

To balance these stages, the authors developed a mathematical formula for Adaptive Decomposition, which dynamically adjusts the compression ratio between eviction and selection based on the total target budget.

Additionally, the paper introduces RocketKV-MT, a variant tailored for multi-turn conversations. Instead of permanent eviction, it filters tokens for the current turn to optimize bandwidth while retaining the full history in memory. This prevents the accuracy decay often seen in multi-turn scenarios when using standard pruning techniques.

Experimental Evaluation

The researchers evaluated RocketKV using Llama3.1-8B, Mistral-7B, and LongChat-7B across several rigorous benchmarks:

  • LongBench: Summarization, QA, and few-shot learning.
  • Needle-in-a-Haystack (NIAH): Fact retrieval within contexts up to 128K tokens.
  • RULER: Multi-hop reasoning and retrieval.
  • SCBench: Multi-turn conversation performance.

Key Results

  • Extreme Compression: RocketKV maintained 100% accuracy on the Needle-in-a-Haystack test even at a 400× compression ratio (compressing 109K tokens into a budget of 256). In contrast, competing methods like SnapKV experienced significant performance degradation at similar levels.
  • Inference Speedup: The system delivered up to 3.7× end-to-end speedup on NVIDIA A100 GPUs and 3.3× on H100 GPUs compared to full KV cache baselines.
  • Memory Efficiency: Peak memory usage during the decoding phase was reduced by up to 32.6%.

Insights and Future Work

A primary insight of the study is the "Oracle Gap." While existing methods often fail when the token budget drops below 1024, an "Oracle" (perfect) selection can maintain accuracy with as few as 256 tokens. RocketKV’s 2D reduction strategy effectively narrows this gap by leveraging both sequence and head sparsity.

Despite its success, RocketKV has limitations. The multi-turn variant (RocketKV-MT) prioritizes accuracy over capacity, meaning it does not offer the same storage savings as the single-turn version. Furthermore, while the current Python-based implementation is highly performant, the authors suggest that custom CUDA kernels could provide even greater speed gains. Finally, the study noted that more robustly trained models, such as Llama 3.1, are generally more resilient to KV cache compression, suggesting that a model's inherent quality influences its compressibility.

Summary updated

BibTeX
@inproceedings{behnam2025rocketkv,
  author = {Payman Behnam and Yaosheng Fu and Ritchie Zhao and Po-An Tsai and Zhiding Yu and Alexey Tumanov},
  title = {{RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=RyOpooIxDF},
}
Figure