Grouped Value Attention: Efficient KV Caching via On-Demand Key Reconstruction

LLM PTSAD MQIA ML TAVR
KV 缓存是 Transformer 解码过程中的主要瓶颈:其内存占用量及缓存读取流量均随序列长度增长而线性增加。分组查询注意力(GQA)通过共享键-值头来降低该开销,但仍需在每一步同时存储键(key)和值(value)。本文提出分组值注意力(GVA),其仅存储分组后的值,并通过一个可学习的线性映射函数重构内容键(content key)。在推理阶段,该映射可被吸收进查询向量中,从而在目标解码路径中完全避免显式物化(materialize)内容键。此外,我们引入一个轻量级、共享且解耦的 RoPE 通道,专门用于保留位置信息:该通道将位置信息编码为独立缓存的位置键(positional key)。在本文所研究的各项配置下,该表示方法相较同等规模的 GQA,可将持久化缓存中的标量数量减少约 45%–47%。在 3.5 亿参数规模、使用 300 亿 token 的 FineWeb-Edu 数据集进行训练的设定下,采用 16 维位置编码的 GVA 变体在五项任务上的平均准确率达到 44.18,略低于 GQA 的 44.36,但显著优于多头线性注意力(MLA)的 43.88。这些结果表明,GVA 在显著压缩缓存表示的同时,仍能保持与 GQA 相当的基准测试精度。为进一步将这一紧凑表示转化为更快的自回归推理速度,我们已开发了专用的解码内核(custom decoding kernels),目前正对其端到端推理性能开展系统评估;相关开源实现计划近期发布。
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.
许愿