Richael
← Back to blog

2026-08-03

Flash Attention: Correct, but Not Fast

3rd kernel: flash attention. Correctness is solid (max diff 0.000122 vs PyTorch), but it's ~25x slower on my T4.

Tried the exp2 trick thinking it was compute-bound - no change. T4 (Turing) lacks the pipelining hardware flash attention needs. Hardware limit, not a bug.

Correction, November 2026: the hardware explanation above is wrong. The same T4 runs a flash attention kernel at about 20 TFLOPs on Triton 3.1 and at this post's 0.5 on Triton 3.4 and later, so the slowdown follows the Triton version, not the card. https://dh8116.github.io/blog/flash-attention-revisited

Line chart comparing Triton and Torch SDPA throughput (TFLOPs/s) across sequence lengths from 512 to 8192. Torch SDPA climbs quickly to 13-14 TFLOPs/s, while Triton stays flat around 0.5 TFLOPs/s across all sequence lengths.