Abstract
Large Language Models (LLMs) face significant memory bottlenecks due to the growing size of Key-Value (KV) caches in long-context scenarios. ZipCache is a novel KV cache compression framework that achieves high-ratio quantization (up to ~5x) with minimal accuracy loss. By accurately identifying "salient" tokens through a normalized attention metric and an efficient "probe token" approximation, ZipCache overcomes the biases of previous adaptive methods while remaining compatible with high-speed kernels like FlashAttention.
Introduction: The KV Cache Bottleneck
LLMs generate text autoregressively, requiring the storage of "Key" and "Value" (KV) states for all previous tokens to avoid redundant computation. As context windows expand to 128k tokens or more, the KV cache size can exceed the model weights, severely limiting throughput and increasing deployment costs.
Existing compression strategies typically involve uniform low-bit quantization or adaptive methods that prioritize "important" tokens. However, current adaptive techniques suffer from two major issues:
- Causal Bias: Accumulated attention scores naturally favor earlier tokens, often ignoring critical information at the end of a prompt.
- Computational Overhead: Calculating full attention matrices for saliency is slow and incompatible with fused kernels like FlashAttention.
Methodology
ZipCache addresses these challenges through three key innovations:
Channel-Separable Tokenwise Quantization
Standard groupwise quantization requires significant metadata overhead. ZipCache instead leverages the observation that certain channels act as outliers across all tokens. By normalizing each channel by its maximum value before performing tokenwise quantization, ZipCache handles these outliers effectively while minimizing the memory footprint of quantization parameters.
Normalized Attention Score
To eliminate "early token bias," ZipCache introduces a normalized metric. Instead of simple accumulation, it divides a token's total attention score by the number of times it has been attended to. This ensures that late-arriving but highly relevant tokens (e.g., the specific question in a long math prompt) are correctly identified as salient.
Efficient Saliency Approximation (Probe Tokens)
To maintain FlashAttention compatibility, ZipCache avoids full attention matrix materialization. It uses a small subset of "probe tokens"—comprising 5% recent and 5% random tokens—to estimate saliency. This sampling approach provides sufficient information to identify high-precision KV pairs without the quadratic memory cost of full attention.
Evaluation and Results
The authors evaluated ZipCache on Mistral-7B, LLaMA2, and LLaMA3 across reasoning (GSM8k), coding (HumanEval), and long-context (Line Retrieval) benchmarks.
Performance Comparison
ZipCache consistently outperforms state-of-the-art methods like H2O, GEAR, and MiKV in both accuracy and efficiency.
Key findings include:
- High Compression: On Mistral-7B, ZipCache achieved a 4.98× compression ratio with a negligible 0.38% accuracy drop on GSM8k, whereas MiKV saw a ~5% drop at the same ratio.
- Latency Reduction: Integration with FlashAttention led to a 37.3% prefill speedup and a 56.9% decoding speedup on LLaMA3-8B.
- Memory Efficiency: Total GPU memory usage was reduced by nearly 20%.
- Long-Context Robustness: In "needle in a haystack" tasks, ZipCache maintained 100% accuracy at high compression levels where competing methods failed by evicting critical tokens.
Conclusion
ZipCache demonstrates that accurate saliency identification is the key to high-ratio KV cache quantization. By correcting causal bias and utilizing efficient sampling, it provides a practical path for deploying long-context LLMs without sacrificing performance or accuracy. Future work includes making the saliency ratio adaptive to input complexity and optimizing for diverse hardware architectures.
Summary updated