XAttention:基于反对角线评分的块稀疏注意力
XAttention: Block Sparse Attention with Antidiagonal Scoring
AI总结:
针对长上下文Transformer注意力计算成本高的问题,提出基于反对角线评分的块稀疏注意力框架XAttention,可在保持准确率的同时实现最高13.5倍的注意力计算加速。
摘要:
长上下文Transformer模型(LCTMs)对实际应用至关重要,但由于注意力的二次复杂度,其计算成本很高。块稀疏注意力通过将计算集中在关键区域来缓解这一问题,但现有方法由于块重要性测量成本高昂,难以在准确性和效率之间取得平衡。本文提出了XAttention,这是一个即插即用框架,使用稀疏注意力大幅加速Transformer模型的长上下文推理。XAttention的核心创新在于发现注意力矩阵中的反对角线(即从左下到右上)数值之和可作为块重要性的有效代理指标。这使得能够精准识别并剪枝非必要块,从而实现高稀疏度并大幅加速推理。在多项高难度长上下文基准的综合评估中——包括语言领域的RULER和LongBench、视频理解领域的VideoMME以及视频生成领域的VBench——XAttention取得了与全注意力相当的准确率,同时带来了显著的计算增益。实验显示其注意力计算加速比最高可达13.5倍。这些结果凸显了XAttention释放块稀疏注意力实际潜力的能力,为LCTMs在实际应用中的可扩展高效部署铺平了道路。代码可在https://github.com/mit-han-lab/x-attention获取。
英文摘要:
Long-Context Transformer Models (LCTMs) are vital for real-world applications but suffer high computational costs due to attention's quadratic complexity. Block-sparse attention mitigates this by focusing computation on critical regions, yet existing methods struggle with balancing accuracy and efficiency due to costly block importance measurements. In this paper, we introduce XAttention, a plug-and-play framework that dramatically accelerates long-context inference in Transformers models using sparse attention. XAttention's key innovation is the insight that the sum of antidiagonal values (i.e., from the lower-left to upper-right) in the attention matrix provides a powerful proxy for block importance. This allows for precise identification and pruning of non-essential blocks, resulting in high sparsity and dramatically accelerated inference. Across comprehensive evaluations on demanding long-context benchmarks-including RULER and LongBench for language, VideoMME for video understanding, and VBench for video generation. XAttention achieves accuracy comparable to full attention while delivering substantial computational gains. We demonstrate up to 13.5x acceleration in attention computation. These results underscore XAttention's ability to unlock the practical potential of block sparse attention, paving the way for scalable and efficient deployment of LCTMs in real-world applications. Code is available at https://github.com/mit-han-lab/x-attention.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。