Abstract
As Large Language Models (LLMs) scale to longer contexts and larger batch sizes, the memory footprint of the Key-Value (KV) cache becomes a critical bottleneck. Existing low-bit Vector Quantization (VQ) methods often rely on calibration datasets, making them vulnerable to distribution shifts. We present NSNQuant, a calibration-free VQ method that compresses the KV cache to as low as 1 or 2 bits. By employing a "Normalize-Shift-Normalize" (NSN) process combined with a Hadamard transform, NSNQuant forces diverse input distributions into a standard normal distribution. This allows for the use of a universal, pre-computed codebook, ensuring robustness across out-of-distribution (OOD) scenarios and achieving up to 3× throughput gains with superior generalization.
The Problem: Brittle Calibration in KV Compression
In the quest to optimize LLM inference, Vector Quantization (VQ) has emerged as a powerful tool for reducing the memory overhead of the KV cache. By grouping values into vectors and mapping them to a learned codebook, memory usage can be slashed significantly. However, state-of-the-art methods like Coupled Quantization (CQ) are "calibration-dependent." They require a small sample dataset (e.g., WikiText-2) to optimize their codebooks.
This dependency creates a major reliability gap. If real-world data differs even slightly from the calibration set—such as varying punctuation usage in the C4 dataset versus WikiText—the quantization error spikes. In models like LLaMA-3, specific punctuation tokens can account for up to 90% of attention weights; misquantizing these "outliers" leads to total model collapse. This distribution shift makes current low-bit KV compression unreliable for general-purpose applications.
Methodology: The Normalize-Shift-Normalize (NSN) Process
NSNQuant addresses the distribution shift problem by transforming the data to fit a universal codebook, rather than adapting the codebook to the data. The core innovation is the Normalize-Shift-Normalize (NSN) process, which, when paired with a Hadamard Transform, standardizes the KV cache into a known distribution.
The transformation involves four key steps:
- Token-wise Normalization: Scales each token to a fixed norm to prevent extreme outliers from dominating the quantization process.
- Channel-wise Centering (Shift): Subtracts the mean across channels to center the distribution at zero.
- Second Token-wise Normalization: Re-normalizes the result to ensure consistent variance across tokens.
- Hadamard Transform: Applies a rotation matrix that "spreads out" remaining outliers. Leveraging the Central Limit Theorem, this step ensures the final data distribution closely approximates a standard Gaussian ($\\mathcal{N}(0,1)$).
By mathematically forcing the KV cache into this standard distribution, NSNQuant can utilize a single, pre-computed codebook for any model or dataset, eliminating the need for calibration.
Key Results and Insights
Robustness and Generalization
NSNQuant was evaluated across a wide array of benchmarks, including LongBench (long-context tasks), GSM8K (math), and HumanEval (coding), using models like LLaMA-3 and Mistral-7B. In 1-bit and 2-bit settings, NSNQuant consistently outperformed baselines on the C4 dataset. While prior methods saw perplexity explode on OOD data, NSNQuant remained stable, demonstrating that standardization is superior to adaptation for general-purpose robustness.
1-Bit Breakthrough
The NSNQuant-1b configuration (utilizing approximately 1.23 bits per value) achieved a significant lead over previous state-of-the-art 1-bit methods. Many existing 1-bit approaches fail to produce coherent text at such high compression ratios, whereas NSNQuant maintains high accuracy and reasoning capabilities.
Efficiency and Throughput
Beyond accuracy, the authors implemented custom CUDA kernels to optimize the NSNQuant pipeline. These kernels achieved up to a 3× throughput improvement over full-precision (FP16) baselines. This efficiency allows for 4× larger batch sizes on the same hardware, directly addressing the primary bottleneck in large-scale LLM deployment.
Conclusion and Future Work
NSNQuant represents a shift toward calibration-free quantization, providing a robust and efficient path for low-bit KV cache compression. While the method effectively tames most outliers, the authors note that "extreme" outliers in the very first layers of some models still pose a challenge. Future work may involve explicitly modeling these early-layer exceptions or exploring inter-channel correlations to further refine 1-bit performance without sacrificing the robustness gained through standardization.
Summary updated