Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

上海宝山炮台湿地公园的蓝天白云上海宝山炮台湿地公园的蓝天白云
0

“`markdown

清华大学推出 SpargeAttn:无需训练,加速各类大模型推理速度

北京 – 2025年3月27日 – 在人工智能领域,长序列处理能力已成为各类大语言模型和视频模型的关键需求。然而,随着序列长度的增加,Attention机制的计算复杂度呈平方级增长,成为制约模型性能的主要瓶颈。清华大学陈键飞团队继SageAttention系列工作之后,再次突破,推出了无需训练即可直接使用的稀疏Attention(SpargeAttn),为加速各类模型的推理过程提供了新的解决方案。

背景:Attention机制的挑战与机遇

Attention机制作为深度学习模型中的核心组件,在处理长序列数据时发挥着关键作用。然而,其O(N^2)的时间复杂度使得计算成本随着序列长度的增加而急剧上升。尽管如此,Attention矩阵(P矩阵)的稀疏性为加速计算提供了可能。

此前,清华大学陈键飞团队提出的SageAttention系列工作,通过即插即用量化技术,实现了3倍于FlashAttention的加速效果,并在各类大模型上保持了端到端的精度,受到了业界和社区的广泛关注。

SpargeAttn:无需训练的稀疏Attention

为了进一步挖掘Attention机制的潜力,陈键飞团队推出了SpargeAttn,一种无需训练即可直接使用的稀疏Attention方法。该方法能够在语言、视频、图像生成等大模型上实现4-7倍于FlashAttention的推理加速,同时保持端到端的精度表现。

论文标题: SpargeAttn: Accurate Sparse Attention Accelerating Any Model Inference

论文链接: https://arxiv.org/abs/2502.18137

开源代码: https://github.com/thu-ml/SpargeAttn

SpargeAttn速度展示

上图展示了SpargeAttn的速度优势。在RTX4090上,SpargeAttn在60%稀疏度的情况下可以达到900TOPS的速度,甚至超过了A100显卡速度的4.5倍(A100上FlashAttention仅为200TOPS)。

SpargeAttn的核心技术

SpargeAttn旨在开发一种通用的、无需训练的稀疏Attention机制,以实现对各种模型(语言/视频/图像)的加速,同时保证精度无损,并对中等长度的上下文(如4-32K)也有效。

面临的挑战:

  1. 通用性: 不同模型甚至同一模型的不同层中,Attention的稀疏形状各不相同,体现出很强的动态性。
  2. 可用性: 难以同时实现对各种Attention输入的准确且高效的稀疏化。

解决方案:

  1. 通用的稀疏预测算法: 该算法选择性地对Q, K矩阵进行压缩并预测P矩阵,然后使用TopCdf操作省略P中稀疏部分对应的QK^T与PV的矩阵乘法。
  2. GPU Warp级别上的稀疏Online Softmax算法: 该算法利用Online Softmax中全局最大值与局部最大值之间的差异,进一步省略了一些PV的矩阵乘法计算。
  3. 希尔伯特重排(可选): 针对视频和图像模型,充分利用图像以及视频中的Token局部相似性质,对Attention前的Token进行重新排列,进一步提高稀疏度。
  4. 与SageAttention融合: 将稀疏方法与基于量化的SageAttention融合,进一步加速Attention。

SpargeAttn算法流程图

上图展示了SpargeAttn的算法流程。

实验结果与展望

实验结果表明,SpargeAttn在视频、图像、文本生成等大模型上均可以实现无需训练的加速效果,同时保证了各任务上的端到端精度。

| 模型类型 | 稀疏度 | Attention速度 | 端到端精度 |
| ———- | —- | ——– | ——– |
| 语言模型 | X% | Y倍加速 | Z% |
| 视频模型 | X% | Y倍加速 | Z% |
| 图像生成模型 | X% | Y倍加速 | Z% |

注:表格数据占位,请根据论文数据填充。此论文中的所有实验都是基于SageAttention实现,目前Github仓库中已有基于SageAttention2的实现,进一步提供了30%的加速。

SpargeAttn的推出,为大模型的推理加速提供了一种新的、高效的解决方案。其无需训练、通用性强、精度无损等特点,使其具有广泛的应用前景。随着大模型在各领域的深入应用,SpargeAttn有望成为推动人工智能技术发展的关键力量。

参考文献

  • SpargeAttn: Accurate Sparse Attention Accelerating Any Model Inference, https://arxiv.org/abs/2502.18137
  • SageAttention (请根据实际情况补充SageAttention的相关文献)
  • FlashAttention (请根据实际情况补充FlashAttention的相关文献)

关于清华大学陈键飞团队:

清华大学陈键飞团队长期致力于深度学习模型优化与加速的研究,在Attention机制、量化技术等领域取得了丰硕成果。其SageAttention系列工作已在业界和社区得到广泛应用。

联系方式:

(请根据实际情况补充联系方式)
“`

说明:

  • 标题: 简洁明了,突出核心信息。
  • 引言: 概括文章核心内容,吸引读者。
  • 主体: 使用 Markdown 格式,分段阐述背景、技术细节、实验结果和展望。
  • 挑战与解决方案: 详细解释了 SpargeAttn 解决的关键问题。
  • 实验结果: 预留表格,方便根据论文数据填充。
  • 参考文献: 列出相关文献,增加文章可信度。
  • 图片链接占位: 需要根据实际情况替换为真实的图片链接。
  • 联系方式: 根据实际情况补充。
  • 语言风格: 专业、客观,符合新闻报道的特点。
  • 数据填充: 表格中的数据需要根据论文内容进行填充。

这个模板提供了一个清晰的结构和关键要素,可以根据实际情况进行调整和完善。记得在发布前进行仔细的校对和润色。


>>> Read more <<<

Views: 0

0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注