Log inStart free
LESSON 29.13 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Static vs dynamic batching

See who waits and what is wasted when requests share a batch.


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

Go Pro · $8.25/mo
EXPLAINER · 29.13 · SERVING BAY8 REQUESTS · 82 OUTPUT TOKENS
01
Stage 1 of 5 · Requests arrive
Eight requests arrive in 200 ms. Prompts run from 60 to 1,000 tokens, and outputs from 4 to 16.
Explain it simply

Each row is one request to a chatbot. The teal tick shows when it arrives. On the left, the teal bar is the prompt length, and the blue number is how many tokens it writes. These lengths matter once requests share a batch.

Eight request lanes, R1 to R8, on a time axis from 0 to 1,600 ms. Arrivals run from 0 to 200 ms. Prompts: 200, 60, 800, 120, 400, 80, 1000, 150 tokens. Outputs: 12, 16, 6, 10, 14, 8, 4, 12 tokens.

request, prompt, prefillbatchwait, padding, empty slotoutput token, resultdecode step
04008001,2001,600time, mspromptoutR112R216R36R410R514R68R74R812the requests8 prompts, 2,810 tokens in all · 82 output tokens04008001,2001,600time, mspromptoutR112R216R36R410R514R68R74R812the requests8 prompts, 2,810 tokens in all · 82 output tokens
Toy: R1–R8 of the 29.C2 trace on one toy GPU
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
ai,pi,oi\sy{a}{data}{a_i},\quad \sy{p}{data}{p_i},\quad \sy{o}{out}{o_i}
R1: a=0 ms, p=200, o=12\text{R1}:\ a = 0\ \text{ms},\ p = 200,\ o = 12

Each request has an arrival time, a prompt length and an output length.

Common mix-ups

MYTHA new request can join a dynamic batch that is running.

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

Predict, then reveal
3 CHECKS · PRO
Q01With static batching, does R1 wait longer at batch size 8 than at batch size 4?

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