- Learn
- Artificial Intelligence
- LLM Inference and Serving
AI-M11
LLM Inference and Serving
What happens when a model answers: prefill and decode, GPU memory, batching, quantization, speculative decoding, routing for cost and streaming to users.
A model that works in a notebook still has to answer thousands of people quickly and at a cost that makes sense. Serving is where that happens, and it follows a few physical limits: how fast the chip can move bytes from memory, how much memory it has, and how many users can share each step.
You will start with the two phases of generation and the latency numbers users feel, then do the memory arithmetic that decides how many requests fit on a GPU. From there you will see how servers keep the GPU busy with continuous batching and paged KV caches, how quantization and speculative decoding make each step cheaper, how routing and caching cut the bill, and how streaming makes a slow answer feel fast.
Lessons
- AI-11.01 How LLM inference works Generating a response has two phases. Intermediate 14 min
- AI-11.02 GPU memory math Serving memory is dominated by model weights and the KV cache. Intermediate 12 min
- AI-11.03 Batching and PagedAttention Static batching waits for a whole batch to finish, wasting GPU time when responses have different lengths. Advanced 14 min
- AI-11.04 Quantization for inference Quantization stores weights, and sometimes activations, in fewer bits, such as 8 or 4 instead of 16. Advanced 12 min
- AI-11.05 Speculative decoding and other speedups Speculative decoding uses a small, fast draft model to propose several tokens, which the large model verifies in one parallel pass; accepted tokens come almost for free, and the output distribution is unchanged. Advanced 12 min
- AI-11.06 Routing, cascades and cost optimization Not every request needs the biggest model. Intermediate 10 min
- AI-11.07 Streaming responses to users Streaming sends tokens to the user as they are generated, usually over Server-Sent Events, so the interface feels fast even when the full answer takes seconds. Beginner 8 min