KQ-SVD: Compressing the KV Cache with Provable Guarantees on Attention Fidelity

📄 arXiv: 2512.05916v1 📥 PDF

作者: Damien Lesens, Beheshteh T. Rakhshan, Guillaume Rabusseau

分类: cs.LG

发布日期: 2025-12-05


💡 一句话要点

KQ-SVD:通过优化Attention矩阵低秩分解压缩KV缓存,提升LLM推理效率

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: KV缓存压缩 Attention机制 低秩分解 奇异值分解 大型语言模型 模型推理加速

📋 核心要点

  1. 现有KV缓存压缩方法忽略了Attention机制的核心:Query和Key的内积,导致压缩性能受限。
  2. KQ-SVD直接对Attention矩阵进行最优低秩分解,通过闭式解高效地保留Attention输出。
  3. 实验表明,KQ-SVD在压缩KV缓存时,能以更高的保真度保留Attention输出,优于现有方法。

📝 摘要(中文)

Key-Value (KV) 缓存对于基于Transformer的大型语言模型(LLM)的效率至关重要,它存储先前计算的向量以加速推理。然而,随着序列长度和批大小的增长,缓存成为主要的内存瓶颈。先前的压缩方法通常单独对Key进行低秩分解,或者尝试联合嵌入Query和Key,但这些方法都忽略了Attention从根本上取决于它们的内积。本文证明了这些策略在近似Attention矩阵时是次优的。我们提出了一种简单且计算高效的方法KQ-SVD,它通过闭式解直接执行Attention矩阵的最优低秩分解。通过针对真正的冗余来源,KQ-SVD在压缩下以更高的保真度保留Attention输出。在LLaMA和Mistral模型上的大量评估表明,我们的方法始终提供卓越的投影质量。

🔬 方法详解

问题定义:大型语言模型(LLM)的KV缓存随着序列长度和批大小的增加,成为内存瓶颈。现有的KV缓存压缩方法,如单独对Key进行低秩分解或联合嵌入Query和Key,未能直接优化Attention矩阵的近似,导致压缩性能受限。这些方法忽略了Attention机制的核心,即Attention权重是由Query和Key的内积决定的。

核心思路:KQ-SVD的核心思路是直接对Attention矩阵进行低秩分解,从而最大限度地保留Attention输出的保真度。通过优化Attention矩阵的低秩近似,可以更有效地压缩KV缓存,同时减少对模型性能的影响。这种方法针对的是Attention机制的本质,即Query和Key之间的交互。

技术框架:KQ-SVD的技术框架主要包括以下步骤:1) 计算Attention矩阵;2) 对Attention矩阵进行奇异值分解(SVD);3) 选择前k个奇异值和对应的奇异向量,构建低秩近似的Attention矩阵;4) 使用低秩近似的Attention矩阵进行后续的Attention计算。该框架的关键在于直接对Attention矩阵进行操作,而不是对Key或Query进行单独处理。

关键创新:KQ-SVD的最重要的技术创新点在于直接对Attention矩阵进行最优低秩分解。与现有方法相比,KQ-SVD能够更准确地捕捉Attention机制中的关键信息,从而在压缩KV缓存的同时,更好地保留模型的性能。此外,KQ-SVD提供了一个闭式解,使得低秩分解的计算更加高效。

关键设计:KQ-SVD的关键设计包括:1) 使用奇异值分解(SVD)来计算Attention矩阵的低秩近似;2) 通过选择合适的奇异值数量k来控制压缩率和性能之间的平衡;3) 利用闭式解来高效地计算低秩分解。此外,KQ-SVD可以与现有的Transformer架构无缝集成,无需对模型进行大量的修改。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

实验结果表明,KQ-SVD在LLaMA和Mistral模型上均表现出卓越的性能。相比于现有的KV缓存压缩方法,KQ-SVD能够在相同的压缩率下,以更高的保真度保留Attention输出,从而获得更好的模型性能。具体而言,KQ-SVD在多个benchmark上取得了显著的提升,证明了其在压缩KV缓存方面的有效性。

🎯 应用场景

KQ-SVD可应用于各种需要高效LLM推理的场景,例如移动设备上的本地部署、资源受限环境下的模型部署、以及需要处理长序列的任务。通过降低KV缓存的内存占用,KQ-SVD能够显著提升LLM的推理速度和可扩展性,加速LLM在实际应用中的落地。

📄 摘要(原文)

The Key-Value (KV) cache is central to the efficiency of transformer-based large language models (LLMs), storing previously computed vectors to accelerate inference. Yet, as sequence length and batch size grow, the cache becomes a major memory bottleneck. Prior compression methods typically apply low-rank decomposition to keys alone or attempt to jointly embed queries and keys, but both approaches neglect that attention fundamentally depends on their inner products. In this work, we prove that such strategies are suboptimal for approximating the attention matrix. We introduce KQ-SVD, a simple and computationally efficient method that directly performs an optimal low-rank decomposition of the attention matrix via a closed-form solution. By targeting the true source of redundancy, KQ-SVD preserves attention outputs with higher fidelity under compression. Extensive evaluations on LLaMA and Mistral models demonstrate that our approach consistently delivers superior projection quality.