Expected Attention: KV Cache Compression by Estimating Attention from Future Queries Distribution

Alessio Devoto, Maximilian Jeblick, Simon Jégou · DOI

Introduction

As Large Language Models (LLMs) are deployed for increasingly complex tasks—such as analyzing massive codebases or processing long-form video—the memory requirements for the "Key-Value (KV) cache" have become a critical bottleneck. The KV cache stores the context of a conversation to avoid redundant computations, but its size grows linearly with sequence length. For a 70B parameter model, a one-million-token context requires approximately 320 GB of GPU memory, far exceeding the capacity of individual high-end GPUs.

Existing pruning methods, which attempt to delete unimportant tokens from the cache, face two primary challenges. First, the Future Query Problem: determining a token's current importance requires knowing how future, yet-to-be-generated queries will attend to it. Second, the Materialization Problem: modern efficiency kernels like Flash Attention do not expose the full attention matrix, making it difficult to use historical attention scores as a proxy for future importance.

Methodology: Modeling the Statistical Future

Researchers from NVIDIA and Sapienza University of Rome have introduced Expected Attention, a training-free method that addresses these hurdles by treating future queries as a probability distribution. The core insight is that while individual future query vectors are unknown, the distribution of query activations in modern LLMs is remarkably stable and follows a predictable Gaussian (Normal) distribution.

Figure 1: Histograms of hidden states and query activations across different layers and heads, demonstrating their Gaussian-like distribution.

Statistical Estimation and Closed-Form Solutions

The algorithm operates in three main steps:

  1. Distribution Modeling: It computes the mean and covariance of recent queries to model the statistical behavior of the next sequence of queries.
  2. Expected Attention Scoring: By utilizing the moment-generating function of a Gaussian distribution, the authors derived a closed-form mathematical equation to calculate the "Expected Attention" score for every KV pair currently in the cache. This allows the model to "peek" into the statistical future without needing a separate predictive model.
  3. Residual Stream Weighting: Rather than relying solely on attention scores, the method weights token importance by its impact on the "residual stream." This quantifies how much a specific value vector actually alters the model's final output.

To facilitate further research, the authors also released KVPress, an open-source PyTorch library implementing over 20 different KV cache compression techniques for standardized benchmarking.

Experimental Evaluation

The researchers evaluated Expected Attention across diverse benchmarks, including LongBench (long-context QA), Ruler (retrieval and multi-hop tracing), and Needle in a Haystack (NIAH). They also tested reasoning-heavy models like DeepSeek-R1 and Qwen-R1 on datasets like MATH-500 to ensure compression did not degrade logical capabilities.

Key Results

Expected Attention consistently outperformed state-of-the-art training-free baselines such as TOVA, SnapKV, and KeyDiff.

Figure 2: Performance comparison across multiple benchmarks. The red line (Expected Attention) maintains higher accuracy as compression ratios increase compared to other methods.
  • High Fidelity Compression: On the NIAH test, the method maintained 100% accuracy even after pruning 50% of the KV cache.
  • Memory Savings: For a 120k token context on Llama 3.1-8B, the method saved approximately 15GB of GPU memory compared to uncompressed baselines.
  • Reasoning Resilience: In high-compression scenarios (up to 12x reduction), Expected Attention showed significantly better retention of mathematical reasoning capabilities than competing methods.

Conclusion and Future Work

Expected Attention represents a significant step forward in training-free KV cache management by leveraging the statistical regularities of LLM activations. While it currently requires manual specification of compression ratios, future work may involve automated mechanisms to determine optimal pruning levels dynamically. Additionally, integrating these mathematical insights into custom CUDA kernels (e.g., vLLM or TensorRT-LLM) could further bridge the gap between research-grade flexibility and production-speed efficiency.

Summary updated

BibTeX
@misc{devoto2025expected,
  author = {Alessio Devoto and Maximilian Jeblick and Simon Jégou},
  title = {{Expected Attention: KV Cache Compression by Estimating Attention from Future Queries Distribution}},
  year = {2025},
  eprint = {2510.00636},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.00636},
}
Figure