arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.07092cs.LGcs.AIcs.CL
收藏

具有双重稀疏性的训练后稀疏注意力

Post-Training Sparse Attention with Double Sparsity

Stanford(斯坦福大学);UC Berkeley(加州大学伯克利分校);Shanghai Jiao Tong University(上海交通大学)

Shuo Yang, Ying Sheng, Joseph E. Gonzalez, Ion Stoica, Lianmin Zheng

AI总结:

针对大语言模型推理中KV缓存访问瓶颈,提出结合token与通道稀疏性的训练后稀疏注意力技术Double Sparsity,可高效识别重要token,结合卸载技术大幅提升推理速度并降低内存占用。

摘要:

大语言模型的推理过程速度慢且内存占用高,其中最关键的瓶颈之一是键值(KV)缓存访问量过大。本文提出了“Double Sparsity(双重稀疏性)”,这是一种新颖的训练后稀疏注意力技术,旨在通过减少KV缓存访问来缓解这一瓶颈。双重稀疏性结合了token稀疏性和通道稀疏性:token稀疏性仅聚焦于利用重要token来自注意力计算,通道稀疏性则是一种使用重要特征通道来识别重要token的方法。我们的核心洞见是,通道稀疏性的模式相对静态,因此我们可以利用离线校准使其在运行时高效执行,从而实现对重要token准确且高效的识别。此外,该方法可以与卸载技术结合,实现显著的内存使用量降低。实验结果表明,在包括wiki-2困惑度、键值检索以及长上下文基准在内的各类任务中,针对Llama-2-7B、Llama-2-70B和Mixtral-8x7B等模型,Double Sparsity能够实现1/16的token和通道稀疏性,且对准确率的影响极小。它在GPU上可实现最高14.1倍的注意力运算加速,以及1.9倍的端到端推理性能提升。结合卸载技术时,在序列长度为256K的情况下,其解码速度相比当前最优方案提升了16.3倍。我们的代码已公开在https://github.com/andy-yang-1/DoubleSparse。

英文摘要:

The inference process for large language models is slow and memory-intensive, with one of the most critical bottlenecks being excessive Key-Value (KV) cache accesses. This paper introduces "Double Sparsity," a novel post-training sparse attention technique designed to alleviate this bottleneck by reducing KV cache access. Double Sparsity combines token sparsity, which focuses on utilizing only the important tokens for computing self-attention, with channel sparsity, an approach that uses important feature channels for identifying important tokens. Our key insight is that the pattern of channel sparsity is relatively static, allowing us to use offline calibration to make it efficient at runtime, thereby enabling accurate and efficient identification of important tokens. Moreover, this method can be combined with offloading to achieve significant memory usage reduction. Experimental results demonstrate that Double Sparsity can achieve $\frac{1}{16}$ token and channel sparsity with minimal impact on accuracy across various tasks, including wiki-2 perplexity, key-value retrieval, and long context benchmarks with models including Llama-2-7B, Llama-2-70B, and Mixtral-8x7B. It brings up to a 14.1$\times$ acceleration in attention operations and a 1.9$\times$ improvement in end-to-end inference on GPUs. With offloading, it achieves a decoding speed acceleration of 16.3$\times$ compared to state-of-the-art solutions at a sequence length of 256K. Our code is publicly available at https://github.com/andy-yang-1/DoubleSparse.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑