Inference Engineering roadmap
Understand the path from trained model to served prediction, and the trade-offs between speed, memory, and cost.
7 parts · 18 modules · 168 lessons · Lessons being written
Lessons being written
Course overviewFoundations
Module 01: Inference engineering fundamentals
11 lessons- Introduction to inference engineering
- The inference stack: model, runtime, hardware, service
- Inference engineering roles: what the job involves
- Running an open model on your own machine
- Streaming tokens from your own model server
- GPU basics: memory, compute and utilization
- Inference arithmetic: memory, throughput and speedups
- Statistics for benchmarks: sampling and variance
- Transformers revisited: what matters for inference
- Lab: run a model and watch the GPU
- Design: serving an internal chatbot on one GPU
Module 02: How generation runs: prefill, decode and the KV cache
10 lessons- The forward pass: from tokens to logits
- Attention at inference time: queries, keys, values
- MLP, normalization and residual layers
- Sampling: turning scores into the next token
- Prefill and decode: two very different phases
- Recomputation: why generation repeats work
- KV cache: storing keys and values for reuse
- Model memory: weights, activations and KV cache
- KV memory budgets: context length vs concurrency
- Lab: build a KV cache in Python
Module 03: Measuring inference performance
10 lessons- Latency metrics: TTFT, TPOT and end-to-end
- Throughput and goodput: counting useful work
- Latency percentiles: p50, p95 and p99
- Workload shape: concurrency, rate and arrivals
- SLOs for model serving: targets users feel
- Benchmarking method: baselines and sweeps
- Finding the limits: saturation, SLO misses, OOM
- Prompt and output length: how they shift results
- Tuning GPU memory for KV cache capacity
- Lab: benchmark a model server end to end
Serving engines
Module 04: Inference servers and batching
10 lessons- Why a plain PyTorch loop can’t serve real traffic
- Anatomy of an inference server: one request’s path
- Serving APIs: OpenAI-compatible endpoints
- Static batching vs serving one request at a time
- Continuous batching: scheduling every iteration
- Scheduler limits: token budgets and batch sizes
- Fair scheduling: queues, cancellation, preemption
- Chunked prefill: keeping long prompts from blocking
- Lab: watch continuous batching in vLLM
- Design: a support chatbot on one GPU node
Module 05: KV cache management and prefix caching
11 lessons- Fragmentation: why contiguous KV memory wastes space
- PagedAttention: KV cache in fixed-size blocks
- Sharing and reclaiming KV blocks
- Memory pressure: preemption and recomputation
- Prefix caching: reusing work across requests
- RadixAttention: sharing prefixes in a tree
- Prefix reuse in RAG, agents and multi-turn chat
- KV offloading: CPU, SSD and remote memory
- Tiered KV storage: what to keep and what to evict
- Lab: find repeated prefix work and cache it
- Case: Mooncake, the KV cache store behind Kimi
Module 06: Quantization for inference
8 lessons- Number formats: FP32, BF16, FP8, INT8 and INT4
- Lower precision: what it saves and what it risks
- Weight quantization methods: GPTQ, AWQ, SmoothQuant
- Dequantization overhead in quantized matrix maths
- KV cache quantization: fitting more context
- Hardware support for low-precision formats
- Measuring quality loss after quantization
- Lab: quantize a model, compare speed and quality
GPU performance
Module 07: GPU performance fundamentals
8 lessons- GPU architecture: cores, memory levels and kernels
- Roofline model: finding what limits your speed
- Profiling workflow: measure before you optimize
- Profiling prefill and decode separately
- GPU execution model: threads, warps and blocks
- Triton: writing GPU kernels in Python
- Fast memory access patterns in GPU kernels
- Lab: profile a model and find the bottleneck
Module 08: Attention kernels and compilation
9 lessons- Attention’s memory problem at long lengths
- Tiling attention with an online softmax
- FlashAttention: attention without the memory traffic
- Why prefill and decode need different kernels
- Attention backends in serving engines
- Eager execution overhead in PyTorch
- torch.compile: fusing kernels automatically
- When compilation fails: changing input shapes
- CUDA graphs: recording work to replay cheaply
Module 09: Speculative decoding
8 lessons- Sequential decode: the speed limit of generation
- Speculative decoding: draft fast, verify in parallel
- Acceptance rate and draft length tradeoffs
- Speculation under load: when it stops helping
- Draft-free speculation: n-grams and prompt lookup
- Self-speculation: extra heads such as Medusa and EAGLE
- Adaptive speculation: changing the draft on the fly
- Lab: measure speculative decoding speedups
Scaling and advanced serving
Module 10: Multi-GPU inference
8 lessons- Scaling out: signs one GPU is no longer enough
- GPU interconnects: PCIe, NVLink and NCCL
- Data parallelism: adding model replicas
- Tensor parallelism: splitting each layer across GPUs
- Pipeline parallelism: splitting the model into stages
- Context parallelism for very long sequences
- Collective operations and their communication cost
- Lab: plan a multi-GPU deployment with a simulator
Module 11: Advanced serving: MoE, long context, disaggregation
11 lessons- Mixture of experts at inference: unlike dense models
- Expert routing and which experts run
- Spreading experts across GPUs
- Busy experts: balancing uneven expert load
- Very long prompts: where prefill time goes
- Measuring how performance scales with context
- Prefill–decode disaggregation: separate worker pools
- Sizing and routing prefill and decode pools
- Moving the KV cache from prefill to decode workers
- Design: serving a long-context model at scale
- Case: how DeepSeek serves V3 and R1
Production and cost
Module 12: Running inference in production
13 lessons- Cold starts: loading weights and warming caches
- Serving many models and many replicas
- Taking servers out of rotation safely
- Safe model rollouts: canary, shadow and rollback
- Smart routing: queue-aware and cache-aware
- Autoscaling on tokens, queues and GPU pressure
- Keeping spare GPUs warm for traffic spikes
- Overload control: admission and load shedding
- Request controls: deadlines, retries and priorities
- Inference metrics: GPU, scheduler and cache
- Tracing requests through the inference stack
- Recovering from OOM, worker and GPU failures
- Securing inference APIs: tenants and models
Module 13: Cost and capacity planning
9 lessons- Cost per million tokens: what you really pay
- Goodput per dollar: the number that matters
- From benchmarks to a capacity plan
- Comparing GPUs on price and performance
- Headroom: peaks, failures and idle GPUs
- APIs, managed endpoints or self-hosting
- Buying GPU capacity: on-demand, reserved and spot
- Case: how Character.AI cut its serving costs
- Design: a capacity plan for 10 million requests a day
Engines and workloads
Module 14: Engines and hardware landscape
8 lessons- vLLM and SGLang: two engine designs compared
- Engine features side by side: KV, kernels, quantization
- TensorRT-LLM: optimizing for NVIDIA hardware
- llama.cpp and lightweight runtimes
- Beyond NVIDIA: AMD, TPUs and custom accelerators
- On-device inference: phones and laptops
- Serving embedding and reranking models
- Choosing an engine for your workload
Module 15: Special workloads
9 lessons- Constrained decoding for structured output and tools
- Multi-LoRA serving: many fine-tunes on one GPU
- Serving models that read images
- Agent and multi-turn workloads
- Reasoning models: serving very long outputs
- Batch inference: trading latency for throughput
- Rollouts for reinforcement learning
- Diffusion model inference: steps and quality
- Speech model inference: streaming recognition and voice
Module 16: Inside an inference engine
9 lessons- Reading the vLLM codebase: a guided map
- Tracing one request through vLLM’s code
- The scheduler and request state in code
- KV block management in code
- Model execution and attention dispatch in code
- Lab: a minimal engine with a generation loop
- Lab: adding continuous batching to your engine
- Lab: paging the KV cache in your engine
- Lab: adding prefix caching and metrics
Research, capstone and interviews
Module 17: Research and capstone
8 lessons- Reading an inference systems paper critically
- Rebuilding a paper’s baseline
- Reproducing a paper’s headline result
- Ablations: what each part of a technique adds
- Stress-testing a technique until it breaks
- Capstone part 1: specifying the service
- Capstone part 2: hardware and software choices
- Capstone part 3: scaling and serving architecture
Module 18: Inference engineering interviews
8 lessons- Inference engineering interviews: what gets tested
- Explaining prefill, decode and the KV cache clearly
- Inference maths under interview pressure
- Inference system design interviews: a framework
- Debugging scenarios: latency spikes and OOMs
- Common mistakes in inference interviews
- Mock interview: a chatbot for a million users
- Mock interview: halving the cost of inference