SpectralKV: Redundancy-Aware KV Cache Compression via Spectral Coreset Selection

Fangming Zhao, Xiaofei Yue, Fulun Ye, Yu Peng, Junyu Chen, Tingting Li, Ziming ZhaoNeurIPS 2026

TL;DR

When compressing a Large Language Model’s memory (its KV cache) to handle long contexts, standard algorithms act like ruthless bouncers—scoring tokens individually and deleting the rest, which wastes precious space on repetitive, high-scoring words. SpectralKV turns cache compression into a representation game: instead of deleting evicted tokens, it merges redundant ones into "representative" kept tokens while preserving their total attention weight. Without any model retraining, it slashes prompt memory down to 5–10% while keeping 98.1% of the model's original brainpower.

What Problem Does This Paper Address?

To generate text without re-reading the entire prompt at every step, LLMs store past keys and values in a KV cache. For long inputs, this cache balloons: a single 128K-token prompt on an 8B model eats up 16 GiB of memory—roughly as big as the model weights themselves.

Because attention is naturally sparse, standard "eviction" methods shrink the cache after reading the prompt (prefill) by looking at the last few queries (an observation window), ranking every cached token by how much attention it gets, keeping the top-$k$, and deleting the rest.

Here is the catch: ranking tokens in isolation ignores redundancy. Long documents repeat concepts constantly. If "Prices" and "fee" behave nearly identically under attention, top-$k$ eviction wastes two slots keeping both while deleting unique, slightly lower-scoring details like "5%" and "May". Even existing cache-merging methods still decide which tokens to keep by ranking them individually first.

Figure 1: Top-k eviction (a) and SpectralKV (b) on one attention head with a budget of four tokens. Dashed tokens are not stored, and a stacked slot also carries the tokens merged into it. Top-k keeps rising and fee next to rose and Prices; SpectralKV merges them into the latter and keeps 5% and May.

Methods

The authors reframe KV cache compression as building a weighted coreset—a small subset of tokens where each survivor carries a weight (implemented as a tiny attention logit bias) representing both itself and the tokens merged into it.

Figure 2: Overview of SpectralKV on one KV head, illustrated with the sentence of Figure 1. The top row shows the cache after prefill, with one row of attention per observation query and the value of each token. Panels (a) to (c) correspond to Sections 4.1 to 4.3: ∝and ≈mark proportional attention and close values, numbers give the greedy order, dashed bars mark covered tokens, and stacked bars show the attention mass that a kept token carries for merged ones.

SpectralKV operates right after prefill in three main steps:

  1. Spectral Representation Search: Two tokens are interchangeable if their attention weights stay proportional across future queries and their projected values are close. Checking all pairs is too slow ($O(N^2)$), so SpectralKV projects keys and values into a custom spectral space shaped by the covariance of observed queries and the output projection matrix. Here, Euclidean distance directly reflects whether two tokens have proportional attention and similar outputs, allowing fast nearest-neighbor search among local candidates.
  2. Coverage-Based Selection: Instead of top-$k$ ranking, SpectralKV maximizes a facility-location objective jointly across all heads in a layer. Using a fast lazy-greedy algorithm (which guarantees at least a $1 - 1/e$ approximation of the optimal set), it picks tokens that cover the most "importance-weighted" ground, naturally allocating more slots to heads with diverse information.
  3. Mass-Preserving Merging & Budgets: Evicted tokens are blended into their best kept representative, scaling up the representative's attention mass so total attention is preserved (with a held-out validation check to revert to deletion if merging hurts a specific head). Layer budgets are divided based on how much a layer's attention shifts across queries—either dynamically per prompt, or via a fast, pre-calibrated Fixed profile that compresses layers on the fly during prefill.

Datasets

SpectralKV is training-free and evaluated across 29 datasets (2,250 test inputs per model/budget):

  • LongBench: 16 English tasks covering single/multi-document QA, summarization, few-shot learning, synthetic tasks, and code.
  • RULER (at 16K context length): All 13 synthetic stress-test tasks, including needle-in-a-haystack variants, variable tracking, QA, and word-frequency aggregation.
  • Calibration: SpectralKV-Fixed uses a small, separate 58-input calibration set per model to fix layer budget shares offline. No new benchmarks are introduced.

Key Insights and Ideas

  • Exact Error Decomposition: The authors prove mathematically (Proposition 1) why standard deletion hits a wall. When you delete a token, its error depends solely on itself—kept tokens cannot rescue it. When you merge a token with proportional attention into a representative, its output error drops to zero.
  • Selection and Merging Need Each Other: Ablations reveal a neat synergy. Selecting diverse tokens without merging barely helps (+0.07 points over top-$k$), because leaving out an important redundant copy still loses its attention weight. Only when paired with mass-preserving merging does coverage-based selection shine.
  • Counting with Attention Mass: In tasks where frequency matters (like finding the most common words in a massive list), deleting duplicate words erases the model's ability to count them. Merging folds the attention mass of 50 evicted copies onto 1 kept representative, preserving the "count" in the attention logits.

Key Results

Tested on Llama-3.1-8B-Instruct and Qwen3-4B at strict 5% and 10% cache budgets against six recent baselines (including SnapKV, CriticalKV, Layer-DefensiveKV, and ReST-KV):

  • Overall Retention: SpectralKV retains 98.1% of full-cache performance on average across all settings, beating the strongest baseline (ReST-KV) by 3.2 points.
  • Crushing Redundancy: On RULER’s Common-Word Extraction (CWE) at a 5% budget on Llama-3.1, SpectralKV scores 70.0, more than doubling the best baseline (32.4).
  • Multi-Token Precision: Because it propagates importance across subwords within a word, it hits 100.0 on Llama-3.1 (and 82–98 on Qwen3) on needle tasks with long, multi-token UUIDs, where several baselines collapse.
  • Low One-Time Overhead: On an H20 GPU, SpectralKV-Fixed performs on par with dynamic layer allocation while adding just ~0.67–0.69s to a 16K-token prefill—a one-time cost before enjoying a 10×–20× smaller cache at every decoding step.

Limitations and Future Work

  • Prefill-Only Compression: SpectralKV compresses the prompt cache once after prefill and appends newly generated tokens uncompressed. If a model generates ultra-long reasoning chains or outputs, the cache will grow again during decoding; extending coverage selection and mass-preserving merging to the decoding phase is left as the natural next step.
  • Reliance on the Observation Window: Like SnapKV-style methods, SpectralKV estimates future query behavior using the prompt's final window of tokens (plus positional rotations). If later decoding queries attend to completely unrepresented directions, proportionality may break—partially mitigated here by requiring merged tokens to also have similar values and verifying merges on held-out window queries.

Summary updated

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.
BibTeX
@inproceedings{zhao2026spectralkv,
  author = {Fangming Zhao and Xiaofei Yue and Fulun Ye and Yu Peng and Junyu Chen and Tingting Li and Ziming Zhao},
  title = {{SpectralKV: Redundancy-Aware KV Cache Compression via Spectral Coreset Selection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=ttixAKQvFd},
}
Figure