Inference and Serving: Running AI Models Fast, Cheaply and Reliably
Serving models fast, cheaply and reliably.
Advanced3 lessons5 questions
What this module covers
The techniques that make serving faster and cheaper, and what each trades away
Setting latency and availability targets customers can rely on
Planning GPUGraphics processing unit. The chips most AI models are trained and served on. Read the full explanation capacity and cost against uncertain demand
AI Infrastructure PMProduct Manager. Decides what a product should do, for whom, and why. Read the full explanation: this is your specialism.
AI TPMTechnical Program Manager. Owns plans, dependencies, risks and delivery for large cross-team programmes. Read the full explanation: capacity and deployment programmes build on it.
AI Platform PM: your rate limits and pricing depend on it.
Serving a model efficiently uses several techniques together:
Technique
What it does
Trade-off
Continuous batching
Adds and removes requests from the running batch as they arrive and finish
Higher throughput; some per-request latency
KV cacheKey-value cache. Stored attention keys and values that let a model generate each new token without recomputing the whole context. Read the full explanation management
Stores attention data efficiently and reuses shared prompt prefixes
Memory complexity
Quantisation
Uses lower-precision numbers for weights
Less memory and faster; possible quality loss
Speculative decoding
A small model drafts tokens; the large model checks several at once
Faster output when drafts are often right
Parallelism across GPUs
Splits a large model over several GPUs
Needed for big models; adds communication overhead
An infrastructure PM doesn't implement these, but must know what each buys and costs, because they decide which to prioritise.
Latency and availability targets
Customers need promises they can build on. Typical targets:
Time to first token: how quickly a response starts, for example under one second at the 95th percentile.
Output speed: tokens per second once generating.
Availability: share of requests that succeed, for example 99.9% per month.
Error budget: the failures allowed by the availability target, used to decide when to slow down releases.
Set targets per product tier: interactive chat needs fast first tokens; batch processing needs throughput and low cost, not speed. Measure at high percentiles, not averages; users remember the slow requests.
Capacity and cost planning
GPU capacity is expensive and slow to add, so planning matters:
Forecast demand: tokens per second at peak, by model, with a range not a single number.
Convert to GPUs: peak demand ÷ throughput per GPU at your latency target, plus headroom for failures and spikes.
Choose how to buy: reserved capacity (cheaper, committed) for the base; on-demand or burst for peaks.
Raise utilisation: share capacity across products, run batch work in quiet hours, scale down idle models.
Track cost per million tokens by model, and feed it into pricing.
The core tension: too little capacity means outages and rate limits; too much means idle, very expensive hardware.