A field guide in 109 chapters

Inference engineering,
from scratch.

Learn why GPUs look the way they do, write the kernels an LLM runs, and understand the KV cache down to the byte. Then build a serving engine and run it at scale. Each idea gets an explanation, an animation and runnable code.

levels
4
levels
modules
18
modules
chapters
109
chapters
sources
8
sources

fig. 0: what a GPU does to write one word

  • Roofline✦
  • Arithmetic intensity✦
  • Warps & SIMT✦
  • Memory coalescing✦
  • Tiled GEMM✦
  • FlashAttention✦
  • KV cache✦
  • PagedAttention✦
  • Continuous batching✦
  • Chunked prefill✦
  • RadixAttention✦
  • Speculative decoding✦
  • FP8 · INT4✦
  • Tensor parallelism✦
  • Prefill/decode disaggregation✦
  • KV-aware routing✦
  • SLO goodput✦
  • Cost per million tokens✦

Where to start

Four levels, one path

New to all of this? Start at level 1. Already know some of it? Pick the level whose question you can't answer yet.

Try it

How fast can a GPU possibly talk?

To write each token, the GPU has to read every weight of the model from memory. Pick a model and a GPU to see the theoretical limit, then add users and watch the bottleneck move.

Model size

Weight precision

GPU

Per user

209tok/s

Whole GPU

209tok/s

Time for one decode step

Moving weights from memory4.78 ms
Doing the math0.016 ms

Memory-bound. The cores wait 99.7% of every step for weights. Add users: they ride along almost for free.

Upper bound: ignores the KV cache, attention and overheads. Real systems reach 50–80% of it. Derived in 0.1 and 3.3.

Four numbers to know

The facts the rest of the course explains

Myth vs fact

Six things most people get wrong about LLM speed

Tap a card to flip it. Each fact links to the chapter that proves it.

Myth #1

“A GPU with 2× the TFLOPS writes text 2× faster.”

↻Tap to flip
Actually…

Usually not. Single-user decode is memory-bound, so speed follows memory bandwidth (TB/s), not TFLOPS.

Learn why · 3.3 →
Myth #2

“Longer prompts make every output token slower.”

↻Tap to flip
Actually…

Mostly they delay the first token (prefill). Per-token speed barely moves; only the larger KV cache adds a little.

Learn why · 0.2 →
Myth #3

“Batching users together makes everyone slower.”

↻Tap to flip
Actually…

Until you reach the ridge point, extra users ride along on the same weight read. Throughput scales almost linearly.

Learn why · 3.3 →
Myth #4

“The model weights are what fill GPU memory.”

↻Tap to flip
Actually…

At long context the KV cache wins: one 128K-token Mistral 7B user needs 17 GB, more than the 14.5 GB of weights.

Learn why · 9.1 →
Myth #5

“Quantization only saves memory.”

↻Tap to flip
Actually…

In decode, fewer bytes per weight means fewer bytes moved per token, so it is also a direct speedup.

Learn why · 12.1 →
Myth #6

“With enough replicas, routing doesn’t matter.”

↻Tap to flip
Actually…

Sending a conversation back to the replica that already holds its KV cache skips re-running the whole prefix.

Learn why · 15.3 →

How you learn

The anatomy of a chapter

  1. ✎

    01Concept

    First principles in plain language, with the maths written out.

  2. ◐

    02Animation

    Simulators you can break: sliders, drags, step-throughs.

  3. ⌘

    03Code lab

    NumPy on a CPU first, then CUDA, Triton or vLLM where marked.

  4. §

    04Sources

    The repo, paper or book section each idea comes from.

  5. ?

    05Quiz

    Sharp questions, each with an explanation.

Built from open repos, papers and books

Start with one question: why is the GPU idle?

The answer leads through memory bandwidth, KV caches, batching and routing. That's the whole course.

  • repoBEFORE-GPU-ENGINEERING
  • coursetime-to-first-token
  • course100 Days of CUDA
  • blogvLLM Router release
  • blogLLM Inference at Scale
  • postAkshay Pachaar on X
  • paperFrom Inference Engine to Inference Control Plane
  • bookAI Systems Performance Engineering