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

用于大型语言模型高效推理的层压缩KV缓存

Layer-Condensed KV Cache for Efficient Inference of Large Language Models

School of Information Science and Technology, ShanghaiTech University(上海科技大学信息科学与技术学院);Shanghai Engineering Research Center of Intelligent Vision and Imaging(上海智能视觉与成像工程技术研究中心)

Haoyi Wu, Kewei Tu

AI总结:

提出层压缩KV缓存方法,仅计算和缓存少量层的KV,显著节省内存并提升大型语言模型推理吞吐量达26倍,同时保持竞争力且与现有技术正交。

摘要:

巨大的内存消耗一直是在实际应用中部署高吞吐量大型语言模型的主要瓶颈。除了大量的参数外,transformer架构中注意力机制的键值(KV)缓存也会消耗大量内存,尤其是当深层语言模型的层数较多时。在本文中,我们提出了一种新方法,该方法仅计算和缓存少量层的KV,从而显著节省内存消耗并提高推理吞吐量。我们在大型语言模型上的实验表明,与标准transformer相比,我们的方法实现了高达26倍的吞吐量提升,并在语言建模和下游任务中取得了具有竞争力的性能。此外,我们的方法与现有的transformer内存节省技术正交,因此可以轻松地将它们与我们的模型集成,进一步提高推理效率。我们的代码可在https://github.com/whyNLP/LCKV获取。

英文摘要:

Huge memory consumption has been a major bottleneck for deploying high-throughput large language models in real-world applications. In addition to the large number of parameters, the key-value (KV) cache for the attention mechanism in the transformer architecture consumes a significant amount of memory, especially when the number of layers is large for deep language models. In this paper, we propose a novel method that only computes and caches the KVs of a small number of layers, thus significantly saving memory consumption and improving inference throughput. Our experiments on large language models show that our method achieves up to 26$\times$ higher throughput than standard transformers and competitive performance in language modeling and downstream tasks. In addition, our method is orthogonal to existing transformer memory-saving techniques, so it is straightforward to integrate them with our model, achieving further improvement in inference efficiency. Our code is available at https://github.com/whyNLP/LCKV.

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

↑