FlashAttention-3 speeds up FP16 attention on NVIDIA H100 GPUs by 1.5x to 2.0x over FlashAttention-2, reaching 740 TFLOPs/s (75% of Hopper’s theoretical peak) while pushing FP8 attention near 1.2 PFLOPs/s with 2.6x lower numerical error than standard per-tensor FP8. In July 2024, Jay Shah, Ganesh Bikshandi (Colfax Research), Ying Zhang (Meta), Vijay Thakkar, Pradeep Ramani (NVIDIA), and Tri Dao (Princeton and Together AI) showed why FlashAttention-2 stalled at 35% utilization on Hopper despite reaching 73% on Ampere: synchronous kernel scheduling forced asynchronous Tensor Cores, memory engines, and exponential units to wait on one another.

On an H100 SXM5 (132 SMs at 1830 MHz), FP16 Tensor Core matmul delivers 989 TFLOPs/s, whereas special-function units computing softmax exp deliver just 3.9 TFLOPs/s. At head dimension 128, attention performs 512x more matmul FLOPs than exp ops, yet exp runs 256x slower per FLOP, meaning serialized softmax alone can burn half the execution time (and even more in FP8).

  • 1.5x to 2.0x FP16 speedup: Forward passes reach up to 740 TFLOPs/s (and 756 TFLOPs/s non-causal at 2k sequence length, head dim 128), backward passes run 1.5x to 1.75x faster than FlashAttention-2, and long sequences (seqlen >= 1k) beat closed-source cuDNN 9.
  • Near-1.2 PFLOPs/s FP8 throughput: Asynchronous FP8 WGMMA plus in-kernel shared-memory V transposes reach up to 1,171 TFLOPs/s (16k causal, head dim 256).
  • 2.6x lower FP8 outlier error: Block quantization paired with orthogonal Hadamard incoherent processing cuts synthetic outlier RMSE from 2.4e-2 to 9.1e-3 (e4m3 vs. FP64 reference).
  • Both overlap techniques are required: Disabling either warp-specialization (570 TFLOPs/s) or 2-stage GEMM-softmax pipelining (582 TFLOPs/s) erases most of the gain down from 661 TFLOPs/s on 8k non-causal attention.
H100 FP16 pipelining ablation (batch 4, seqlen 8,448, 16 heads, head dim 128)
GEMM-Softmax pipelining, no warp-specialization570 TFLOPs/s (4.105 ms)
Warp-specialization, no GEMM-Softmax pipelining582 TFLOPs/s (4.021 ms)
Full FlashAttention-3 (warp-specialization + 2-stage overlap)661 TFLOPs/s (3.538 ms)

Bar widths scaled against H100’s 989 TFLOPs/s theoretical FP16 ceiling (higher is better). Source: Shah et al. (2024), Table 2.

How It Works

FlashAttention-3 redesigns the tiled kernel around three Hopper hardware mechanisms:

  1. Producer-consumer warp-specialization and pingpong scheduling: Thread blocks split warps into dedicated TMA producers (issuing asynchronous HBM to shared-memory loads into a circular buffer) and WGMMA consumers, using Hopper’s setmaxnreg to donate registers from idle producers to compute warps. Across two consumer warpgroups, bar.sync barriers enforce pingpong scheduling so one warpgroup executes Tensor Core WGMMA while the other computes softmax exp, lifting 8k FP16 forward throughput from 570 to 620 to 640 TFLOPs/s. (In the backward pass, a dedicated dQ-writer warp overlaps global atomic accumulations.)
  2. Intra-warpgroup 2-stage GEMM-softmax pipelining: Even inside one warpgroup, waiting for S = QK^T before softmax and O += PV serializes hardware units. By buffering an extra score tile S_next in registers, the kernel executes the asynchronous PV WGMMA of iteration j - 1 concurrently with softmax on iteration j. A 3-stage variant actually ran slower because NVCC did not overlap the second WGMMA and extra register pressure shrank tile sizes.
  3. In-kernel FP8 transposes and Hadamard incoherence: Hopper’s FP8 WGMMA demands k-major shared-memory operands, clashing with V’s head-contiguous layout and FP32 accumulator registers. Rather than paying for a global memory transpose kernel, FlashAttention-3 performs a packed 8-bit LDSM/STSM transpose of V inside shared memory hidden behind prior WGMMA work, paired with register byte permutations. To tame 3-bit-mantissa e4m3 quantization outliers, it combines per-block scaling with incoherent processing, multiplying Q and K by a random diagonal ±1 Hadamard matrix M in O(d log d) time (fusable with RoPE). Because M is orthogonal (M M^T = I), (QM)(KM)^T = QK^T preserves exact dot products while spreading outlier spikes across channels.
FP8 (e4m3) outlier error ablation vs. FP64 reference (RMSE, lower is better)
Baseline FP8
2.4e-2
Per-tensor scaling, FP16 softmax
No incoherent proc.
2.4e-2
Block quant alone does not tame outliers
No block quant
9.3e-3
Hadamard transform drives the gain
Full FA-3 FP8
9.1e-3
2.6x lower RMSE than baseline

Simulated with 0.1% outlier entries of std 10 added to N(0, 1). Source: Shah et al. (2024), Section 4.3 and Table 3.

Key Findings

Benchmarked on an H100 80GB SXM5 with 16k tokens per batch (sequence lengths 512 to 16k, hidden dim 2048, head dims 64, 128, 256), FlashAttention-3 FP16 delivers 1.5x to 2.0x higher forward throughput than FlashAttention-2, 1.5x over Triton, and 3x to 16x over standard PyTorch attention. At sequences of 1k and longer, FP16 FlashAttention-3 surpasses NVIDIA’s closed-source cuDNN 9 library.

In FP16, both FlashAttention-2 and FlashAttention-3 match at 1.9e-4 RMSE against FP64, 1.7x lower than standard PyTorch attention (3.2e-4) because intermediate softmax statistics stay in FP32. In FP8, the Table 3 ablation confirms that Hadamard incoherent processing does almost all the heavy lifting against activation outliers, cutting error 2.6x even before adding per-block scaling. Like FlashAttention-2, the kernel natively supports multi-query and grouped-query attention without duplicating K and V in HBM.

Caveats and Builder Takeaway

  • Hopper-only primitives and FP8 gaps: The kernel relies on Hopper TMA, WGMMA, and setmaxnreg, offering no direct speedup on Ampere A100 GPUs. Furthermore, the paper’s FP8 kernel lacks the persistent scheduling and causal load-balancing strategy built into FP16 FlashAttention-3, so FP8 lags cuDNN 9 on short sequences and causal masks at head dimensions 128 and 256 (ahead at head dim 64).
  • Prefill and training focus, not single-token decode: Benchmarks evaluate long-sequence compute-bound passes (512 to 16k query tokens). Memory-bandwidth-bound autoregressive decode steps (query_len = 1) still depend on PagedAttention or split-KV decode kernels for utilization.
  • FP8 training stability untested: The paper evaluates FP8 kernel RMSE on synthetic outliers rather than end-to-end large-scale pretraining runs.

Builder takeaway: On H100 clusters running long-context training or high-throughput prefill, upgrading from FlashAttention-2 to FlashAttention-3 FP16 is a drop-in 1.5x to 2.0x attention speedup with identical numerical accuracy; hold off on FP8 attention for causal 128/256 head dimensions until persistent causal load balancing closes the gap with cuDNN 9.