通过位置持续稀疏注意力,加速大模型生成且不损失质量
TidalDecode: Fast and Accurate LLM Decoding with Position Persistent Sparse Attention

- 利用层间令牌选择的空间一致性,减少冗余计算
- 在多个模型上实现最高2.1倍的解码速度提升
- 适合需要高效推理的长文本生成场景
大语言模型(LLMs)在自然语言处理任务中取得显著进展,长上下文模型因其能处理更长输入而备受关注。然而,Transformer架构所需的键值(KV)缓存规模扩大,加剧了内存压力,尤其在解码阶段形成显著瓶颈。现有稀疏注意力机制存在两大局限:一是难以可靠识别最具相关性的令牌,二是忽视连续层间令牌选择的空间一致性,导致性能下降和选令牌开销过大。本文提出TidalDecode,一种基于位置持续稀疏注意力的简单高效算法与系统,用于快速准确的LLM解码。TidalDecode利用已有稀疏注意力方法选出的令牌空间一致性,仅在少数层执行全注意力以确定最高注意力得分的令牌,其余层则使用预选令牌进行稀疏注意力。该设计在不牺牲生成质量的前提下,大幅降低稀疏注意力的选令牌开销。在多种LLM和任务上的评估表明,TidalDecode在生成性能上接近全注意力方法,同时将解码延迟降低最多达2.1倍。
原文摘要 · Abstract (English)
Large language models (LLMs) have driven significant advancements across diverse NLP tasks, with long-context models gaining prominence for handling extended inputs. However, the expanding key-value (KV) cache size required by Transformer architectures intensifies the memory constraints, particularly during the decoding phase, creating a significant bottleneck. Existing sparse attention mechanisms designed to address this bottleneck have two limitations: (1) they often fail to reliably identify the most relevant tokens for attention, and (2) they overlook the spatial coherence of token selection across consecutive Transformer layers, which can lead to performance degradation and substantial overhead in token selection. This paper introduces TidalDecode, a simple yet effective algorithm and system for fast and accurate LLM decoding through position persistent sparse attention. TidalDecode leverages the spatial coherence of tokens selected by existing sparse attention methods and introduces a few token selection layers that perform full attention to identify the tokens with the highest attention scores, while all other layers perform sparse attention with the pre-selected tokens. This design enables TidalDecode to substantially reduce the overhead of token selection for sparse attention without sacrificing the quality of the generated results. Evaluation on a diverse set of LLMs and tasks shows that TidalDecode closely matches the generative performance of full attention methods while reducing the LLM decoding latency by up to 2.1x.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。