Log inStart free
LESSON 27.03 · 5 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Kernel launch overhead

Watch 12 small GPU kernels wait for the CPU that launches them.


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/mo
EXPLAINER · 27.03 · LAUNCH BAY12 KERNELS · WORK 23.2 µs
01
Stage 1 of 5 · GPU work
One decode step runs 12 kernels in order. Their memory and math work takes 23.2 µs.
Explain it simply

Each teal block is one kernel, a small program the GPU runs. Its width is the time it needs to read its bytes or do its math, whichever is longer. The four matrix products are the widest blocks, because they read the weights. With one sequence, the whole step needs 23.2 microseconds of work.

The GPU lane holds 12 kernel blocks back to back. Their work adds up to 23.2 µs.

kernel workCPU launchstart cost, idle GPUstep time
CPUGPUtime (µs)0102030405060QKV matmul256gate-up matmul911kernel workwork 23.2 µsw = max(bytes / 1 TB/s, FLOPs / 100 TFLOP/s) per kernelCPUGPUtime (µs)0102030405060QKV matmul256gate-up matmul911kernel workwork 23.2 µsw = max(bytes / 1 TB/s, FLOPs / 100 TFLOP/s) per kernel
Toy: one decode step, 12 kernels, a 1 TB/s GPU
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
wi=max⁡ ⁣(bytesiBW, FLOPsipeak)\sy{w}{data}{w_i} = \max\!\left(\frac{\text{bytes}_i}{\sy{bw}{param}{\text{BW}}},\ \frac{\text{FLOPs}_i}{\sy{pk}{param}{\text{peak}}}\right)
∑iwi=23.2 μs\textstyle\sum_i w_i = 23.2\ \mu\text{s}

A kernel's work is its memory time or its math time, whichever is longer.

Common mix-ups

MYTHA faster GPU always makes the decode step faster.

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

Predict, then reveal
3 CHECKS · PRO
Q01With 2 µs launches at batch 1, is the GPU busy for more or less than 90% of the step?

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

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.