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