LogQuant: Log-Distributed 2-Bit Quantization of KV Cache with Superior Accuracy Preservation
Han Chen, Zicong Jiang, Zining Zhang, Bingsheng He, Pingyi Luo, Mian Lu, Yuqiang Chen
TL;DR
LogQuant introduces a log-based 2-bit quantization strategy for KV caches in LLM inference, driven by the observation that attention spike positions follow a log distribution. By combining a log-distributed token selection with a position-agnostic attention calculation, it preserves crucial tokens while reducing memory, outperforming prior 2-bit methods like KiVi in accuracy and delivering notable throughput gains under a fixed memory budget. Empirical results across Llama3, Qwen, and Phi models on GSM8K and LongBench demonstrate improved task accuracy, particularly on Math and Code Completion, alongside hardware-efficient benefits such as ~25% higher throughput and ~60% larger batch sizes on an H100 with HuggingFace. The approach integrates cleanly with the Transformer ecosystem, offering a practical path to efficient, long-context inference in resource-constrained environments.
Abstract
We introduce LogQuant, a groundbreaking 2-bit quantization technique for KV Cache in large language model (LLM) inference, delivering substantial memory savings while preserving superior performance. Previous methods either assume that later tokens are more important or attempt to predict important tokens based on earlier attention patterns. Both approaches, however, can result in performance bottlenecks or frequent mispredictions. LogQuant takes a different approach. By applying a log-based filtering mechanism, it selectively compresses the KV Cache across the entire context, achieving better performance with the same or even reduced memory footprint compared to existing methods. In benchmark tests, it enhances throughput by 25% and boosts batch size by 60% without increasing memory consumption. For challenging tasks such as Math and Code Completion, LogQuant improves accuracy by 40% to 200% at the same compression ratio, outperforming comparable techniques.LogQuant integrates effortlessly with popular inference frameworks like Python's transformers library. Implementation can be available in https://github.com/Concyclics/LogQuantKV.
