LESSON 28.02 · 5 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW
Online softmax
Watch softmax finish a row of scores in one pass over the keys.
Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 2 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 28.02 · SOFTMAX BAYTOKEN 7 · MAX 0.387 · 3 PASSES · 528 B
01
Stage 1 of 5 · Three passes
Safe softmax needs three passes: the max m, the sum ℓ, then the output. Each pass reads K again.
Explain it simply
Softmax turns scores into weights that sum to 1. Safe softmax subtracts the largest score first, so every power of e is 1 or less. Here the scores are small, yet e to the 12 is 162,755, past FP16's 65,504. The max comes before the sum, and the sum before the output, so K is read three times.
Sixteen score bars for query token 7. A dashed line marks the max, 0.387. Three pass arrows read K. The bar shows 528 bytes.
scores s, max m, sum ℓoutput o, O and byte countstile of keys in SRAMsum before the rescale
Toy: 1 head, 16 tokens × 4 values, seeded random, not trained; one query row, keys in tiles
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Each weight is e to the score minus the max, over the sum.
PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
- 4 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.