Attention, as a core layer of the ubiquitous Transformer architecture, is the bottleneck for large language models and long-context applications. While FlashAttention-3 optimized attention for Hopper GPUs through asynchronous execution and warp specialization, it primarily targets the H100 architecture. The AI industry has rapidly transitioned to deploying Blackwell-based systems such as the B200 and GB200, which exhibit fundamentally different performance characteristics due to asymmetric hardware scaling: tensor core throughput doubles while other functional units (shared memory bandwidth, exponential units) scale more slowly or remain unchanged. We develop several techniques to address these shifting bottlenecks on Blackwell GPUs: (1) redesigned pipelines that exploit fully asynchronous MMA operations and larger tile sizes, (2) software-emulated exponential and conditional softmax rescaling that reduces non-matmul operations, and (3) leveraging tensor memory and the 2-CTA MMA mode to reduce shared memory traffic and atomic adds in the backward pass. We demonstrate that our method, FlashAttention-4, achieves up to 1.3$\times$ speedup over cuDNN 9.13 and 2.7$\times$ over Triton on B200 GPUs with BF16, reaching up to 1613 TFLOPs/s (71% utilization). Beyond algorithmic innovations, we implement FlashAttention-4 entirely in CuTe-DSL embedded in Python, achieving 20-30$\times$ faster compile times compared to traditional C++ template-based approaches while maintaining full expressivity.


翻译:注意力机制作为普遍存在的Transformer架构的核心层,是大型语言模型和长上下文应用的性能瓶颈。尽管FlashAttention-3通过异步执行和线程束(warp)专用化针对Hopper GPU优化了注意力计算,但它主要面向H100架构。AI行业已迅速转向部署基于Blackwell架构的系统(如B200和GB200),这些系统由于非对称硬件扩展而展现出根本不同的性能特征:张量核心吞吐量翻倍,而其他功能单元(共享内存带宽、指数运算单元)扩展较慢或保持不变。我们开发了多种技术以应对Blackwell GPU上这些不断变化的瓶颈:(1)利用完全异步的MMA(矩阵乘累加)操作和更大分块尺寸的重新设计流水线;(2)通过软件模拟的指数运算和条件性softmax重缩放,以减少非矩阵乘法运算;(3)利用张量内存和2-CTA MMA模式,以减少反向传播过程中的共享内存流量和原子加法操作。我们证明,在B200 GPU上使用BF16精度时,我们的方法FlashAttention-4相比cuDNN 9.13实现了最高1.3倍的加速,相比Triton实现了最高2.7倍的加速,算力峰值达到1613 TFLOPs/s(利用率为71%)。除了算法创新,我们完全使用嵌入在Python中的CuTe-DSL实现了FlashAttention-4,相比传统的基于C++模板的方法,编译时间加快了20-30倍,同时保持了完整的表达能力。

0
下载
关闭预览

相关内容

DeepSeek技术溯源及前沿探索
专知会员服务
34+阅读 · 2025年5月28日
非Transformer不可?最新《状态空间模型(SSM)》综述
专知会员服务
75+阅读 · 2024年4月16日
144页ppt!《Transformers》全面讲解,附视频
专知会员服务
118+阅读 · 2023年1月1日
【ICML2022】Transformer是元强化学习器
专知会员服务
56+阅读 · 2022年6月15日
华为等发布《视觉Transformer转换器》综述论文,21页pdf
专知会员服务
86+阅读 · 2020年12月25日
盘点来自工业界的GPU共享方案
计算机视觉life
12+阅读 · 2021年9月2日
深度学习的下一步:Transformer和注意力机制
云头条
56+阅读 · 2019年9月14日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
从Seq2seq到Attention模型到Self Attention(一)
量化投资与机器学习
76+阅读 · 2018年10月8日
TensorFlow seq2seq中的Attention机制(续)
深度学习每日摘要
15+阅读 · 2017年11月16日
国家自然科学基金
8+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
VIP会员
最新内容
美国与以色列如何在攻击伊朗中使用人工智能
专知会员服务
3+阅读 · 4月16日
《自动化战略情报管控》
专知会员服务
2+阅读 · 4月16日
得失评估:审视对伊朗战争的轨迹(简报)
专知会员服务
2+阅读 · 4月16日
【CMU博士论文】迈向可解释机器学习的理论基础
基于数据优化的人机协同与机器人僚机
专知会员服务
7+阅读 · 4月16日
相关VIP内容
DeepSeek技术溯源及前沿探索
专知会员服务
34+阅读 · 2025年5月28日
非Transformer不可?最新《状态空间模型(SSM)》综述
专知会员服务
75+阅读 · 2024年4月16日
144页ppt!《Transformers》全面讲解,附视频
专知会员服务
118+阅读 · 2023年1月1日
【ICML2022】Transformer是元强化学习器
专知会员服务
56+阅读 · 2022年6月15日
华为等发布《视觉Transformer转换器》综述论文,21页pdf
专知会员服务
86+阅读 · 2020年12月25日
相关资讯
盘点来自工业界的GPU共享方案
计算机视觉life
12+阅读 · 2021年9月2日
深度学习的下一步:Transformer和注意力机制
云头条
56+阅读 · 2019年9月14日
【干货】注意力机制(Attention)最新综述论文及相关源码
GAN生成式对抗网络
11+阅读 · 2018年11月16日
从Seq2seq到Attention模型到Self Attention(一)
量化投资与机器学习
76+阅读 · 2018年10月8日
TensorFlow seq2seq中的Attention机制(续)
深度学习每日摘要
15+阅读 · 2017年11月16日
相关基金
国家自然科学基金
8+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员