Abstract
As Large Language Models (LLMs) scale to handle massive context lengths, the Key-Value (KV) cache has become a critical memory bottleneck. Standard quantization methods struggle to maintain accuracy below 1-bit. We introduce AnTKV, a novel framework that achieves ultra-low "sub-bit" compression (down to 0.375 bits per element) with minimal performance loss. By identifying and preserving a tiny fraction (1%) of "anchor tokens" in full precision and employing token-aware vector quantization for the remainder, AnTKV enables scaling LLaMA-3-8B to 840K tokens on a single GPU and provides up to 3.5× higher decoding throughput.
Introduction
The memory required for the KV cache grows linearly with sequence length, often rivaling the model's parameters in long-context scenarios. While Scalar Quantization (SQ) is commonly used to compress these caches to 4-bit or 8-bit, it hits a hard floor at 1-bit. Vector Quantization (VQ) can reach sub-bit regimes by grouping numbers into vectors; however, at extreme compression levels, VQ typically suffers from catastrophic accuracy drops because it treats all tokens as equally important. AnTKV addresses this by recognizing that quantization error is highly non-uniform across tokens.
Methods
AnTKV utilizes a dual-stage framework designed to balance extreme compression with high fidelity:
- Offline Token-Aware Centroid Learning: Instead of standard k-means, AnTKV uses weighted clustering to create VQ codebooks. It uses gradients (derived from forward error analysis) as weights, ensuring the quantization process prioritizes accuracy for the most sensitive data regions.
- Online Anchor Token Selection: The authors developed a lightweight metric called the Anchor Score (AnS) to identify critical tokens on the fly. During inference, the top 1% of tokens with the highest scores are kept in full precision (FP16), while the remaining 99% are aggressively compressed using the learned VQ centroids.
- System Optimization: The framework is implemented with custom GPU kernels using Triton, extending FlashAttention to compute Anchor Scores with minimal overhead.
Key Insights
- The 1% Rule: Preserving just a tiny subset of tokens in full precision is sufficient to stabilize the model under aggressive quantization. These "anchor tokens" are not random; they tend to cluster at the initial "sinks" and the most recent tokens of a sequence.
- VQ vs. SQ: While scalar quantization fails at 1-bit, vector quantization exploits data correlations to reach sub-bit regimes (e.g., 0.375 bits) while maintaining usable performance.
- Pre-RoPE Quantization: Applying quantization before Rotary Position Embeddings (RoPE) yields better results, as RoPE disrupts the data distribution, making it harder to cluster effectively.
Key Results
AnTKV was evaluated across a broad suite of benchmarks including WikiText-2, C4, and LongBench using models like LLaMA-3 and Mistral-7B.
- Superior Accuracy: On Mistral-7B at 1-bit, AnTKV achieved a perplexity of 6.32, significantly outperforming prior state-of-the-art methods like CQ (7.25) and KVQuant (15.36).
- Extreme Compression: AnTKV remains functional even at 0.375 bits, a regime where most other methods fail completely. This allows LLaMA-3-8B to scale to 840,000 tokens on a single 80GB A100 GPU.
- Throughput Gains: By reducing memory I/O, the implementation delivers up to 3.5× higher decoding throughput compared to a standard FP16 baseline.
Conclusion
AnTKV demonstrates that anchor-aware vector quantization can break the 1-bit barrier for LLM KV caches. By focusing precision on the most critical 1% of tokens, the framework enables massive context scaling and significant throughput improvements. Future work will focus on further refining the Anchor Score metrics and optimizing kernels for a wider variety of architectures, such as Mixture-of-Experts (MoE) models.
Summary updated