Log inStart free
LESSON 32.03 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Lowering a graph to kernels

Watch 8 graph ops become a few GPU kernels, then machine code.


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/mo
EXPLAINER · 32.03 · COMPILER BAY8 OPS · N 300 · 5 FOLDED
01
Stage 1 of 6 · Runtime graph
The traced block runs 8 ops on every call. Its 5 constant nodes are folded ahead.
Explain it simply

Each box is one op of the block, in the order the program runs them. The teal x is the input, and the ochre chips are weights. The weights stay the same on every call. Only the number of rows changes.

A chain of 8 op boxes: ln, mm1, add1, act, mm2, add2, res and out. The input has 300 rows.

input and tensorsweights, settingskernels, timeslaunches, round trips
runtime graphHBMscaleroottwo_lw2tw1tfolded ahead:xγ, βW1ᵀb1W2ᵀb2scalexlnmm1add1actmm2add2resoutruntime graphHBMscaleroottwo_lw2tw1tfolded ahead:xγ, βW1ᵀb1W2ᵀb2scalexlnmm1add1actmm2add2resout
Toy: the 32.01 MLP block, 8B-class sizes, a toy H100-like GPU
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x∈RN×D\sy{x}{data}{x} \in \mathbb{R}^{\sy{n}{param}{N} \times D}
N=300,  D=4096,  H=16384N = 300,\; D = 4096,\; H = 16384

The input holds N rows of D numbers.

Common mix-ups

MYTHFusion makes the GPU do less math.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If fusion joins only pointwise ops, how many kernels run for one call?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

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.