Serving Models: GPUs, Batching, and Streaming
Trace an inference request and examine latency, memory, and throughput.
generative ai, serving, gpu, batching, streamingFollow an inference request
A serving system accepts a request, checks authorization and limits, and schedules it on available compute. A GPU is specialised for parallel numerical work and has finite device memory. The inference engine manages model execution, token generation and often a key-value cache.
Prefill and decode
- The server tokenises the prompt and processes its input context (prefill).
- During decoding it generates tokens using the context and prior output; a KV cache avoids some repeated work but consumes memory.
- The server streams tokens as available, then records an outcome without logging unnecessary sensitive content.
See the reasoning
Follow an inference request
Distinguish prefill, decoding, and streaming. This is a prepared demonstration, not live code execution.
Prefill
- InputTokenise and process promptCurrent focus
- DecodeWaiting
- StreamNo output yet
The engine processes the prompt context.
Batch and observe
Batching can improve hardware utilisation and throughput but waiting for a batch can increase latency. Continuous batching can admit and retire requests at different times; exact behaviour depends on the engine. Measure time to first token, total latency, tokens per second, queue depth, memory, errors and cost for representative input and output lengths. Streaming is a delivery choice, not a guarantee of correct or safe output.
Reflect on the concept
Four fixed questions to reinforce the reasoning. Answers are not saved or scored.
