分组值注意力:通过按需键重建实现高效KV缓存
研究论文 · 2026/09/15
KV缓存是Transformer解码的主要瓶颈:其内存占用和缓存读取流量随序列长度增长。分组查询注意力(GQA)通过共享键值头降低此成本,但仍在每一步存储键和值。我们提出分组值注意力(GVA),它存储分组值并用学习到的线性映射重建内容键。在推理时,该映射可被吸收到查询中,从而在预期的解码路径中无需物化内容键。一个小的共享解耦RoPE通道通过单独缓存的位置键保留位置信息。在所研究的配置中,这种表示相对于匹配的GQA将持久缓存标量减少约45-47%。在3.5亿参数规模、300亿FineWeb-Edu token下,16维位置变体在五项任务上达到44.18平均准确率,而GQA为44.36,MLA为43.88。这些结果表明,在更紧凑的缓存表示下,基准准确率接近GQA。为了将这种紧凑表示转化为更快的自回归推理,我们开发了自定义解码内核,目前正在评估其端到端推理性能,并计划很快开源发布。
该研究提出了一种更紧凑的KV缓存表示,在保持接近GQA准确率的同时显著减少缓存大小,有望缓解长序列解码的内存瓶颈,并计划开源解码内核,对高效Transformer推理有实用价值。
The KV cache is a primary bottleneck for Transformer decoding: its memory footprint and cache-read traffic grow with sequence length. Grouped-query attention (GQA) reduces this cost by sharing key-value heads, but still stores both a key and a value at every step. We introduce Grouped Value Attention (GVA), which stores grouped values and reconstructs content keys with a learned linear map. At inference, the map can be absorbed into the query, eliminating the need to materialize content keys in the intended decode path. A small shared decoupled RoPE channel retains positional information through a separately cached positional key. For the configurations studied, this representation reduces persistent cache scalars by approximately 45-47% relative to matched GQA. At the 350M-parameter scale with 30B FineWeb-Edu tokens, the 16-dimensional positional variant reaches 44.18 average accuracy across five tasks, compared with 44.36 for GQA and 43.88 for MLA. These results demonstrate near-GQA benchmark accuracy with a more compact cache representation. To translate this compact representation into faster autoregressive inference, we have developed custom decoding kernels and are currently evaluating their end-to-end inference performance with an open-source release planned soon.