arXiv:2502.00527cs.LGcs.CL2025-02NeurIPS被引 7

通过极坐标变换解决键缓存量化中的异常值问题,提升大模型推理效率。

PolarQuant: Leveraging Polar Transformation for Efficient Key Cache Quantization and Decoding Acceleration

  • 将键向量按二维分组,用极坐标半径和角度量化,缓解异常值影响。
  • 在保持全精度模型性能前提下,实现键缓存高效量化与解码加速。
  • 适合需要低延迟、高内存效率的大语言模型部署场景。

大语言模型中的键值(KV)缓存是内存占用的主要因素,制约其广泛应用。量化缓存至低位宽可有效降低计算开销,但以往方法在量化键向量时因异常值存在而效果受限。本文提出一种新量化方法 PolarQuant,针对旋转位置编码下异常值通常仅出现在一个维度的特性,将二维向量转换为极坐标表示,使半径和角度在极坐标中分布平滑。PolarQuant 将键向量分组为二维子向量,以量化后的半径和极角进行编码,而非直接量化原始键向量。该方法显著提升 KV 缓存量化效率,并通过将查询-键内积转化为查表操作,加速解码过程,同时维持与全精度模型相当的下游性能。

原文摘要 · Abstract (English)

The KV cache in large language models is a dominant factor in memory usage, limiting their broader applicability. Quantizing the cache to lower bit widths is an effective way to reduce computational costs; however, previous methods struggle with quantizing key vectors due to outliers, resulting in excessive overhead. We propose a novel quantization approach called PolarQuant, which efficiently addresses the outlier challenge. We observe that outliers typically appear in only one of two dimensions, which are rotated together by a specific angle when rotary position embeddings are applied. When represented as two-dimensional vectors, these dimensions exhibit well-structured patterns, with radii and angles smoothly distributed in polar coordinates. This alleviates the challenge of outliers on per-channel quantization, making them well-suited for quantization. Thus, PolarQuant divides key vectors into groups of two-dimensional sub-vectors, encoding them as the corresponding quantized radius and the polar angle, rather than quantizing original key vectors directly. PolarQuant achieves the superior efficiency in KV cache quantization and accelerates the decoding process by turning the query-key inner product into a table lookup, all while maintaining the downstream performance of full-precision models.

量化大模型推理加速

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。