arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2502.02770cs.LGcs.CL
收藏

Twilight:基于分层 Top-$p$ 剪枝的自适应注意力稀疏化

Twilight: Adaptive Attention Sparsity with Hierarchical Top-$p$ Pruning

Tsinghua University(清华大学);Massachusetts Institute of Technology(麻省理工学院);University of California, Berkeley(加州大学伯克利分校)

Chaofan Lin, Jiaming Tang, Shuo Yang, Hanshuo Wang, Tian Tang, Boyu Tian, Ion Stoica, Song Han, Mingyu Gao

AI总结:

针对长上下文LLM加速中固定稀疏预算无法适应动态场景的问题,提出Twilight框架,利用分层Top-$p$剪枝实现自适应注意力稀疏化,在不损失精度的前提下最多剪枝98%冗余token,显著提升推理速度。

摘要:

利用注意力稀疏性来加速长上下文大型语言模型(LLMs)一直是一个热门的研究课题。然而,当前的算法(如稀疏注意力或键值(KV)缓存压缩)倾向于使用固定预算,这在部署期间提出了一个重大挑战,因为它未能考虑现实场景的动态特性,在这些场景中,准确性和效率之间的最佳平衡可能会有很大差异。在本文中,我们发现将 top-$p$ 采样(核采样)借用到稀疏注意力中可以出人意料地实现自适应预算分配。基于此,我们提出了 Twilight,这是一个在不牺牲其准确性的前提下,将自适应稀疏性引入任何现有稀疏注意力算法的框架。实证结果表明,Twilight 能够自适应地剪枝最多 98% 的冗余 token,从而在长上下文 LLM 解码中,使自注意力操作实现 $15.4\ imes$ 的加速,并使端到端的每 token 延迟实现 $3.9\ imes$ 的加速。

英文摘要:

Leveraging attention sparsity to accelerate long-context large language models (LLMs) has been a hot research topic. However, current algorithms such as sparse attention or key-value (KV) cache compression tend to use a fixed budget, which presents a significant challenge during deployment because it fails to account for the dynamic nature of real-world scenarios, where the optimal balance between accuracy and efficiency can vary greatly. In this paper, we find that borrowing top-$p$ sampling (nucleus sampling) to sparse attention can surprisingly achieve adaptive budgeting. Based on this, we propose Twilight, a framework to bring adaptive sparsity to any existing sparse attention algorithm without sacrificing their accuracy. Empirical results show that Twilight can adaptively prune at most 98% of redundant tokens, leading to $15.4\times$ acceleration in self-attention operations and $3.9\times$ acceleration in end-to-end per token latency in long context LLM decoding.

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

↑