FlashAttention-3:借助异步机制与低精度实现快速准确的注意力计算
FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision
AI总结:
针对现有注意力算法在新GPU上硬件利用率低的问题,提出FlashAttention-3,通过异步计算-数据重叠、运算交错及FP8分块量化三项技术,在H100上实现1.5-2.0倍加速,且FP8版本数值误差更低。
摘要:
注意力机制作为无处不在的Transformer架构的核心层,是大语言模型与长上下文应用的性能瓶颈。FlashAttention提出了一种通过最小化内存读写来加速GPU上注意力计算的方法,但尚未利用最新硬件具备的新能力——FlashAttention-2在H100 GPU上的利用率仅为35%。我们开发了三项核心技术以在Hopper架构GPU上加速注意力计算:利用Tensor Core(张量核心)与TMA(张量内存加速器)的异步特性,通过warp-specialization(线程束专用化)实现整体计算与数据移动的重叠;对分块矩阵乘法与softmax运算进行交错执行;以及分块量化与非相干处理,以利用硬件对FP8低精度格式的支持。实验表明,我们提出的FlashAttention-3方法在H100 GPU上实现了1.5-2.0倍的速度提升:FP16精度下算力可达740 TFLOPs/s(利用率75%),FP8精度下算力接近1.2 PFLOPs/s。我们验证了FP8版本的FlashAttention-3的数值误差比基线FP8注意力低2.6倍。
英文摘要:
Attention, as a core layer of the ubiquitous Transformer architecture, is the bottleneck for large language models and long-context applications. FlashAttention elaborated an approach to speed up attention on GPUs through minimizing memory reads/writes. However, it has yet to take advantage of new capabilities present in recent hardware, with FlashAttention-2 achieving only 35% utilization on the H100 GPU. We develop three main techniques to speed up attention on Hopper GPUs: exploiting asynchrony of the Tensor Cores and TMA to (1) overlap overall computation and data movement via warp-specialization and (2) interleave block-wise matmul and softmax operations, and (3) block quantization and incoherent processing that leverages hardware support for FP8 low-precision. We demonstrate that our method, FlashAttention-3, achieves speedup on H100 GPUs by 1.5-2.0$\times$ with FP16 reaching up to 740 TFLOPs/s (75% utilization), and with FP8 reaching close to 1.2 PFLOPs/s. We validate that FP8 FlashAttention-3 achieves 2.6$\times$ lower numerical error than a baseline FP8 attention.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。