Read page 1 as text
How does an LLM server serve many people at once?
One model. Many conversations. Which parts can share the work?
WHAT WE WILL FIGURE OUT
01
Batch work without mixing conversations
02
Refill a finished slot
03
Allocate cache in small blocks
OUR EXAMPLE
Four service slots and request lengths of 2, 2, 8 and 8 steps.
Follow the steps. Ask the obvious questions. Check the result.
Part 11 of 18 · Challenge: page 5 · Suggested answers: page 6
Read page 2 as text
Batch work without mixing conversations
1
ONE LOADED MODEL
shared weights
separate contexts
shared weights
separate contexts
Does every person need a model copy?
Many requests can use one loaded set of weights. Their context states stay logically separate.
Shared weights; separate request state
2
BATCH THE STEP
FOLLOW THE CHANGE
A + B + C + D
GPU batch
A + B + C + D
→
GPU batch
A batch combines work for several requests into GPU operations. This can amortize weight movement and improve utilization.
One decode step can include several users
3
KEEP LATENCY SEPARATE
system throughput
user latency
system throughput
user latency
Higher total tokens per second does not guarantee faster tokens for each person. Larger batches can increase waiting or gaps.
Throughput and individual latency are different
4
AN ORDINARY STATIC BATCH
STATIC BATCH
A
B
C
D
8 steps → pale = idle
A: 2
B: 2
C: 8
D: 8
Suppose four requests need 2, 2, 8 and 8 steps. Two finish early, but a naive fixed batch leaves their seats idle.
After step 2: two finished, two still running
Read page 3 as text
Refill a finished slot
5
REFILL THE EMPTY SEAT
CONTINUOUS BATCH: REFILL AFTER STEP 2
A
E
B
F
C
D
New work enters available, permitted slots
A done
B done
E + F enter
Why wait for the longest answer?
Continuous batching updates active membership as work finishes. A new request can use a freed slot.
A finished slot can admit the next waiting request
6
PREFILL NEEDS SCHEDULING TOO
prefill work
decode work
prefill work
decode work
New prompts may compete with decode work. Chunking and scheduler policies can balance startup waits and ongoing streams.
New prompt work + existing token generation
7
DO NOT MIX THE FILES
context A
context B
context A
context B
Each active sequence keeps its own context and sampling state. A shared batch is not a shared conversation.
Request A cannot borrow request B's private text
8
ADMISSION STILL MATTERS
cache room
queue
latency
cache room
queue
latency
A free compute slot is not unlimited memory. Admit work only when cache and latency budgets permit it.
Check queue, token budget and cache pressure
Read page 4 as text
Allocate cache in small blocks
9
RESERVING THE MAXIMUM
FOLLOW THE CHANGE
growing sequence
small blocks
growing sequence
→
small blocks
Must I reserve a huge contiguous block?
Over-reserving a maximum-length region can waste cache space. Paged KV allocation uses smaller physical blocks.
Allocate blocks as a sequence grows
10
A BLOCK TABLE
LOGICAL BLOCK → PHYSICAL BLOCK
0
→
7
1
→
2
2
→
9
logical 0
→
physical 7
The runtime maps logical token positions to physical memory blocks, which need not be contiguous.
Logical block 0 → physical block 7
11
SHARE ELIGIBLE PREFIXES
shared prefix
private suffixes
shared prefix
private suffixes
Supporting runtimes can point multiple requests at eligible shared prefix blocks, with isolation for later changes.
Shared prefix blocks; separate suffix blocks
12
MY NEW MENTAL MODEL
batching: slots
paging: blocks
batching: slots
paging: blocks
Schedule steps; allocate memory on demand.
Continuous batching reduces idle capacity. Paging reduces allocation waste. They solve related but different problems.
Neither creates unlimited capacity
Read page 5 as text
Your turn. Can you explain what happens?
Use the same example. Change one detail. What follows?
KEEP THIS EXAMPLE IN MIND
Four service slots and request lengths of 2, 2, 8 and 8 steps.
Try first. Suggested answers are on the next page.
1
In the toy static batch, how many slots become idle after step 2?
What makes you say that?
2
What does continuous batching change?
What makes you say that?
3
What does the block table map?
What makes you say that?
Write your answers in the comments.
Read page 6 as text
Suggested answers
How does an LLM server serve many people at once?
01
In the toy static batch, how many slots become idle after step 2?
Two of the four slots.
02
What does continuous batching change?
It allows membership to change as requests finish, subject to scheduling and memory constraints.
03
What does the block table map?
Logical sequence blocks to physical KV-memory blocks.