[Paper Review] KIVI : Plug-and-play 2bit KV Cache Quantization with Streaming Asymmetric Quantization
KIVI proposes a plug-and-play, tuning-free 2-bit asymmetric quantization method for key-value (KV) cache in large language model inference, using per-channel quantization for keys and per-token quantization for values. It reduces peak memory usage by 2.6× and enables up to 4× larger batch sizes, achieving 2.35×–3.47× higher throughput with minimal accuracy loss on Llama, Falcon, and Mistral models.
Efficiently serving large language models (LLMs) requires batching of many requests to reduce the cost per request. Yet, with larger batch sizes and longer context lengths, the key-value (KV) cache, which stores attention keys and values to avoid re-computations, significantly increases memory demands and becomes the new bottleneck in speed and memory usage. Additionally, the loading of the KV cache causes the computational core to be idle, which limits the inference speed. A straightforward and effective solution to reduce KV cache size is quantization, which decreases the total bytes taken by KV cache. However, there is a lack of in-depth studies that explore the element distribution of KV cache to understand the hardness and limitation of KV cache quantization. To fill the gap, we conducted a comprehensive study on the element distribution in KV cache of popular LLMs. Our findings indicate that the key cache should be quantized per-channel, i.e., group elements along the channel dimension and quantize them together. In contrast, the value cache should be quantized per-token. From this analysis, we developed a tuning-free 2bit KV cache quantization algorithm named KIVI. With hardware-friendly implementation, KIVI can enable Llama, Falcon, and Mistral models to maintain almost the same quality while using $\mathbf{2.6 imes}$ less peak memory (including model weight). This reduction in memory usage enables up to $\mathbf{4 imes}$ larger batch size, bringing $\mathbf{2.35 imes \sim 3.47 imes}$ throughput on real LLM inference workload. The source code is available at https://github.com/jy-yuan/KIVI.
Motivation & Objective
- To address the growing memory and speed bottleneck caused by KV cache in large language model (LLM) inference under high batch sizes and long context lengths.
- To analyze the element distribution of KV cache across popular LLMs to understand quantization challenges and limitations.
- To develop a hardware-friendly, tuning-free 2-bit quantization method that maintains model accuracy while drastically reducing memory usage.
- To enable larger batch sizes and higher throughput in real-world LLM inference workloads through efficient KV cache compression.
Proposed method
- Proposes KIVI, a plug-and-play 2-bit asymmetric quantization method for KV cache that requires no fine-tuning or model retraining.
- Applies per-channel quantization to key cache, grouping elements along the channel dimension to confine quantization error per channel.
- Applies per-token quantization to value cache, aligning with the streaming nature of autoregressive generation and isolating error per token.
- Splits KV cache into grouped and residual parts: applies group-wise quantization to grouped segments and keeps residuals in full precision.
- Uses tiled matrix multiplication to combine grouped and residual cache parts during attention computation, preserving accuracy.
- Employs hardware-friendly implementation to minimize quantization overhead in prefill and decoding phases.
Experimental results
Research questions
- RQ1How do the element distributions of key and value caches in LLMs differ, and what implications do these differences have for quantization strategies?
- RQ2Why is per-channel quantization more effective for key cache, while per-token quantization is better for value cache?
- RQ3Can a 2-bit quantization scheme achieve high model accuracy without fine-tuning, given the streaming and dynamic nature of KV cache?
- RQ4What is the impact of different quantization schemes on memory usage, batch size, and throughput in real LLM inference workloads?
- RQ5How does the grouping and residual split mechanism in KIVI maintain accuracy while enabling efficient quantization of large, streaming KV caches?
Key findings
- Per-channel quantization of key cache reduces error propagation across channels and is essential due to the presence of high-magnitude outlier channels.
- Per-token quantization of value cache is necessary because value cache acts as a mixer in attention computation, and error must be isolated per token.
- KIVI reduces peak memory usage by 2.6× for Llama-2-7B while maintaining near-identical model quality across multiple benchmarks.
- The method enables up to 4× larger batch sizes and achieves 2.35× to 3.47× higher throughput on real LLM inference workloads.
- Ablation studies confirm that group size and residual length have a measurable but manageable impact on performance, with optimal configurations found empirically.
- KIVI maintains strong performance across diverse models including Llama, Falcon, and Mistral, with minimal accuracy drop even at 2-bit precision.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.