Post

Q-Filters: Leveraging QK Geometry for Efficient KV Cache Compression

arXiv

Abstract
Autoregressive language models rely on a Key-Value (KV) Cache, which avoids re-computing past hidden states during generation, making it faster. As model sizes and context lengths grow, the KV Cache becomes a significant memory bottleneck, which calls for compression methods that limit its size during generation. In this paper, we discover surprising properties of Query (Q) and Key (K) vectors that allow us to efficiently approximate attention scores without computing the attention maps. We propose Q-Filters, a training-free KV Cache compression method that filters out less crucial Key-Value pairs based on a single context-agnostic projection. Contrarily to many alternatives, Q-Filters is compatible with FlashAttention, as it does not require direct access to attention weights. Experimental results in long-context settings demonstrate that Q-Filters is competitive with attention-based compression methods such as SnapKV in retrieval tasks while consistently outperforming efficient compression schemes such as Streaming-LLM in generation setups. Notably, Q-Filters achieves a 99% accuracy in the needle-in-a-haystack task with a ×32 compression level while reducing the generation perplexity drop by up to 65% in text generation compared to Streaming-LLM.

This work was co-authored with Alessio Devoto, Yu Zhao, Simone Scardapane, Pasquale Minervini, and my PhD supervisors Éric de la Clergerie and Benoît Sagot. It was presented at the Sparsity in LLMs (SLLM) workshop in 2025.

Here is the PDF version of the paper that you can also find on arXiv:

Please cite as:

1
2
3
4
5
6
7
8
@misc{godey2025qfilters,
      title={Q-Filters: Leveraging QK Geometry for Efficient KV Cache Compression},
      author={Nathan Godey and Alessio Devoto and Yu Zhao and Simone Scardapane and Pasquale Minervini and Éric de la Clergerie and Benoît Sagot},
      year={2025},
      eprint={2503.02812},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
This post is licensed under CC BY 4.0 by the author.