Log inStart free
LESSON 32.04 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Reading a GPU timeline

One slow decode step, traced row by row: find where the GPU waits.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 32.04 · TRACE BAY22 KERNELS · STEP 342 µs
01
Stage 1 of 6 · Launches
PyTorch Profiler records each CPU launch and each kernel. A kernel starts when its launch ends and the GPU is free.
Explain it simply

The top row is the CPU, and the row under it is the GPU. Each thin line joins a launch to the kernel it starts. The CPU only queues work, so it can run ahead of the GPU. Both tools record the same events; only the row names change.

A timeline of one decode step. The CPU row launches 24 operations, and 22 of them run on the GPU row in order.

kernelstoken copiesweight copygaps and waitsCPU work
record_functionCPU ops · rank 0GPU 0 kernels050100150200250300 µslayer 1layer 2layer 3layer 4mm1mm2mm1mm2mm1mm2mm1mm2torch.profiler trace (one file per rank)22 kernels launched by the CPU, run by GPU 0 in orderrecord_functionCPU ops · rank 0GPU 0 kernels050100150200250300 µslayer 1layer 2layer 3layer 4mm1mm2mm1mm2mm1mm2mm1mm2torch.profiler trace (one file per rank)22 kernels launched by the CPU, run by GPU 0 in order
Toy: one decode step, 4 MLP blocks, 2 GPUs, 16 requests
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
tstart=max⁡(tlaunch, tprev)\sy{s}{out}{t_{\text{start}}} = \max(\sy{l}{ink}{t_{\text{launch}}},\ \sy{p}{out}{t_{\text{prev}}})
tstart=max⁡(80.0, 74.1)=80.0 μst_{\text{start}} = \max(80.0,\ 74.1) = 80.0\ \mu s

A kernel starts at its launch or when the kernel before it ends.

Common mix-ups

MYTHHigh GPU utilization means the GPU does useful math.

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

Predict, then reveal
3 CHECKS · PRO
Q01With a slow CPU thread, does GPU utilization go up or down?

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 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.