arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.21118cs.AIcs.LG
收藏

Palu:基于低秩投影的KV-Cache压缩

Palu: Compressing KV-Cache with Low-Rank Projection

National Yang Ming Chiao Tung University(国立阳明交通大学);University of Washington(华盛顿大学);Cornell University(康奈尔大学)

Chi-Chih Chang, Wei-Cheng Lin, Chien-Yu Lin, Chong-Yan Chen, Yu-Fang Hu, Pei-Shuo Wang, Ning-Chi Huang, Luis Ceze, Mohamed S. Abdelfattah, Kai-Chiang Wu

AI总结:

针对现有KV-Cache压缩方法无法利用KV张量隐藏维度冗余的问题,本文提出Palu框架,通过低秩投影实现隐藏维度压缩,结合多项优化技术,在保证准确率的同时显著降低内存占用并提升推理速度。

摘要:

训练后KV-Cache压缩方法通常要么选取有效令牌的子集,要么将数据量化为更低的数值位宽。然而,这些方法无法利用KV张量隐藏维度中的冗余。本文提出了一种名为Palu的隐藏维度压缩方法,这是一种KV-Cache压缩框架,利用低秩投影来减少大语言模型(LLM)推理时的内存占用。Palu将线性层分解为低秩矩阵,缓存压缩后的中间状态,并实时重建完整的键和值。为了提升准确率、压缩率和效率,Palu还包含:(1)一种中粒度低秩分解方案;(2)一种高效的秩搜索算法;(3)低秩感知的量化兼容性增强;(4)带算子融合的优化GPU内核。针对主流LLM的大量实验表明,Palu将KV-Cache压缩了50%,同时保持了较高的准确率,并且在基于RoPE的注意力模块上实现了最高1.89倍的加速。当与量化结合时,Palu固有的量化友好设计带来的额外准确率下降很小甚至可以忽略不计,同时比仅使用量化的方法节省了更多内存,并且在基于RoPE的注意力上实现了最高2.91倍的加速。此外,与仅使用量化的方法相比,它保持了相当甚至更优的准确率(困惑度最高低1.19)。这些结果证明了Palu在有效解决由KV-Cache带来的LLM推理效率和内存挑战方面的卓越能力。我们的代码公开于:https://github.com/shadowpa0327/Palu

英文摘要:

Post-training KV-Cache compression methods typically either sample a subset of effectual tokens or quantize the data into lower numerical bit width. However, these methods cannot exploit redundancy in the hidden dimension of the KV tensors. This paper presents a hidden dimension compression approach called Palu, a KV-Cache compression framework that utilizes low-rank projection to reduce inference-time LLM memory usage. Palu decomposes the linear layers into low-rank matrices, caches compressed intermediate states, and reconstructs the full keys and values on the fly. To improve accuracy, compression rate, and efficiency, Palu further encompasses (1) a medium-grained low-rank decomposition scheme, (2) an efficient rank search algorithm, (3) low-rank-aware quantization compatibility enhancements, and (4) optimized GPU kernels with operators fusion. Extensive experiments with popular LLMs show that Palu compresses KV-Cache by 50% while maintaining strong accuracy and delivering up to 1.89x on the RoPE-based attention module. When combined with quantization, Palu's inherent quantization-friendly design yields small to negligible extra accuracy degradation while saving additional memory than quantization-only methods and achieving up to 2.91x speedup for the RoPE-based attention. Moreover, it maintains comparable or even better accuracy (up to 1.19 lower perplexity) compared to quantization-only methods. These results demonstrate Palu's superior capability to effectively address the efficiency and memory challenges of LLM inference posed by KV-Cache. Our code is publicly available at: https://github.com/shadowpa0327/Palu

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

↑