FlashAttention 2: Key Speed & Efficiency Gains

FlashAttention-2 improves upon its predecessor by re-engineering for better GPU parallelism and work partitioning, achieving up to 2x faster performance than FlashAttention-1, and 9x faster than standard PyTorch attention. It optimizes non-matmul FLOPs and uses better warp-level communication, reaching 50-73% of A100's theoretical peak FLOPs/s.

The top 3

  1. FlashAttention 2: Up to 10x Faster Than Standard Attention: FlashAttention-2 delivers approximately 2x speedup over its predecessor, FlashAttention 1, and can be up to 9-10x faster compared to standard PyTorch attention implementations, achieving up to 230 TFLOPs/s on A100 GPUs.
  2. FlashAttention 2's Top 3 Algorithmic Innovations: FlashAttention-2's significant performance gains result from three key optimizations: reducing non-matrix multiplication FLOPs, implementing sequence-length parallelism to boost GPU Streaming Multiprocessor (SM) occupancy, and switching the warp layout from 'split-K' to 'split-Q' to minimize inter-warp shared memory communication.
  3. Bridging the Gap: FlashAttention 2's GPU Utilization & LLM Context: FlashAttention-2 significantly boosts GPU utilization from 25-40% (FlashAttention 1) to 50-73% of theoretical peak FLOPs/s on A100 GPUs, closely matching the efficiency of raw matrix multiplication operations. This improved hardware efficiency enables training Large Language Models with 2x longer context windows at the same computational cost.

Sources

Open the full topic