papers / flashattention2
Next task →
Research Papers/Efficient inference and systems/FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
Efficient inference and systems · #3 · modern

FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning

Tri Dao · 2023 · NeurIPS
reproduction difficulty: highSystemsTransformersEfficiency

1. Research problem

The first FlashAttention reduced memory traffic but still left GPU occupancy low and wasted work on non-matmul operations.

2. Motivation

The authors wanted to better align the algorithm with GPU execution model by increasing parallelism and reducing non-matmul FLOPs.

3. Previous approaches

FlashAttention tiled attention but partitioned work in a way that underutilized thread blocks and synchronized frequently across blocks.

4. Core contribution

Refined work partitioning to reduce non-matmul operations, parallelize over sequence length in addition to batch and heads, and adjust warp-level layout for tensor cores.

5. Mathematical formulation

Same exact online-softmax attention mathematics as FlashAttention, with different loop ordering and a split-K-style partition across blocks.

6. Methodology

Kernel-level engineering: fewer rescaling operations, more parallelism across attention heads and query blocks, and improved warp partitioning.

7. Architecture

Updated attention kernel; no model-level changes.

8. Experimental setup

Benchmarks on A100/H100 GPUs for forward and backward passes at various sequence lengths and head dimensions.

9. Datasets

Synthetic attention benchmarks plus end-to-end transformer training setups.

10. Results

Roughly two times the speed of FlashAttention on common configurations and substantially better GPU utilization, approaching a large fraction of peak FLOPs.

11. Limitations

Highly hardware-specific; performance gains vary by GPU generation and shape; requires maintaining specialized kernels.

12. Critical analysis

Incremental in mathematics but important in practice, illustrating that systems co-design is central to modern model scaling.

13. Implementation tasks

  • 1.Benchmark attention across sequence lengths to find where the kernel becomes memory- versus compute-bound.
  • 2.Compare forward/backward throughput of FlashAttention and FlashAttention-2 on a supported GPU.
  • 3.Inspect how split query blocks change occupancy using a profiler.

14. Follow-up work

  • 1.FlashAttention: Fast and Memory-Efficient Exact Attention (Dao et al., 2022)
  • 2.FlashAttention-3 and hardware-specific attention kernels

15. Open research questions

  • 1.How portable are these kernel optimizations across accelerator generations?
  • 2.Can the same IO-aware ideas accelerate non-attention operators?
16. Reproduce it. Record the hypothesis, configuration, dataset, metrics and discrepancies in the Experiment Tracker. A reproduction is not complete until you have run the experiments, performed at least one ablation and documented the differences from the reported numbers.