arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2502.00527cs.LGcs.CL
收藏

PolarQuant: 利用极坐标变换实现高效键缓存量化和解码加速

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

Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学北京校区人工智能学院);ShanghaiTech University(上海科技大学);Meituan(美团)

Songhao Wu, Ang Lv, Xiao Feng, Yufei Zhang, Xun Zhang, Guojun Yin, Wei Lin, Rui Yan

AI总结:

提出PolarQuant方法,通过将键向量分组为二维子向量并编码为量化半径和极角,解决键缓存量化中的异常值问题,同时通过查表加速解码,保持全精度模型性能。

摘要:

大型语言模型中的KV缓存是内存使用的主要因素,限制了其更广泛的适用性。将缓存量化到更低的位宽是减少计算成本的有效方法;然而,先前的方法由于异常值的存在,难以量化键向量,导致过高的开销。我们提出了一种名为PolarQuant的新型量化方法,有效解决了异常值挑战。我们观察到,异常值通常只出现在两个维度中的一个,当应用旋转位置嵌入时,这两个维度会一起旋转特定角度。当表示为二维向量时,这些维度展现出结构良好的模式,半径和角度在极坐标中平滑分布。这减轻了异常值对逐通道量化的挑战,使其非常适合量化。因此,PolarQuant将键向量分为二维子向量组,将其编码为相应的量化半径和极角,而不是直接量化原始键向量。PolarQuant在KV缓存量化中实现了卓越的效率,并通过将查询-键内积转化为查表操作来加速解码过程,同时保持全精度模型的下游性能。

英文摘要:

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.

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

↑