Inference Engineering

A free, visual course in 14 lessons

An H100 does a thousand trillion operations a second. Llama 3.1 8B on it writes about 223 tokens a second for one user.

The gap is not a bug. It is the first thing to understand about serving language models, and this course starts there. It is for engineers who have called a model through an API and never had to run one. You need arithmetic, not a background in GPUs.

Start lesson 1See all 14 lessons

A fast clerk, a slow belt

Lesson 1 in one shot: why the chip waits. Real numbers for Llama 3.1 8B at 16 bits on one NVIDIA H100, slowed down so a few thousandths of a second can be seen. It plays by itself; press a stage to replay it, or drag to look around.

By the end

You will be able to do three things

  1. 223 tokens/s

    Predict speed from a spec sheet. Take a model's size and a GPU's memory bandwidth and work out the most tokens a second one user can get, before you rent anything.

  2. 52 conversations

    Size the memory. Work out how many 8,192-token conversations fit on one 80 GB GPU beside the model, and which fixes buy more room.

  3. 141 GB on 80 GB GPUs

    Serve a model that does not fit. The final exam is a Serving Lab challenge: Llama 3.1 70B on as few GPUs as you can, inside a latency promise.

How it works

One incident, one picture, one page

You are the first inference engineer at a small startup. Its chatbot, Parrot, runs Llama 3.1 8B on one H100. Every lesson opens with something going wrong, and answers it.

Every number on the site is computed from the published model and hardware figures by one tested module. The Serving Lab is a simulator where you run a whole server and try the challenges.

The course

14 lessons, in order

Part 1 One request

What a GPU does to write one reply, and what limits it.

  1. The roofline

    Incident: The fast GPU that types slowly

    Why is generating a token so much slower than the GPU’s FLOP rating suggests?

  2. What one token costs

    Incident: Where do 15 GB per token go?

    Where do the FLOPs and bytes of a forward pass actually go?

  3. Prefill and decode

    Incident: Slow to start, fast to type

    Why are time to first token and time per token two different problems?

Part 2 What the model remembers

The notes a model keeps, and how they fill the memory.

  1. The KV cache

    Incident: The memory alarm

    What does a model remember between tokens, and how much memory does it take?

  2. Shrinking the cache: MQA, GQA, MLA

    Incident: Should we switch models?

    How do newer attention designs cut KV memory without losing quality?

Part 3 Many users at once

Sharing one GPU between everyone who is waiting.

  1. Continuous batching

    Incident: Everyone waits for the slowest reply

    How do servers keep the GPU busy when requests start and stop at different times?

  2. Paged KV memory

    Incident: Full, but half empty

    Why did borrowing virtual memory from operating systems double serving throughput?

  3. Prefix caching

    Incident: The same 2,000 tokens, ten thousand times a day

    When can two requests share work, and why must prefixes match token for token?

Part 4 Doing less work

Three ways to get the same answer for fewer bytes or fewer steps.

  1. FlashAttention

    Incident: The long-document launch

    How do you compute attention without ever writing the attention matrix to memory?

  2. Quantization

    Incident: The GPU bill

    When does using fewer bits make inference faster, and when does it only save memory?

  3. Speculative decoding

    Incident: One user, twice as fast

    How can a small model make a big model generate faster without changing its output?

Part 5 Running it for real

Long prompts, models too big for one GPU, and proving it works.

  1. Chunked prefill and disaggregation

    Incident: One long prompt freezes everyone

    How do you stop long prompts from stalling everyone else’s tokens?

  2. Tensor and pipeline parallelism

    Incident: The model that does not fit

    How do you serve a model that does not fit on one GPU?

  3. Measuring a serving system

    Incident: Prove it

    What are TTFT, TPOT and goodput, and how do you benchmark them honestly?

The final exam

Serve a 70B model on the fewest H100s

Serve Llama 3.1 70B at 3 requests/s (about 1,000-token prompts, 256-token answers) with p99 time to first token under 0.5 s and p99 time per output token under 50 ms. Use as few GPUs as you can.

Open the challengeStart from lesson 1