Inference Engineer: Serving design
Design a serving stack
About 45 minutes, start to finish.
Open withLet me start with the targets: how many requests, how long prompts and replies are, and how fast the first token and the rest must come.
The clock
Stage by stage
Close each stage out loud, so they always know where you are.
- 1Targets5 min
Those are the targets I'll design to. Next, the memory one request needs.
- 2Memory per request8 min
That's bytes per request and how many fit. Next, how we batch them.
- 3Batching8 min
That's how many run at once and the speed each gets. Now caching and drafting ahead.
- 4Caching and speculation8 min
Those are the savings and when they hold. Now the cost of one request.
- 5Cost per request8 min
That's the cost per request. Last, what breaks first.
- 6What breaks first8 min
That's the first failure and the guard for it. Where would you like more detail?
How people lose this round
Divide the GPU's memory by the model size to get the users.
The weights are only part of it. The cache left after them, and how long each user's context runs, set the number.Set the batch size where throughput peaks.
Throughput can keep rising while every request misses its latency target. The targets set the cap.Speculative decoding always makes it faster.
It uses spare compute, which a large batch doesn't have. Measure it on real prompts at real load.The prefix cache is on, so the system prompt is free.
Only if the shared text comes first and is identical every time. One timestamp at the top and nothing matches.Report the average latency.
A few long waits hide in an average. Give the median and the 99th percentile.
A worked answer
The notes in the margin mark where the candidate asked, put a number on it, took a hint or caught a slip.
- Interviewer
Design serving for a chat assistant on an 8B model. At peak, 10 new chats arrive a second.
- You
First the targets. How long are prompts and replies, and how fast must it feel?
Asks for targets before drawing boxes.
The rest of this answer comes with Pro.
Pro opens every worked answer, margin notes and all.