动态分组与自适应降阶,高效压缩大模型推理时的键值缓存。
DynaCalKV: Key-Value Cache Compression via Head Grouping and Adaptive Rank Allocation

- 按注意力头相似性动态分组,自适应分配压缩秩预算。
- 在三款指令微调大模型上,键缓存参数减少且精度保持竞争力。
- 特别适合多头注意力模型,长上下文下对分组查询注意力需谨慎使用。
大型语言模型(LLMs)在推理阶段需处理长上下文窗口,键值(KV)缓存虽能缓解此问题,但随着上下文增长仍成为主要瓶颈。低秩压缩被视作有效减少KV缓存内存的方法,但现有方法大多未区分键(Key)和值(Value)缓存的不同作用,且通常采用固定注意力头分组,未能充分挖掘头间结构相似性。本文提出一种改进的低秩KV缓存压缩框架:对键缓存,基于中心核对齐(CKA)相似性动态分组,并在参数预算下自适应分配秩;对值缓存,沿用ReCalKV方法,通过离线校准优化低秩分解以提升重建质量。在三个指令微调的大模型上的实验表明,该方法在保持竞争性精度的同时显著减少键缓存参数量。进一步观察发现,该策略对多头注意力(MHA)模型尤为有效,而应用于分组查询注意力(GQA)模型时应更保守,尤其是在长上下文场景中。
原文摘要 · Abstract (English)
As the inference phase of Large Language Models (LLMs) requires handling long context windows, the Key-Value (KV) cache initially appears to address this challenge but eventually becomes a significant bottleneck as the context window continues to grow. Low-rank compression has recently been studied as an effective approach to reduce KV cache memory while maintaining model performance. However, only a few existing methods treat the Key and Value caches differently, despite their distinct roles. Moreover, these methods typically employ fixed attention-head grouping, which may not fully exploit the structural similarity among attention heads. In this paper, we propose an improved low-rank KV cache compression framework. For the Key cache, we dynamically group attention heads based on Centered Kernel Alignment (CKA) similarity and allocate the rank budget adaptively under a parameter budget. For the Value cache, we adopt the same approach as ReCalKV, refining the low-rank decomposition through offline calibration to improve reconstruction quality. Experimental results on three instruction-tuned LLMs show that our method reduces the number of Key cache parameters while maintaining competitive accuracy. We further observe that the proposed strategy is particularly effective for Multi-Head Attention (MHA) models, whereas it should be applied more conservatively to Grouped-Query Attention (GQA) models, especially in long-context settings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。