GTA通过共享注意力图和压缩值缓存,大幅降低大模型推理开销。
GTA: Grouped-head latenT Attention
- 共享多头注意力图,减少键值缓存存储
- 值缓存压缩至隐空间,内存减少70%
- 推理速度提升2倍,适合资源受限部署
注意力机制驱动大语言模型成功,但其计算与内存开销巨大,尤其在长文本场景下,键值缓存与注意力计算快速膨胀,制约了在资源受限设备上的部署。我们发现注意力机制存在显著冗余:跨头注意力图高度相似,键值缓存可大幅压缩。为此提出新注意力机制GTA,包含两部分:(1) 共享注意力图机制,复用多头间注意力分数,减少键缓存大小;(2) 带学习投影的非线性值解码器,将值缓存压缩至隐空间,进一步降低内存需求。GTA相比分组查询注意力减少62.5%的注意力计算量,键值缓存缩小70%,且无额外多头隐式注意力开销,从而实现端到端推理速度提升2倍。预填充阶段得益于计算成本下降,解码阶段受益于更小缓存占用。
原文摘要 · Abstract (English)
Attention mechanisms underpin the success of large language models (LLMs), yet their substantial computational and memory overhead poses challenges for optimizing efficiency and performance. A critical bottleneck arises as KV cache and attention computations scale rapidly with text length, challenging deployment on hardware with limited computational and memory resources. We observe that attention mechanisms exhibit substantial redundancy, since the KV cache can be significantly compressed and attention maps across heads display high similarity, revealing that much of the computation and storage is unnecessary. Leveraging these insights, we propose \textbf{G}rouped-Head Laten\textbf{T} \textbf{A}ttention (GTA), a novel attention mechanism that reduces memory usage and computational complexity while maintaining performance. GTA comprises two components: (1) a shared attention map mechanism that reuses attention scores across multiple heads, decreasing the key cache size; and (2) a nonlinear value decoder with learned projections that compresses the value cache into a latent space, further cutting memory needs. GTA cuts attention computation FLOPs by up to \emph{62.5\%} versus Grouped-Query Attention and shrink the KV cache by up to \emph{70\%}, all while avoiding the extra overhead of Multi-Head Latent Attention to improve LLM deployment efficiency. Consequently, GTA models achieve a \emph{2x} increase in end-to-end inference speed, with prefill benefiting from reduced computational cost and decoding benefiting from the smaller cache footprint.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。