Logo/

FlashAttention-3 essentials

Log in

Made with ScholarlyMake flashcards like these from your own notes

FlashAttention-3 essentials

Questions and answers

49 cards
  1. Question:What is incoherent processing in FlashAttention-3?

    Answer:Multiplying Q and K with a random orthogonal matrix M before FP8 quantization to even out outliers.

  2. Question:Why multiply Q and K with matrix M in incoherent processing?

    Answer:To spread out outliers, reducing quantization error in FP8.

  3. Question:What property ensures multiplying Q and K with M doesn't change attention output?

    Answer:M is orthogonal, so M M^T = I, thus (Q M)(K M)^T = Q K^T.

  4. Question:How does incoherent processing reduce quantization error?

    Answer:Each entry in Q M or K M is a random sum of original entries, spreading outlier impact.

  5. Question:What is the choice of M in incoherent processing?

    Answer:Product of random diagonal matrices of ±1 and a Hadamard matrix.

  6. Question:What is the time complexity of multiplying with the chosen M?

    Answer:O(d log d), faster than O(d^2).

  7. Question:Can M multiplication fuse with rotary embedding?

    Answer:Yes, at no extra computation cost.

  8. Question:By how much do the techniques reduce numerical error?

    Answer:Up to 2.6x, validated in section 4.3.

  9. Question:What primitives from CUTLASS are used in FlashAttention-3?

    Answer:WGMMA and TMA abstractions for implementation.

  10. Question:What is FlashAttention-3 compared to in benchmarking?

    Answer:PyTorch standard, FlashAttention-2, Triton FA-2, cuDNN FA-2 on H100.

  11. Question:How much faster is FlashAttention-3 than FlashAttention-2?

    Answer:Up to 2.0x faster.

  12. Question:How does FlashAttention-3 compare to Triton FA-2?

    Answer:1.5x faster.

  13. Question:What peak performance does FlashAttention-3 achieve?

    Answer:Up to 740 TFLOPs/s, 75% of H100 theoretical max.

  14. Question:What contributes to FlashAttention-3 speedup in ablation?

    Answer:Warp-specialization and GEMM-softmax pipelining.

  15. Question:How much error reduction from FP8 techniques?

    Answer:2.6x reduction in numerical error.

  16. Question:What GPU is used for benchmarking?

    Answer:H100 80GB SXM5.

  17. Question:What input precision for main benchmarks?

    Answer:FP16 inputs, with/without causal mask, head dims 64 or 128.

  18. Question:How much faster is FA-3 forward pass than FA-2?

    Answer:1.5-2.0x faster.

  19. Question:Backward pass speedup of FA-3 over FA-2?

    Answer:1.5-1.75x faster.

  20. Question:Compared to standard PyTorch attention, FA-3 speedup?

    Answer:Up to 3-16x faster.

  21. Question:When does FA-3 surpass cuDNN FA-2?

    Answer:For medium and long sequences (1k and above).

  22. Question:Benchmark sequence lengths varied?

    Answer:512, 1k, ..., 16k.

  23. Question:How is batch size set in benchmarks?

    Answer:So total tokens = 16k.

  24. Question:Hidden dimension in benchmarks?

    Answer:2048.

  25. Question:Head dimensions tested?

    Answer:64, 128, 256 (32, 16, 8 heads).

  26. Question:Forward pass FLOPs formula?

    Answer:4 * seqlen^2 * head_dim * num_heads.

  27. Question:Adjustment for causal masking in FLOPs?

    Answer:Divide by 2, as half the entries are computed.

  28. Question:Backward pass FLOPs relative to forward?

    Answer:2.5x forward FLOPs.

  29. Question:FP8 benchmarks focus on?

    Answer:Forward pass, head dim 256, results in Fig. 7 and Appendix C.2.

  30. Question:Ablation parameters fixed?

    Answer:batch=4, seqlen=8448, nheads=16, hdimg=128.

  31. Question:TFLOPs improvement in ablation?

    Answer:From 570 to 661 TFLOPs with pipelining and specialization.

  32. Question:What does Figure 5a show?

    Answer:Forward speed without causal mask, head dim 64 on H100.

  33. Question:Trend in Figure 5b for causal mask head 64?

    Answer:FA-3 up to 473 TFLOPs at 16k, outperforms others.

  34. Question:Peak in Figure 5c non-causal head 128?

    Answer:FA-3 at 648 TFLOPs for 16k seq.

  35. Question:Figure 5d causal head 128 performance?

    Answer:FA-3 reaches 616 TFLOPs at 16k.

  36. Question:For head 256 non-causal in Fig 5e?

    Answer:FA-3 up to 756 TFLOPs, highest.

  37. Question:Causal head 256 in Fig 5f?

    Answer:FA-3 at 642 TFLOPs for 16k.

  38. Question:Numerical error comparison against?

    Answer:FP64 reference implementation.

  39. Question:How are outliers simulated in error validation?

    Answer:Generate Q, K, V entries to mimic LLM features and activations.

  40. Question:Interest in FlashAttention numerical error from?

    Answer:Paper [21].

  41. Question:What validates FP8 attention accuracy?

    Answer:Block quantization and incoherent processing reduce error 2.6x.

  42. Question:Why use WGMMA in FA-3?

    Answer:For efficient GEMM on Hopper tensor cores.

  43. Question:Role of TMA in FA-3?

    Answer:Tensor memory access for fast data loading to SRAM.

  44. Question:What is the theoretical max TFLOPs on H100 for attention?

    Answer:Implied ~987 TFLOPs, since 75% is 740.

  45. Question:OOM in benchmarks means?

    Answer:Out of memory, e.g., standard attention at long seq.

  46. Question:Why 2.5x FLOPs for backward?

    Answer:2 matmuls forward, 5 in backward due to gradient recompute.

  47. Question:Follows which papers for M choice?

    Answer:Chee et al. [9] and Tseng et al. [58].

  48. Question:What is 2-stage pipelining in ablation?

    Answer:WGMMA-softmax pipelining for overlapping compute.

  49. Question:Warp-specialization benefit?

    Answer:Allows asynchrony, improving throughput.