KVSharer:通过层间相异 KV 缓存共享实现高效推理
KVSharer: Efficient Inference via Layer-Wise Dissimilar KV Cache Sharing
AI总结:
针对 LLM 推理中 KV 缓存占用过高的问题,提出即插即用的 KVSharer,通过层间共享相异 KV 缓存实现压缩,减少 30% 计算并获得至少 1.3 倍加速,还可兼容层内压缩方法。
摘要:
大型语言模型(LLM)的发展显著扩大了模型规模,导致推理期间需要大量 GPU 内存。KV(key-value,键值)缓存中注意力图的键和值存储占此类内存消耗的 80% 以上。如今,大多数现有 KV 缓存压缩方法都聚焦于单个 Transformer 层内的层内压缩,而很少有工作考虑层间压缩。本文提出一种名为 KVSharer 的即插即用方法,该方法在不同层之间共享 KV 缓存以实现层间压缩。我们并未直观地基于更高相似性进行共享,而是发现了一个反直觉现象:共享相异的 KV 缓存能更好地保持模型性能。实验表明,KVSharer 可将 KV 缓存计算减少 30%,从而在不显著影响模型性能的情况下降低内存消耗,并且还能实现至少 1.3 倍的生成加速。此外,我们验证了 KVSharer 与现有层内 KV 缓存压缩方法兼容,将二者结合可进一步节省内存。
英文摘要:
The development of large language models (LLMs) has significantly expanded model sizes, resulting in substantial GPU memory requirements during inference. The key and value storage of the attention map in the KV (key-value) cache accounts for more than 80\% of this memory consumption. Nowadays, most existing KV cache compression methods focus on intra-layer compression within a single Transformer layer but few works consider layer-wise compression. In this paper, we propose a plug-and-play method called \textit{KVSharer}, which shares the KV cache between layers to achieve layer-wise compression. Rather than intuitively sharing based on higher similarity, we discover a counterintuitive phenomenon: sharing dissimilar KV caches better preserves the model performance. Experiments show that \textit{KVSharer} can reduce KV cache computation by 30\%, thereby lowering memory consumption without significantly impacting model performance and it can also achieve at least 1.3 times generation acceleration. Additionally, we verify that \textit{KVSharer} is compatible with existing intra-layer KV cache compression methods, and combining both can further save memory.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。