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.

Try it

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

Design it

Fast first words, even at double traffic

One GPU serves a language model. Requests arrive about once a second, each with a prompt of 200 to 1,200 tokens. Pick how the GPU batches requests and how many it runs at once, then check the design.

The goals

  • At normal traffic, 95% of answers start within 1 s.
  • At double traffic, 95% of answers start within 5 s.
  • At double traffic, no request is pushed out of GPU memory and started again.
Batching
Requests the GPU runs at once

The check runs the same engine as the lab on this page for 60 simulated seconds under each condition, with a fixed seed, so a design always gets the same result. There is no score: each goal passes or fails.

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.