LESSON 28.C1 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW
FlashAttention end to end
Follow 16 tokens through naive attention and FlashAttention, counting every HBM byte.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 28.C1 · KERNEL BAYNAIVE 2,560 B · S, P 2,048 B
01
Stage 1 of 6 · Naive kernels
Explain it simply
Each kernel is a separate program on the chip. When one ends, its fast memory is cleared. So the score grid S goes out to the big, slow memory, and the next kernel reads it back. The probabilities P make the same round trip, and that's most of the traffic.
Three kernel boxes sit in SRAM. S and P sit in HBM. The naive bar fills to 2,560 B; S and P are 2,048 B of it.
Q, K, VS, P, max m, sum ℓ (traffic to remove)O, written to HBMSRAM, current tileskipped, masked or never written; a dashed bar: does not fit, or no skip
Toy: 1 head, 16 tokens × 4 values in FP16, seeded random, not trained; SRAM 256 B
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Q, K, V and O give 4Nd values; S and P give 4N² values.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 2 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.