Lookahead Q-Cache: Achieving More Consistent KV Cache Eviction via Pseudo Query

Yixuan Wang, Shiyu Ji, Yijun Liu, Yuzhuang Xu, Yang Xu, Qingfu Zhu, Wanxiang Che · OpenReview

Abstract

Large language models (LLMs) rely on key-value cache (KV cache) to accelerate decoding by reducing redundant computations. However, the KV cache memory usage grows substantially with longer text sequences, posing challenges for efficient deployment. Existing KV cache eviction methods prune tokens using prefilling-stage attention scores, causing inconsistency with actual inference queries, especially under tight memory budgets. In this paper, we propose Lookahead Q-Cache (LAQ), a novel eviction framework that generates low-cost pseudo lookahead queries to better approximate the true decoding-stage queries. By using these lookahead queries as the observation window for importance estimation, LAQ achieves more consistent and accurate KV cache eviction aligned with real inference scenarios. Experimental results on LongBench and Needle-in-a-Haystack benchmarks show that LAQ outperforms existing methods across various budget levels, achieving a 1 ~ 4 point improvement on LongBench under limited cache budget. Moreover, LAQ is complementary to existing approaches and can be flexibly combined to yield further improvements.

Introduction

As Large Language Models (LLMs) are increasingly deployed for long-context tasks, managing the memory footprint of the Key-Value (KV) cache has become a critical bottleneck. The KV cache stores intermediate states to avoid redundant computations during auto-regressive decoding, but its size scales linearly with sequence length. To mitigate this, researchers use eviction strategies to prune less important tokens.

However, a fundamental challenge exists: current eviction methods typically rely on attention scores from the prefilling stage (the initial prompt) to decide which tokens to keep. This creates an "inconsistency" because the tokens required to process an instruction often differ from those needed to generate a specific response. Under tight memory budgets, this misalignment leads to the premature eviction of critical information, degrading model performance.

Methodology: Lookahead Q-Cache (LAQ)

To address this inconsistency, we introduce Lookahead Q-Cache (LAQ). Instead of relying solely on the prefilling stage, LAQ anticipates future needs by generating "pseudo-queries."

Comparison of standard auto-regressive decoding, current KV-cache eviction methods, and the proposed Lookahead Query-Cache (LAQ).

The LAQ framework operates in two primary stages:

  1. Pseudo Lookahead Generation: The model performs a rapid, low-budget generation of a small number of tokens (typically 8). While these "pseudo-queries" may not be perfectly accurate textually, they effectively capture the semantic direction of the model's intended response.
  2. Consistent Eviction: These pseudo-queries serve as a probe to identify which context tokens are most relevant for the upcoming decoding steps. Tokens with high attention scores relative to these lookahead queries are preserved.

We also propose LAQ++, an enhanced version that integrates these lookahead queries with a local observation window (the most recent prompt tokens). This ensures the model maintains awareness of both the long-term context and the immediate instruction.

Experimental Evaluation

We evaluated LAQ across several benchmarks, including LongBench (17 diverse long-context tasks), Needle-in-a-Haystack (fact retrieval), and RULER. Testing was conducted on state-of-the-art open-source models such as Mistral-7B-v0.2-Instruct, Llama3.1-8B-Instruct, and Qwen2.5-7B-Instruct.

Key Results and Insights

Our experiments demonstrate that LAQ significantly improves performance over standard baselines like H2O and SnapKV, particularly under constrained memory budgets. On LongBench, LAQ achieved a 1 to 4 point improvement.

Near-Lossless Retrieval

In the "Needle-in-a-Haystack" test, LAQ++ demonstrated remarkable robustness. Even when the KV cache was pruned to a mere 128 tokens for a 32k context, LAQ++ maintained nearly 100% accuracy, whereas competing methods experienced significant degradation.

Needle-in-a-Haystack performance comparison between SnapKV (Score=76.2) and LAQ++ (Score=99.2) on Mistral-7B.

Efficiency and Orthogonality

  • Low Overhead: The lookahead step is highly efficient, typically adding less than 5% to the total runtime for long-output tasks.
  • The "Jump" in Recall: We observed a significant spike in recall as soon as even 1 or 2 lookahead tokens were used to probe the cache, confirming that even "low-quality" pseudo-queries provide high-quality signals for eviction.
  • Complementary Nature: LAQ is orthogonal to existing methods and can be combined with techniques like SnapKV or PyramidKV to further enhance performance.

Conclusion and Future Work

Lookahead Q-Cache provides a practical and effective solution to the KV cache eviction problem by aligning the eviction process with actual decoding requirements. While there is a minor latency trade-off for the lookahead phase, future work could mitigate this through speculative decoding. Additionally, exploring dynamic lookahead step sizes and layer-wise budget allocation presents promising avenues for further optimization.

Summary updated

BibTeX
@inproceedings{wang2025lookahead,
  author = {Yixuan Wang and Shiyu Ji and Yijun Liu and Yuzhuang Xu and Yang Xu and Qingfu Zhu and Wanxiang Che},
  title = {{Lookahead Q-Cache: Achieving More Consistent KV Cache Eviction via Pseudo Query}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  doi = {10.18653/v1/2025.emnlp-main.1732},
}
Figure