LAVa: Layer-wise KV Cache Eviction with Dynamic Budget Allocation

Yuhui Shen, Song Yuan, Zhi Zhang, Fangxing Li, Daxin Jiang, Cam-Tu Nguyen2025

Abstract

KV Cache is essential for accelerating LLM inference in long-context scenarios, but its substantial memory footprint necessitates effective compression. Traditional heuristic-based eviction methods often lack a principled foundation and fail to adaptively allocate memory budgets. We present LAVa, a unified framework for KV cache compression that minimizes information loss within Transformer residual streams. By analyzing layer attention output loss, we derive a novel metric to compare cache entries across heads, enabling dynamic head budgets. Furthermore, by evaluating cross-layer information flow via normalized entropy, we achieve dynamic layer budgets. LAVa is a training-free, fully dynamic strategy that consistently outperforms existing methods across benchmarks like LongBench and InfiniteBench. Our findings reveal that dynamic layer budgets are vital for generation tasks, while dynamic head budgets are critical for extraction tasks.

What Problem Does This Paper Address?

As Large Language Models (LLMs) push toward context windows of 128K tokens and beyond, the memory required to store Key-Value (KV) caches—the "memory" of previous tokens used to speed up inference—explodes. This memory bottleneck often forces a trade-off between context length and hardware costs.

Existing solutions like SnapKV or H2O use "eviction" strategies to prune less important tokens from the cache. However, these methods are largely heuristic, relying on simple statistics like accumulated attention scores. Furthermore, most existing methods use a "fixed budget" approach, assigning the same amount of memory to every attention head or every layer, regardless of the actual information flow. This rigidity leads to performance degradation in complex tasks where some layers or heads are significantly more important than others.

Methods

The authors introduce a principled framework that treats KV cache compression as an optimization problem: minimizing information loss in the Transformer's residual streams.

The LAVa framework treats the Transformer as a communication channel, minimizing information loss across residual streams to guide cache eviction.

Key components of the LAVa approach include:

  1. The LAVa Scoring Function: Unlike previous methods that only look at attention weights, LAVa incorporates the norm of the Value vectors. The score for a token is the product of its recent attention weights and the maximum norm of the value vectors in that head. This provides a more theoretically grounded measure of how much a token actually contributes to the layer's output.
  2. Dynamic Head Budgeting: Instead of giving every head in a layer the same number of cache slots, LAVa flattens the scores across all heads in a layer and keeps the top-N tokens globally for that layer. This allows "important" heads to claim more memory.
  3. Dynamic Layer Budgeting: LAVa uses normalized entropy to measure the "uncertainty" of a layer. If a layer’s attention is spread thin (high entropy), it is assigned a larger memory budget to preserve more information.
  4. Training-Free & Plug-and-Play: LAVa requires no fine-tuning or complex hyperparameter search, making it easy to drop into existing inference pipelines.

Key Results and Insights

Evaluation across LongBench, Ruler, and InfiniteBench demonstrates LAVa's superiority. It consistently maintains higher accuracy than baselines like SnapKV and PyramidKV across various cache budgets.

Performance comparison of LAVa against baselines across Mistral and Qwen models for both Generation and Extraction tasks.
  • Extraction vs. Generation: One of the most significant findings is that different tasks need different budget strategies. Extraction tasks (like finding a specific fact in a document) benefit most from dynamic head budgets, while generation tasks (like writing code or summarizing) rely heavily on dynamic layer budgets. By being fully dynamic in both dimensions, LAVa maintains top-tier performance regardless of the task type.
  • Values Matter: Most prior work focused solely on Attention scores. LAVa proves that the magnitude of the Value vector is a critical component of "importance." A token might have high attention, but if its associated value vector is near zero, it contributes little to the final output.
  • Massive Speedups: Compared to a full-cache implementation using FlashAttention-2, LAVa achieved a 9x speedup in decoding latency for 128K-token sequences. It effectively prevented Out-Of-Memory (OOM) errors at high context lengths while maintaining a negligible computational overhead.

Conclusion

LAVa represents a shift from heuristic-based KV cache pruning to a principled, information-theoretic approach. By dynamically allocating budgets across both heads and layers, it effectively manages the memory-performance trade-off for long-context LLMs. Future work will explore integrating LAVa into high-performance frameworks like vLLM and extending the framework to model pruning and online optimization.

Summary updated

Abstract

KV Cache is commonly used to accelerate LLM inference with long contexts, yet its high memory demand drives the need for cache compression.Existing compression methods, however, are largely heuristic and lack dynamic budget allocation.To address this limitation, we introduce a unified framework for cache compression by minimizing information loss in Transformer residual streams.Building on it, we analyze the layer attention output loss and derive a new metric to compare cache entries across heads, enabling layer-wise compression with dynamic head budgets.Additionally, by contrasting cross-layer information, we also achieve dynamic layer budgets.LAVa is the first unified strategy for cache eviction and dynamic budget allocation that, unlike prior methods, does not rely on training or the combination of multiple strategies.Experiments with benchmarks (LongBench, Needle-In-A-Haystack, Ruler, and InfiniteBench) demonstrate its superiority.Moreover, our experiments reveal a new insight: dynamic layer budgets are crucial for generation tasks (e.g., code completion), while dynamic head budgets play a key role in extraction tasks (e.g., extractive QA).As a fully dynamic compression method, LAVa consistently maintains top performance across task types.
BibTeX
@misc{shen2025lava,
  author = {Yuhui Shen and Song Yuan and Zhi Zhang and Fangxing Li and Daxin Jiang and Cam-Tu Nguyen},
  title = {{LAVa: Layer-wise KV Cache Eviction with Dynamic Budget Allocation}},
  year = {2025},
  doi = {10.18653/v1/2025.findings-emnlp.737},
}
Figure