PatternKV: Flattening KV Representation Expands Quantization Headroom

Ji Zhang, Yiwei Li, Shaoxiong Feng, Peiwen Yuan, Xinglin Wang, Yueqi Zhang, Jiayi Shi, Chuyi Tan, Boyuan Pan, Yao Hu, Kan Li

As Large Language Models (LLMs) scale to handle longer contexts and complex test-time reasoning, the Key-Value (KV) cache has emerged as a primary memory and bandwidth bottleneck. While quantization—reducing precision from 16-bit floats to 4-bit or 2-bit integers—is a standard mitigation strategy, extreme low-bit quantization often leads to severe accuracy degradation. This occurs because native KV distributions are "peaky" and riddled with extreme outliers.

Existing methods typically rely on outlier protection, storing anomalous values in higher precision while quantizing the rest. However, this fails to address the root issue: the remaining distribution is still not flat enough to be accurately represented by a handful of discrete levels. To unlock true low-bit quantization, the entire distribution must be flattened to expand the "quantization headroom."

Introducing PatternKV

PatternKV is a novel KV cache compression scheme that achieves high-fidelity 2-bit and 4-bit quantization by reshaping the data distribution itself. Instead of quantizing raw values, PatternKV identifies common "patterns" in the data and quantizes only the residuals—the differences between a vector and its closest pattern.

How It Works

PatternKV relies on a variance-decomposition approach executed in four main steps:

  1. Pattern Mining (Prefill Stage): During initial prompt processing, PatternKV employs a GPU-parallel K-means clustering algorithm to identify representative "pattern vectors" (centroids) for each attention head.
  2. Adaptive Updates (Decoding Stage): As generation proceeds, Rotary Positional Embeddings (RoPE) cause the K-cache distribution to drift. PatternKV tracks this evolution dynamically using Chebyshev centers, which minimize the local quantization range and update pattern vectors on the fly.
  3. Residual Quantization: For a given vector $X$, the system locates the nearest pattern $M$ and quantizes the residual $R = X - M$. Because $R$ possesses a significantly smaller dynamic range and a flatter distribution, it can be quantized to 2 bits with minimal information loss.
  4. Adaptive Thresholding for V-Cache: The Value (V) cache exhibits semantic regularities but is less stable across middle layers. PatternKV uses a statistical z-test to automatically determine whether to apply pattern-flattening or revert to standard quantization, ensuring baseline performance is always maintained.

Key Insights

The development of PatternKV was driven by several critical observations about LLM internals:

  • K-Cache Stability: Structural outliers in the K-cache are primarily driven by model-internal weights and activations rather than specific prompts. This allows patterns to be reliably mined online without needing a pre-calculated calibration dataset.
  • The RoPE Effect: Rotary Positional Embeddings induce a smooth, predictable drift in the K-cache distribution over time. This insight led to the use of Chebyshev centers to track the distribution during long generations.
  • Semantic Regularity in V-Cache: V-cache vectors corresponding to similar token types tend to cluster together, particularly in the earliest and latest layers of the model, providing a semantic foundation for pattern mining.
  • Flattening > Protecting: Reshaping the entire distribution to be flatter is fundamentally more effective for low-bit quantization than simply trying to hide or clip outliers.

Evaluation and Results

Researchers evaluated PatternKV across demanding benchmarks, including LongBench (long-context tasks), GSM8K (zero-shot CoT), and AIME & AMC (test-time scaling). Testing on the Llama-3.1 and Qwen-2.5 families demonstrated exceptional performance:

  • Near-Lossless 4-bit: PatternKV achieves a mere 0.08% average accuracy drop compared to full-precision FP16.
  • Superior 2-bit Performance: In extreme low-bit settings, PatternKV consistently outperforms baselines like KIVI and RotateKV, maintaining significantly higher accuracy across all LongBench categories.
  • Enhanced Reasoning: On long-reasoning tasks (test-time scaling), PatternKV improves accuracy by 10% on average compared to existing quantization methods.
  • High Efficiency: Despite the clustering overhead, PatternKV delivers a 1.5× throughput increase over FP16 and supports 1.25× larger batch sizes due to its reduced memory footprint. The memory overhead for storing pattern vectors is negligible (~0.42%).

Limitations and Future Directions

While PatternKV represents a significant leap in KV cache compression, the authors note a few areas for future exploration:

  • Non-RoPE Architectures: Models utilizing ALiBi positional encoding (like MPT) exhibit non-smooth K-cache drift, meaning the current adaptive update strategy may require adjustments for those specific architectures.
  • MLA Integration: Preliminary analysis on Multi-Head Latent Attention (MLA, as seen in DeepSeek-V3) is promising, but systematic evaluation on MLA-native architectures remains for future work.
  • System-Level Optimization: Although custom CUDA kernels were written to fuse operations, tighter integration into inference frameworks like vLLM could further minimize the minor latency overhead introduced during the prefill clustering step.

Summary updated

BibTeX
@inproceedings{zhang2026patternkv,
  author = {Ji Zhang and Yiwei Li and Shaoxiong Feng and Peiwen Yuan and Xinglin Wang and Yueqi Zhang and Jiayi Shi and Chuyi Tan and Boyuan Pan and Yao Hu and Kan Li},
  title = {{PatternKV: Flattening KV Representation Expands Quantization Headroom}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=ozV2cpEgnZ},
}
Figure