arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.23200cs.LGcs.CL
收藏

InnerQ: 一种面向硬件的无需调优的KV缓存量化方法用于大语言模型

InnerQ: Hardware-Aware Tuning-Free Quantization of KV Cache for Large Language Models

Department of Electrical and Computer Engineering(电气与计算机工程系)

Sayed Mohammadreza Tayaranian Hosseini, Amir Ardakani, Warren J. Gross

AI总结:

本文提出InnerQ,一种面向硬件的KV缓存量化方法,旨在减少解码延迟而不影响评估性能,通过分组量化策略提高数据重用率,从而在Llama和Mistral模型上提升了少样本评估得分。

摘要:

当基于Transformer的语言模型用于文本生成时,大部分推理时间消耗在解码阶段,其中依次生成输出token。因此,减少每个解码步骤的硬件成本对于高效的长上下文生成至关重要。主要瓶颈是键值(KV)缓存,其大小随序列长度增长,通常主导模型的内存足迹。先前工作提出了压缩KV缓存的同时最小化精度损失的量化方法。我们提出了InnerQ,一种面向硬件的KV缓存量化方案,能够在不牺牲评估性能的情况下减少解码延迟。InnerQ通过沿内维对缓存矩阵进行分组实现分组量化。这种分组策略使去量化与向量-矩阵乘法对齐,并在GPU计算单元之间增加数据重用。结果,InnerQ减少了内存访问并加速了去量化,实现了比先前KV缓存量化方法平均快1.3倍,比非量化基线快2.7倍。为了在剧烈压缩下保持精度,InnerQ结合了三种技术:(i) 混合量化,根据局部统计选择对每个组使用对称或非对称量化;(ii) 高精度窗口用于最近的token和注意力sink token以缓解异常值泄漏;(iii) 对key缓存的通道归一化,在prefill期间计算一次并折叠到模型参数中以消除运行时开销。除了减少延迟外,在Llama和Mistral模型上的实验表明,InnerQ还相对于先前的KV缓存量化方法提升了少样本评估得分。

英文摘要:

When transformer-based language models are deployed for text generation, most of the inference time is spent in the decoding stage, where output tokens are generated sequentially. Reducing the hardware cost of each decoding step is therefore critical for efficient long-context generation. A major bottleneck is the key-value (KV) cache, whose size grows with sequence length and often dominates the model's memory footprint. Prior work has proposed quantization methods to compress the KV cache while minimizing its loss of precision. We present InnerQ, a hardware-aware KV cache quantization scheme that reduces decode latency without compromising evaluation performance. InnerQ performs group-wise quantization by grouping cache matrices along their inner dimension. This grouping strategy aligns dequantization with vector-matrix multiplication and increases data reuse across GPU compute units. As a result, InnerQ reduces memory access and accelerates dequantization, achieving an average $1.3\times$ speedup over prior KV cache quantization methods and $2.7\times$ over the non-quantized baseline. To maintain fidelity under aggressive compression, InnerQ incorporates three techniques: (i) hybrid quantization, which chooses symmetric or asymmetric quantization for each group based on local statistics; (ii) high-precision windows for both recent tokens and attention sink tokens to mitigate outlier leakage; and (iii) per-channel normalization of the key cache, computed once during prefill and folded into the model parameters to eliminate runtime overhead. Beyond reducing latency, experiments on Llama and Mistral models show that InnerQ also improves few-shot evaluation scores relative to prior KV cache quantization methods.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑