通过硬件感知分组量化,显著加速大模型解码阶段的键值缓存处理。
InnerQ: Hardware-Aware Tuning-Free Quantization of KV Cache for Large Language Models
- 按内维分组量化键值缓存,提升GPU数据重用效率
- 相比之前方法平均提速1.3倍,较未量化基线快2.7倍
- 支持高精度窗口与通道归一化,适合长文本生成场景
当基于Transformer的语言模型用于文本生成时,大部分推理时间集中在解码阶段,输出标记按顺序生成。降低每个解码步骤的硬件开销对高效长上下文生成至关重要。主要瓶颈在于键值(KV)缓存,其大小随序列长度增长,常占据模型内存的主要部分。以往工作提出量化方法压缩KV缓存,同时最小化精度损失。本文提出InnerQ,一种硬件感知的、无需调优的KV缓存量化方案,在不牺牲评估性能的前提下减少解码延迟。InnerQ通过沿内维分组缓存矩阵进行分组量化,该策略使反量化操作与向量-矩阵乘法对齐,并增强跨GPU计算单元的数据重用。因此,InnerQ减少了内存访问并加速了反量化,相比先前的KV缓存量化方法平均提速1.3倍,相比非量化基线提速2.7倍。为在激进压缩下保持精度,InnerQ引入三项技术:(i) 混合量化,根据局部统计选择每组的对称或非对称量化;(ii) 对近期标记和注意力汇集标记采用高精度窗口,缓解异常值泄露;(iii) 键缓存的逐通道归一化,预填充阶段计算一次并融合进模型参数,消除运行时开销。实验表明,除降低延迟外,InnerQ在Llama和Mistral模型上还优于先前的KV缓存量化方法的少样本评估得分。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。