internalsGet Pro

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
    1. Introduction to inference engineeringFree (coming soon)
    2. The inference stack: model, runtime, hardware, serviceFree (coming soon)
    3. Inference engineering roles: what the job involves (coming soon)
    4. Running an open model on your own machineFree (coming soon)
    5. Streaming tokens from your own model server (coming soon)
    6. GPU basics: memory, compute and utilizationFree (coming soon)
    7. Inference arithmetic: memory, throughput and speedupsFree (coming soon)
    8. Statistics for benchmarks: sampling and variance (coming soon)
    9. Transformers revisited: what matters for inference (coming soon)
    10. Lab: run a model and watch the GPU (coming soon)
    11. Design: serving an internal chatbot on one GPU (coming soon)
  • 02How generation runs: prefill, decode and the KV cache10 lessons
    1. The forward pass: from tokens to logits (coming soon)
    2. Attention at inference time: queries, keys, values (coming soon)
    3. MLP, normalization and residual layers (coming soon)
    4. Sampling: turning scores into the next token (coming soon)
    5. Prefill and decode: two very different phases (coming soon)
    6. Recomputation: why generation repeats work (coming soon)
    7. KV cache: storing keys and values for reuse (coming soon)
    8. Model memory: weights, activations and KV cache (coming soon)
    9. KV memory budgets: context length vs concurrency (coming soon)
    10. Lab: build a KV cache in Python (coming soon)
  • 03Measuring inference performance10 lessons
    1. Latency metrics: TTFT, TPOT and end-to-endFree (coming soon)
    2. Throughput and goodput: counting useful work (coming soon)
    3. Latency percentiles: p50, p95 and p99 (coming soon)
    4. Workload shape: concurrency, rate and arrivals (coming soon)
    5. SLOs for model serving: targets users feel (coming soon)
    6. Benchmarking method: baselines and sweeps (coming soon)
    7. Finding the limits: saturation, SLO misses, OOM (coming soon)
    8. Prompt and output length: how they shift results (coming soon)
    9. Tuning GPU memory for KV cache capacity (coming soon)
    10. Lab: benchmark a model server end to end (coming soon)

Serving engines

3 modules · 29 lessons

  • 04Inference servers and batching10 lessons
    1. Why a plain PyTorch loop can’t serve real traffic (coming soon)
    2. Anatomy of an inference server: one request’s path (coming soon)
    3. Serving APIs: OpenAI-compatible endpoints (coming soon)
    4. Static batching vs serving one request at a time (coming soon)
    5. Continuous batching: scheduling every iteration (coming soon)
    6. Scheduler limits: token budgets and batch sizes (coming soon)
    7. Fair scheduling: queues, cancellation, preemption (coming soon)
    8. Chunked prefill: keeping long prompts from blocking (coming soon)
    9. Lab: watch continuous batching in vLLM (coming soon)
    10. Design: a support chatbot on one GPU node (coming soon)
  • 05KV cache management and prefix caching11 lessons
    1. Fragmentation: why contiguous KV memory wastes space (coming soon)
    2. PagedAttention: KV cache in fixed-size blocks (coming soon)
    3. Sharing and reclaiming KV blocks (coming soon)
    4. Memory pressure: preemption and recomputation (coming soon)
    5. Prefix caching: reusing work across requests (coming soon)
    6. RadixAttention: sharing prefixes in a tree (coming soon)
    7. Prefix reuse in RAG, agents and multi-turn chat (coming soon)
    8. KV offloading: CPU, SSD and remote memory (coming soon)
    9. Tiered KV storage: what to keep and what to evict (coming soon)
    10. Lab: find repeated prefix work and cache it (coming soon)
    11. Case: Mooncake, the KV cache store behind Kimi (coming soon)
  • 06Quantization for inference8 lessons
    1. Number formats: FP32, BF16, FP8, INT8 and INT4 (coming soon)
    2. Lower precision: what it saves and what it risks (coming soon)
    3. Weight quantization methods: GPTQ, AWQ, SmoothQuant (coming soon)
    4. Dequantization overhead in quantized matrix maths (coming soon)
    5. KV cache quantization: fitting more context (coming soon)
    6. Hardware support for low-precision formats (coming soon)
    7. Measuring quality loss after quantization (coming soon)
    8. Lab: quantize a model, compare speed and quality (coming soon)

GPU performance

3 modules · 25 lessons

  • 07GPU performance fundamentals8 lessons
    1. GPU architecture: cores, memory levels and kernels (coming soon)
    2. Roofline model: finding what limits your speed (coming soon)
    3. Profiling workflow: measure before you optimize (coming soon)
    4. Profiling prefill and decode separately (coming soon)
    5. GPU execution model: threads, warps and blocks (coming soon)
    6. Triton: writing GPU kernels in Python (coming soon)
    7. Fast memory access patterns in GPU kernels (coming soon)
    8. Lab: profile a model and find the bottleneck (coming soon)
  • 08Attention kernels and compilation9 lessons
    1. Attention’s memory problem at long lengths (coming soon)
    2. Tiling attention with an online softmax (coming soon)
    3. FlashAttention: attention without the memory traffic (coming soon)
    4. Why prefill and decode need different kernels (coming soon)
    5. Attention backends in serving engines (coming soon)
    6. Eager execution overhead in PyTorch (coming soon)
    7. torch.compile: fusing kernels automatically (coming soon)
    8. When compilation fails: changing input shapes (coming soon)
    9. CUDA graphs: recording work to replay cheaply (coming soon)
  • 09Speculative decoding8 lessons
    1. Sequential decode: the speed limit of generation (coming soon)
    2. Speculative decoding: draft fast, verify in parallel (coming soon)
    3. Acceptance rate and draft length tradeoffs (coming soon)
    4. Speculation under load: when it stops helping (coming soon)
    5. Draft-free speculation: n-grams and prompt lookup (coming soon)
    6. Self-speculation: extra heads such as Medusa and EAGLE (coming soon)
    7. Adaptive speculation: changing the draft on the fly (coming soon)
    8. Lab: measure speculative decoding speedups (coming soon)

Scaling and advanced serving

2 modules · 19 lessons

  • 10Multi-GPU inference8 lessons
    1. Scaling out: signs one GPU is no longer enough (coming soon)
    2. GPU interconnects: PCIe, NVLink and NCCL (coming soon)
    3. Data parallelism: adding model replicas (coming soon)
    4. Tensor parallelism: splitting each layer across GPUs (coming soon)
    5. Pipeline parallelism: splitting the model into stages (coming soon)
    6. Context parallelism for very long sequences (coming soon)
    7. Collective operations and their communication cost (coming soon)
    8. Lab: plan a multi-GPU deployment with a simulator (coming soon)
  • 11Advanced serving: MoE, long context, disaggregation11 lessons
    1. Mixture of experts at inference: unlike dense models (coming soon)
    2. Expert routing and which experts run (coming soon)
    3. Spreading experts across GPUs (coming soon)
    4. Busy experts: balancing uneven expert load (coming soon)
    5. Very long prompts: where prefill time goes (coming soon)
    6. Measuring how performance scales with context (coming soon)
    7. Prefill–decode disaggregation: separate worker pools (coming soon)
    8. Sizing and routing prefill and decode pools (coming soon)
    9. Moving the KV cache from prefill to decode workers (coming soon)
    10. Design: serving a long-context model at scale (coming soon)
    11. Case: how DeepSeek serves V3 and R1 (coming soon)

Production and cost

2 modules · 22 lessons

  • 12Running inference in production13 lessons
    1. Cold starts: loading weights and warming caches (coming soon)
    2. Serving many models and many replicas (coming soon)
    3. Taking servers out of rotation safely (coming soon)
    4. Safe model rollouts: canary, shadow and rollback (coming soon)
    5. Smart routing: queue-aware and cache-aware (coming soon)
    6. Autoscaling on tokens, queues and GPU pressure (coming soon)
    7. Keeping spare GPUs warm for traffic spikes (coming soon)
    8. Overload control: admission and load shedding (coming soon)
    9. Request controls: deadlines, retries and priorities (coming soon)
    10. Inference metrics: GPU, scheduler and cache (coming soon)
    11. Tracing requests through the inference stack (coming soon)
    12. Recovering from OOM, worker and GPU failures (coming soon)
    13. Securing inference APIs: tenants and models (coming soon)
  • 13Cost and capacity planning9 lessons
    1. Cost per million tokens: what you really pay (coming soon)
    2. Goodput per dollar: the number that matters (coming soon)
    3. From benchmarks to a capacity plan (coming soon)
    4. Comparing GPUs on price and performance (coming soon)
    5. Headroom: peaks, failures and idle GPUs (coming soon)
    6. APIs, managed endpoints or self-hosting (coming soon)
    7. Buying GPU capacity: on-demand, reserved and spot (coming soon)
    8. Case: how Character.AI cut its serving costs (coming soon)
    9. Design: a capacity plan for 10 million requests a day (coming soon)

Engines and workloads

3 modules · 26 lessons

  • 14Engines and hardware landscape8 lessons
    1. vLLM and SGLang: two engine designs compared (coming soon)
    2. Engine features side by side: KV, kernels, quantization (coming soon)
    3. TensorRT-LLM: optimizing for NVIDIA hardware (coming soon)
    4. llama.cpp and lightweight runtimes (coming soon)
    5. Beyond NVIDIA: AMD, TPUs and custom accelerators (coming soon)
    6. On-device inference: phones and laptops (coming soon)
    7. Serving embedding and reranking models (coming soon)
    8. Choosing an engine for your workload (coming soon)
  • 15Special workloads9 lessons
    1. Constrained decoding for structured output and tools (coming soon)
    2. Multi-LoRA serving: many fine-tunes on one GPU (coming soon)
    3. Serving models that read images (coming soon)
    4. Agent and multi-turn workloads (coming soon)
    5. Reasoning models: serving very long outputs (coming soon)
    6. Batch inference: trading latency for throughput (coming soon)
    7. Rollouts for reinforcement learning (coming soon)
    8. Diffusion model inference: steps and quality (coming soon)
    9. Speech model inference: streaming recognition and voice (coming soon)
  • 16Inside an inference engine9 lessons
    1. Reading the vLLM codebase: a guided map (coming soon)
    2. Tracing one request through vLLM’s code (coming soon)
    3. The scheduler and request state in code (coming soon)
    4. KV block management in code (coming soon)
    5. Model execution and attention dispatch in code (coming soon)
    6. Lab: a minimal engine with a generation loop (coming soon)
    7. Lab: adding continuous batching to your engine (coming soon)
    8. Lab: paging the KV cache in your engine (coming soon)
    9. Lab: adding prefix caching and metrics (coming soon)

Research, capstone and interviews

2 modules · 16 lessons

  • 17Research and capstone8 lessons
    1. Reading an inference systems paper critically (coming soon)
    2. Rebuilding a paper’s baseline (coming soon)
    3. Reproducing a paper’s headline result (coming soon)
    4. Ablations: what each part of a technique adds (coming soon)
    5. Stress-testing a technique until it breaks (coming soon)
    6. Capstone part 1: specifying the service (coming soon)
    7. Capstone part 2: hardware and software choices (coming soon)
    8. Capstone part 3: scaling and serving architecture (coming soon)
  • 18Inference engineering interviews8 lessons
    1. Inference engineering interviews: what gets testedFree (coming soon)
    2. Explaining prefill, decode and the KV cache clearly (coming soon)
    3. Inference maths under interview pressure (coming soon)
    4. Inference system design interviews: a framework (coming soon)
    5. Debugging scenarios: latency spikes and OOMs (coming soon)
    6. Common mistakes in inference interviews (coming soon)
    7. Mock interview: a chatbot for a million users (coming soon)
    8. Mock interview: halving the cost of inference (coming soon)