ResKV: Residual-based Channel-wise Unstructured Pruning for KV Cache Compression

Yue Chen, Jinze Li, Dajiang LiuNeurIPS 2026

TL;DR

When large language models read massive documents, their short-term memory—the Key-Value (KV) cache—balloons in size and chokes GPU bandwidth. ResKV solves this by grouping semantically similar memory vectors together and only pruning and quantizing the tiny differences (residuals) from each group's average. This simple mathematical shift slashes memory usage and delivers over 4× faster generation throughput without making the model forget what it just read.

What Problem Does This Paper Address?

As LLMs scale to 100K+ token contexts, the KV cache—which stores intermediate attention representations for past tokens so the model doesn't recompute them—grows linearly with sequence length. During text generation, streaming this massive cache from GPU memory for every single new word creates a severe memory bottleneck.

One popular way to shrink the KV cache is channel-wise unstructured pruning: zeroing out the least important feature dimensions inside each token's vector. However, existing pruning methods operate directly on raw vectors and hit two walls:

  1. Steep accuracy drops at high sparsity: Zeroing out 75% or more of a raw vector distorts its direction too much, confusing the attention mechanism.
  2. Quantization incompatibility: Ideally, we want to combine pruning with low-bit quantization (shrinking 16-bit numbers to 4-bit). Because different tokens lose different channels, you have to quantize per-token. Unfortunately, raw Key vectors contain notorious "outlier" channels with massive values that ruin per-token quantization scales.

Prior pruning methods completely overlooked a well-known quirk of LLMs: many KV vectors across a sequence are semantically very similar to one another.

Figure 1: Comparison of different channel-wise pruning methods. (a) Input-based pruning (Musta- far), (b) output-based pruning (SparK), and (c) residual-based pruning (ResKV).

Methods

Instead of pruning raw vectors, ResKV borrows a classic idea from signal compression: store a shared reference, and compress only the residuals.

  1. Pre-RoPE Global Clustering: Before positional encodings (RoPE) are applied, ResKV uses global K-means clustering to group cached Key and Value vectors into $N_C$ semantic clusters (defaulting to 32), computing a high-precision BF16 centroid for each.
  2. Residual Extraction, Pruning, and Quantization: Each token's cluster centroid is subtracted from its original vector, leaving behind a low-magnitude, near-zero residual vector. ResKV then applies unstructured channel-wise pruning (tracking kept channels with a compact 128-bit binary mask) and low-bit per-token quantization exclusively to these residuals. Centroids stay in fast on-chip shared GPU memory, while tiny sparse residuals sit in off-chip memory.
  3. Asymmetric Flash Decoding: ResKV integrates directly into Flash Decoding, treating Keys and Values differently to save compute. Because RoPE requires full dense vectors, Keys are fully reconstructed on the fly (adding the centroid back to the sparse residual) before computing attention scores. For Values, ResKV uses deferred centroid fusion: it accumulates attention-weighted sparse residuals across token chunks first, and only multiplies in the Value centroids once globally at the very end.
Figure 3: The compression process of ResKV.

During inference, initial "attention sink" tokens (the first four tokens) and a small sliding window of recent tokens are kept uncompressed, flushing into existing clusters once the window fills up.

Datasets

Because ResKV is a plug-and-play inference method, no training datasets are required. The authors evaluate on Llama-3-8B, Llama-3.1-8B, and Qwen3-8B using established long-context benchmarks (no new benchmarks are introduced):

  • WikiText-2: Used for motivational analysis of vector magnitudes and cosine distances.
  • LongBench: Evaluates real-world tasks including single/multi-document QA, summarization, code completion, few-shot learning, and synthetic tasks (tested at 8K and 16K lengths).
  • RULER & Needle-In-A-Haystack (NIAH): Used to test retrieval fidelity across 13 tasks at 16K context length and varying document depths.

Key Insights and Ideas

  • Cluster before RoPE: Rotary Positional Embeddings twist vectors in space based on where they sit in the text, destroying their natural semantic similarity. Intercepting raw Keys before RoPE yields much tighter clusters and smaller residuals.
  • Residuals tame the outliers: Subtracting the cluster centroid absorbs the massive channel-wise outliers that normally break quantization. On Llama-3-8B, the average feature magnitude drops from 19.77 in raw/pruned Key vectors down to just 3.69 in residual vectors—making per-token INT4 quantization suddenly viable alongside unstructured pruning.
  • Minimal angular distortion: At 75% sparsity, standard pruning methods warp Key vectors to cosine distances of 0.05–0.08 from the original. Compensating pruned residuals with centroids keeps the average cosine distance at a tiny 0.01.
Figure 2: Motivation analysis on Llama-3-8B-Instruct at 75% sparsity using WikiText-2 (Layer 16, Head 1). (a) The cosine distance between original Key vector and pruned Key vector of different approaches. (b) The feature magnitude of the original Key vector and the residual Key vector.
  • Linearity gives Values a free lunch: Because the attention output is just a weighted sum of Value vectors, you don't actually need to reconstruct full Value vectors per token. Factoring out the centroids saves massive per-token arithmetic during decoding.

Key Results

  • Throughput Speedups: With an 8K input and 2K output on Llama-3.1-8B at 75% sparsity, ResKV hits 4.27× higher generation throughput than the FlashAttention-2 dense baseline (at batch size 16) and 2.63× higher end-to-end throughput than Mustafar, a competing channel-pruning baseline (at batch size 32).
  • Memory Savings: At batch size 32 and 75% sparsity, ResKV cuts peak GPU memory from 75.97 GB down to 47.70 GB—a 37.2% reduction, allowing larger batch sizes on a single GPU.
  • Accuracy Retention: At 50% sparsity, ResKV retains ~99.6–99.8% of dense baseline accuracy on LongBench. At 75% sparsity on Llama-3-8B, it beats SparK and Mustafar by 2.05 and 2.26 points. Under extreme 87.5% sparsity, where baselines collapse, ResKV outperforms them by +6.5 to +9.2 points across Llama-3-8B and Qwen3-8B.

Limitations and Future Work

The authors highlight two practical trade-offs:

  • Prefill Latency: Running K-means clustering on prompt tokens introduces a mild, one-time latency overhead during the prefill stage before generation begins.
  • Centroid Drift in Long Generations: Once the clusters are established up to the predefined maximum count, newly generated tokens during decoding are assigned to existing centroids. If the generated text shifts to a wildly different topic, new KV vectors may be dissimilar to the old centroids, shrinking the accuracy advantage of residual pruning. No specific future work directions are explicitly outlined beyond these observations.

Summary updated

Abstract

In modern LLM applications, the demand for extended context lengths continues to surge, making KV cache a major performance bottleneck in long-context inference. Channel-wise pruning has emerged as a prevalent KV cache compression paradigm; however, existing solutions overlook inherent similarities among KV vectors, resulting in limited pruning ratios and noticeable performance degradation. To tackle this issue, we present ResKV, a novel residual-driven channel-wise pruning framework that fully exploits KV vector similarity for effective compression. ResKV first clusters highly similar KV vectors via cosine similarity metrics, then calculates residual vectors by subtracting each cluster’s centroid from the original features. Subsequent channel-wise unstructured pruning and per-token quantization are exclusively applied to these residual components. During inference, preserved residuals are combined with their corresponding centroids to accurately recover dense KV representations. Benefiting from the low magnitude and sparse, near-zero properties of centroid residuals, both pruning and quantization incur only negligible approximation errors. Experimental results show that, at 75% sparsity, ResKV achieves 4.27× the inference throughput of the dense baseline while sustaining competitive model performance. Under the same sparsity setting, ResKV improves the average LongBench score by up to 2.26 points over state-of-the-art channel-wise KV pruning methods and achieves 2.63× the end-to-end throughput of a competing pruning baseline. Our code is publicly available at https://github.com/coralabo/ResKV.
BibTeX
@inproceedings{chen2026reskv,
  author = {Yue Chen and Jinze Li and Dajiang Liu},
  title = {{ResKV: Residual-based Channel-wise Unstructured Pruning for KV Cache Compression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=PcOi9GxwJj},
}
Figure