SpectralKV: Redundancy-Aware KV Cache Compression via Spectral Coreset Selection
Abstract
Long-context inference with large language models is limited by the key-value (KV) cache, which grows linearly with the input and is read at every decoding step. Most compression methods evict tokens: they score each cached token on its own, keep the highest-scoring ones, and delete the rest. We revisit this recipe from the perspective of the attention output and show that, when evicted tokens can be merged into kept ones, the output error decomposes exactly over the evicted tokens. The decomposition reveals that an evicted token can be recovered by a kept token whose attention is proportional to its own, so the benefit of keeping a token depends on whether other kept tokens already represent it. Building on this analysis, we propose SpectralKV, a training-free method that compresses the prompt KV cache into a weighted coreset. SpectralKV finds candidate representatives in a key-value space shaped by the covariance spectrum of the observed queries and by the output projection, and scores how much of each token's contribution they recover. It then selects the representatives that maximize importance-weighted coverage jointly across attention heads and merges the remaining tokens into them while preserving their attention mass. Across 29 datasets from LongBench and RULER on Llama-3.1-8B-Instruct and Qwen3-4B, SpectralKV retains 98.1% of the full-cache performance with 5% and 10% of the prompt cache and outperforms the strongest of six recent eviction methods by 3.2 points on average. Code and data are available at https://github.com/Secbrain/SpectralKV.