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

CUDA Graphs

Watch 12 kernel launches turn into one graph launch.


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 · 27.07 · GRAPH BAYEAGER STEP 61.6 µs · IDLE 26.4 µs
01
Stage 1 of 6 · Eager step
Without a graph, the CPU launches 12 kernels one by one. The decode step takes 61.6 µs.
Explain it simply

This is the decode step from the launch overhead lesson. Each ochre block on the CPU lane is one launch of 5 microseconds. Each teal block on the GPU lane is one kernel. 8 of the 12 kernels wait for their launch, and the dashed red gaps show the idle GPU.

A CPU lane of 12 launches over a GPU lane of 12 kernels. The eager step ends at 61.6 µs.

kernel, graph nodeCPU launch, setupstart cost, idle, paddinggraph runeager run
CPUGPUtime (µs)0102030405060QKV matmulgate-up matmuleager step 61.6 µseager stepeager: 12 launches, 60 µs of CPUT(eager) = 61.6 µs: 12 launches of 5 µs, GPU idle 26.4 µsCPUGPUtime (µs)0102030405060QKV matmulgate-up matmuleager step 61.6 µseager stepeager: 12 launches, 60 µs of CPUT(eager) = 61.6 µs: 12 launches of 5 µs, GPU idle 26.4 µs
Toy: one decode step, 12 kernels, a 1 TB/s GPU
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
starti=max⁡(i⋅L, endi−1),Teager=end12\text{start}_i = \max(i \cdot \sy{l}{param}{L},\ \text{end}_{i-1}),\quad \sy{Te}{ink}{T_{\text{eager}}} = \text{end}_{12}
Teager=61.6 μsT_{\text{eager}} = 61.6\ \mu\text{s}

A kernel starts when its launch is done and the GPU is free.

Common mix-ups

MYTHA CUDA graph removes all of the launch overhead.

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, does the graph save more or less than 5 µs per step?

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.