2比特压缩键值缓存,让大模型推理更快更省显存
VecInfer: Efficient LLM Inference with Low-Bit KV Cache via Outlier-Suppressed Vector Quantization
- 通过平滑与哈达玛变换抑制键缓存异常值,提升低比特量化效果
- 2比特量化下性能接近全精度,单批延迟降低8.3倍,批量计算快2.7倍
- 适合需要长序列推理的高效部署场景,如超长文本处理
键值(KV)缓存给大语言模型推理带来巨大内存开销。现有向量量化(VQ)方法虽能降低缓存占用并支持多比特灵活表示,但在超低比特下因键缓存异常值导致码本利用不充分,性能严重下降。为此,我们提出VecInfer,一种用于激进KV缓存压缩的新式量化方法,通过平滑和哈达玛变换抑制键缓存中的异常值,使码本能全面覆盖原始数据分布,从而降低量化难度。为实现高效部署,设计了融合计算与反量化操作的优化CUDA内核,减少内存访问开销。大量实验表明,VecInfer在长序列理解与数学推理任务中持续优于现有量化基线。仅使用2比特量化时,性能即接近全精度,在Llama-3.1-8B模型上,196k序列长度下,大规模批处理自注意力计算速度提升2.7倍,单批端到端延迟降低8.3倍。
原文摘要 · Abstract (English)
The Key-Value (KV) cache introduces substantial memory overhead during large language model (LLM) inference. Although existing vector quantization (VQ) methods reduce KV cache usage and provide flexible representational capacity across bit-widths, they suffer severe performance degradation at ultra-low bit-widths due to key cache outliers that hinder effective codebook utilization. To address this challenge, we propose VecInfer, a novel VQ method for aggressive KV cache compression while enabling efficient inference. By applying smooth and Hadamard transformations, VecInfer suppresses outliers in the key cache, enabling the codebook to comprehensively cover the original data distribution and thereby reducing quantization difficulty. To facilitate efficient deployment, we design an optimized CUDA kernel that fuses computation with dequantization to minimize memory access overhead. Extensive evaluations demonstrate that VecInfer consistently outperforms existing quantization baselines across both long-context understanding and mathematical reasoning tasks. With only 2-bit quantization, VecInfer achieves performance comparable to full precision, while delivering up to $\mathbf{2.7\times}$ speedup in large-batch self-attention computation and $\mathbf{8.3\times}$ reduction in single-batch end-to-end latency on Llama-3.1-8B with a 196k sequence length.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。