Log inStart free
LESSON 29.C2 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Batching compared on one arrival trace

Run one trace of 10 requests through three batchers and compare.


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 · 29.C2 · SERVING BAY10 REQUESTS · 3,210 PROMPT · 98 OUTPUT TOKENS
01
Stage 1 of 6 · One trace
Ten requests arrive in 260 ms. Prompts run from 60 to 1,000 tokens, and outputs from 4 to 16.
Explain it simply

Each row is one chat request, with its prompt length on the left and its output length in blue. The bars show what one step costs on this toy GPU. Every step reads the weights once, the 16 ms part. So 4 rows cost only a little more than 1 row. That is why batching pays.

Ten lanes, R1 to R10, with arrival ticks from 0 to 260 ms. Below, three step-cost bars: 1 row 16.5 ms, 4 rows, and a 1,000-token prefill.

request, prompt, prefillbatch, step cost of weightswait, padding, empty rowoutput token, resultdecode step
promptout0 ms2505007501,0001,250step cost on this toy GPUR112R216R36R410R514R68R74R812R96R1010decode 1 row16.5 msdecode 4 rows18.0 msprefill 1,00076.0 ms10 requests, one toy GPU (the trace of 29.10)t_step(0, 4) = 16 + 0.5·4 = 18.0 mspromptout0 ms2505007501,0001,250step cost on this toy GPUR112R216R36R410R514R68R74R812R96R1010decode 1 row16.5 msdecode 4 rows18.0 msprefill 1,00076.0 ms10 requests, one toy GPU (the trace of 29.10)t_step(0, 4) = 16 + 0.5·4 = 18.0 ms
Toy: the 29.C2 trace, R1–R10, on one toy GPU
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
tstep=16+0.06 P+0.5 D ms\sy{step}{ink}{t_{\text{step}}} = \sy{w}{param}{16} + 0.06\,\sy{P}{data}{P} + 0.5\,\sy{D}{out}{D}\ \text{ms}
tstep(0,4)=16+0.5⋅4=18.0 mst_{\text{step}}(0, 4) = 16 + 0.5 \cdot 4 = 18.0\ \text{ms}

A step costs the weights once, plus prompt tokens and decoded rows.

Common mix-ups

MYTHContinuous batching beats static batching on every metric.

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

Predict, then reveal
3 CHECKS · PRO
Q01At batch size 4 with mixed lengths, switch to continuous batching. Does R1 get its first token sooner or later?

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.