CORM:面向大语言模型推理的基于近期消息的缓存优化
CORM: Cache Optimization with Recent Message for Large Language Model Inference
AI总结:
针对大语言模型推理中KV缓存显存占用随序列长度线性增长的瓶颈,提出无需微调的KV缓存淘汰策略CORM,可将显存占用最高降低70%且性能损失极小,还可与GQA兼容进一步提升压缩率。
摘要:
大语言模型(LLM)尽管在各类任务中表现出色,但需要大量GPU显存并消耗可观的计算资源。除了模型权重占用的显存外,KV缓存的显存占用随序列长度线性增长,已成为推理的主要瓶颈。本文提出了一种创新的KV缓存优化方法,可大幅降低其显存占用。经过深入研究,我们发现大多数Transformer模型中存在两个特性:(i)相邻词元的查询向量之间存在显著相似性;(ii)当前查询的注意力计算可仅依赖于少量前置查询的注意力信息。基于这些观察,我们提出CORM——一种KV缓存淘汰策略,无需模型微调即可动态保留推理所需的关键键值对。我们的验证结果表明,在LongBench的六项任务上,CORM可将KV缓存的推理显存占用降低最高70%,且性能下降可忽略不计。此外,我们还证明CORM可与GQA兼容,以实现更高的压缩率。
英文摘要:
Large Language Models (LLMs), despite their remarkable performance across a wide range of tasks, necessitate substantial GPU memory and consume significant computational resources. Beyond the memory taken up by model weights, the memory used by the KV cache rises linearly with sequence length, becoming a primary bottleneck for inference. In this paper, we introduce an innovative method for optimizing the KV cache, which considerably minimizes its memory footprint. Upon thorough investigation, we discover that in most Transformer models, (i) there is a striking similarity between adjacent tokens' query vectors, and (ii) the attention calculation of the current query can rely exclusively on the attention information of a small fraction of preceding queries. Based on these observations, we present CORM, a KV cache eviction policy that dynamically retains essential key-value pairs for inference without the need for model fine-tuning. Our validation shows that CORM reduces the inference memory usage of KV cache by up to 70\% with negligible performance degradation across six tasks in LongBench. Furthermore, we demonstrate that CORM is compatible with GQA for further compression rate.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。