Introduction
As Large Language Models (LLMs) scale toward "infinite" context windows, the Key-Value (KV) cache has emerged as a critical memory bottleneck. Storing representations for every token in high precision consumes gigabytes of VRAM, often exceeding the memory requirements of the model weights themselves. While quantization and adaptive eviction have been proposed as separate solutions, combining them effectively remains a challenge due to accuracy degradation at low bit-widths and system-level incompatibilities with high-performance kernels like FlashAttention.
MiniKV bridges this gap through a holistic algorithm-system co-design. It achieves over 80% KV cache compression by synergizing 2-bit quantization with adaptive token eviction policies, resulting in a 48% throughput boost and the capacity to handle 44K-token contexts on a single GPU.
Methodology: Algorithm-System Co-Design
MiniKV introduces a three-pronged approach to maximize compression without sacrificing model performance:
- Persistent Context Selection: Observations indicate that "heavy hitter" tokens—those with high attention scores identified during the initial prefill stage—remain consistently important throughout the generation process. MiniKV identifies these tokens once and locks them in the cache, avoiding redundant importance calculations.
- Pyramid KV Allocation: Recognizing that different layers contribute differently to context processing, MiniKV employs a "pyramid" strategy. It allocates a larger cache budget to lower layers (requiring broader context) and reduces the budget for higher layers, optimizing accuracy within a fixed memory footprint.
- Hybrid Quantization: The system utilizes 2-bit sub-channel quantization for Keys to manage outliers and per-token quantization for Values.
To resolve the incompatibility between token eviction and memory-efficient attention, MiniKV implements a Two-Pass Triton Kernel. Standard FlashAttention avoids materializing the full attention matrix, making it difficult to calculate the scores needed for eviction. MiniKV’s custom kernel re-computes necessary scores in a second pass with linear memory complexity, enabling adaptive eviction to work alongside high-performance inference.
Experimental Evaluation
The authors evaluated MiniKV across several rigorous benchmarks, including LongBench (13 datasets for QA and summarization), InfiniteBench (context lengths up to 100k+ tokens), and GSM8K (mathematical reasoning). Testing was conducted on Llama-2 (7B, 13B), Llama-3 (1B, 3B, 8B), and Mistral-7B models.
Key Results and Insights
MiniKV demonstrates substantial improvements in both efficiency and performance:
- Massive Compression: The system achieves an 86% KV cache reduction while maintaining accuracy comparable to full-precision models.
- Throughput and Memory: It delivers up to 48% higher throughput than KIVI (the previous SOTA for 2-bit quantization) and supports prompt lengths of up to 44K tokens on a single NVIDIA A100 (40GB).
- Pareto Dominance: Across LongBench categories, MiniKV consistently defines the Pareto frontier, offering the best accuracy-to-memory trade-off.
A key insight from the study is the discovery of Persistence. Since 60-80% of important tokens remain relevant throughout generation, the system can "lock in" these tokens in a hardware-friendly manner. Furthermore, the researchers found that synergy is crucial; while some eviction policies like SnapKV are sensitive to 2-bit quantization, the H2O-based approach used in MiniKV proves highly robust.
Limitations and Future Directions
While MiniKV significantly advances KV cache efficiency, several areas remain for future exploration. The current implementation focuses exclusively on the KV cache; combining it with weight quantization methods like GPTQ or AWQ could yield further gains. Additionally, while Triton provides portability, the kernels are currently optimized for NVIDIA architectures. Extending these principles to other hardware accelerators like AMD GPUs or TPUs is a natural next step.
Summary updated