Module 11 · Lesson 5 of 5

Two numbers to watch

Lab · AI engineering

Serving a language model

Requests fill a GPU batch and its memory; watch batching, long prompts and batch size decide how fast each user gets an answer.

Lab time 3.0 s
Users, 1/sUsers1/sQueue, waiting for a batch slotQueuewaiting for a batch slot0 waitingGPU, 7 / 8 in the batchGPU7 / 8 in the batch82% of memory used
  • Users — 1/s — healthy
  • Queue — waiting for a batch slot — healthy — 0 waiting
  • GPU — 7 / 8 in the batch — healthy — 82% of memory used
  • Request
  • Response

A token is a small piece of text the model reads or writes.

A GPU is the chip that runs the model's calculations.

Time to first token ()
247 ms
Time to first token ()
296 ms
Healthy:
Tokens a second
79/s
Each user's tokens a second
25.5/s
Queue length
0
Paused to free memory (preemptions)
0
Wasted slot steps
0
Seats held by finished requests, static batching only

Numbers add up:9 arrived = 1 completed + 7 running + 0 waiting + 1 in flightThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

Traffic
1/s

New requests bring a 2,000–4,000-token prompt instead of 200–1,200.

Batching
Batching mode

Requests join and leave the batch at every step. Memory grows one token at a time.

8 requests
8,000 tokens

In the batch

  • r170 of 83 tokens
  • r334 of 103 tokens
  • r434 of 41 tokens
  • r533 of 104 tokens
  • r619 of 25 tokens
  • r75 of 119 tokens
  • r80 of 43 tokens

Memory (KV cache)

The KV cache is the memory where the model keeps its saved work on every token so far.

  • Used6,556 of 8,000 tokens (82%)
Time to first token (, recent)
0 ms125 ms250 ms375 ms500 ms1s2s3s
Show data table
Timep95
1s189 ms
1s212 ms
2s296 ms
2s296 ms
3s296 ms
3s296 ms
Tokens a second
0501001502001s2s3s
Show data table
TimeTokens/s
1s16
1s54
2s56
2s110
3s126
3s110
Queue and batch
WaitingIn the batch
02.557.5101s2s3s
Show data table
TimeWaitingIn the batch
1s01
1s02
2s05
2s05
3s05
3s07
What this model simplifies
  • The step times, prefill speed and memory size are made up to show the shape. Real numbers vary by model and hardware by ten times or more.
  • Every request's answer length is fixed when it arrives. A real model stops when it writes a special end token.
  • Paused requests go back to the queue and redo their work. Real servers can also move saved work to slower memory instead.
  • One GPU and one model. Real services spread a model over several GPUs and run many copies behind a load balancer.

Open the full lab →

Two numbers describe how a model server feels to use. (see How a model writes) is the wait for the first piece of the answer: the plus reading the .

per second is the speed of every token after that first one. It says how fast the rest of the answer streams in, once the model has started writing.

A bigger batch raises the 's total tokens produced every second, across every request together. But since each step takes a little longer with more requests in it, each single user's own tokens per second falls.

Because of this trade-off, a design sets a target for both numbers, not for one alone. A fast start with a slow stream can still feel disappointing once the answer begins.

Example. Illustrative: a chat product might aim for the first token within about 1 second, and at least 15 tokens a second after that. These are example targets, not fixed rules.

In system design: Set a target for both numbers, and watch them together. A larger batch trades one for the other, so pick a batch size that meets both targets.

Check yourself

Why should a chat product set targets for both time to first token and tokens per second?