Log inStart free
LESSON 32.C1 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Inside a serving engine

Follow one engine step through every part of a serving engine.


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 · 32.C1 · ENGINE BAY4 RUNNING · 2 WAITING
01
Stage 1 of 6 · Requests in
The API server turns each prompt into tokens. R5 and R6 wait while R1 to R4 run.
Explain it simply

On the left, six clients send requests. The API server is the front door: it turns each prompt's text into tokens, the numbers the model reads. R1 to R4 already run and keep their tokens in the KV cache. R5 and R6 are new, so they wait in the queue.

Six request lanes. R1 to R4 run with 40, 23, 57 and 12 tokens in the KV cache. R5 and R6 wait with prompts of 24 and 20 tokens.

requests, tokensbudget, blocks, poolssampled tokenswaitsfree block
clientsAPI serverschedulerKV-cache managerworkerssamplerR140R223R357R412R524newR620newrunningwaiting queueR1R2R3R4R5R6R5: tokenize → system 16 + question 8 = 24 tokensR6: tokenize → system 16 + question 4 = 20 tokensclientsAPI serverschedulerKV-cache managerworkerssamplerR140R223R357R412R524newR620newrunningwaiting queueR1R2R3R4R5R6R5: tokenize → system 16 + question 8 = 24 tokensR6: tokenize → system 16 + question 4 = 20 tokens
Toy: R1–R4 decode, R5 and R6 wait; one layer, D 1,024, 8 heads; blocks of 16 tokens
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
p=s+q\sy{p}{data}{p} = \sy{s}{data}{s} + \sy{q}{data}{q}
p5=16+8=24p_5 = 16 + 8 = 24

A prompt is the system prompt plus the question.

Common mix-ups

MYTHA prefix cache only saves memory.

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

Predict, then reveal
3 CHECKS · PRO
Q01With the prefix cache on and a budget of 8, when does R6 get its first token?

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.