LESSON 29.24 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW
Sampling on the GPU
Watch one GPU thread block turn 8 logits into one sampled token.
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 · 29.24 · SAMPLING BAY8 TOKENS · 8 THREADS · 1 BLOCK
01
Stage 1 of 6 · Logits in HBM
The last layer writes 8 logits to HBM. One thread of the sampling kernel reads each logit.
Explain it simply
Each box on top is one token with its logit, a raw score from the model. A block of threads works on the row at the same time. Here one thread holds one logit. A real block has 1,024 threads, so with 128,256 tokens each thread reads about 125 logits.
Eight token boxes in a row, each with its logit and one thread, t0 to t7.
The logits are toy values, not from a trained model.
logits ztemperature T, draw ukernel resultslogit copy, avoided
Toy: 8 tokens, 8 threads, 64 requests in the copy
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
One logit per token, and one thread per logit.
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.