LESSON 27.17 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW
A fused softmax kernel
Watch softmax run as five GPU kernels, then as one fused kernel.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 27.17 · SOFTMAX BAYFUSED · 0 KERNELS · HBM 0 B
01
Stage 1 of 6 · Scores in HBM
The decode token has 2 heads. Each head stores 8 attention scores in HBM as FP16.
Explain it simply
At the bottom is HBM, the big main memory of the GPU. The new token has two heads, and each head has 8 scores, one per position. Softmax must turn each row into probabilities. Above sit the registers of one SM, where a kernel does its math.
HBM holds two rows of 8 scores. The largest score is 1.82 in head 1 and 3.48 in head 2. The register lanes are empty.
scores, partial resultsprobabilitiesextra HBM trips, overflowempty or not stored
Toy: 2 heads × 8 positions; 8 lanes per block (a warp has 32)
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Each score is the query times one key, over the root of 4.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 3 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.