cd /news/ai-infrastructure/inference-engineering-from-scratch · home › topics › ai-infrastructure › article
[ARTICLE · art-182301] src=ai-inference-engineering-from-scrat.vercel.app ↗ pub= topic=ai-infrastructure verified=true sentiment=↑ positive

Inference Engineering, from Scratch

A new 119-chapter field guide, "Inference Engineering, from Scratch," teaches developers to write GPU kernels, understand the KV cache down to the byte, and build and scale a serving engine, spanning 4 levels, 18 modules and 9 sources. The course's interactive demo shows a single-user decode step is memory-bound, with GPU cores waiting 99.7% of every step for weights, and its chapter 6.1 measures a naive matmul kernel on an RTX 3050 Laptop GPU running 60× slower than cuBLAS. The guide also notes that one 128K-token Mistral 7B user needs 17 GB of KV cache, more than the model's 14.5 GB of weights.

recommendation

Optimize single-user decode for memory bandwidth rather than TFLOPS, and budget KV cache memory separately from weights: one 128K-token Mistral 7B user needs 17 GB versus 14.5 GB of weights.

more in playbook: Inference and self-hosting
read4 min views5 publishedDec 5, 2026
Inference Engineering, from Scratch
Image: source

A field guide in 119 chapters

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
  • 119
  • chapters
  • sources
  • 9
  • 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✦

Watch · 22 seconds, sound on

A chapter, in 22 seconds #

Chapter 6.1, recorded on this site: the naive matmul kernel, the interactive tiling figure clicked live, and themeasured output from an RTX 3050 Laptop GPU. A naive kernel is 60× slower than cuBLAS; the chapter shows why, and how to close the gap.

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.

[Full roadmap →](https://ai-inference-engineering-from-scrat.vercel.app/roadmap)

[121 chaptersBeginnerWhat is inference, and why is it hard?](https://ai-inference-engineering-from-scrat.vercel.app/learn/m00/what-is-inference-engineering)
  • M0Orientation
  • M1The LLM forward pass, for inference engineers
  • M2Why GPUs: hardware first principles
  • M3The performance mental model

238 chaptersIntermediateHow do I write and optimize GPU code?

  • M4CUDA programming fundamentals
  • M5Parallel patterns
  • M6GEMM and memory optimization
  • M7Profiling: measure, don't guess
  • M8Transformer kernels and compilers

337 chaptersAdvancedHow do I build and tune a serving engine?

  • M9KV cache engineering
  • M10Serving engine internals
  • M11Decoding and sampling
  • M12Quantization for inference
  • M13Measurement and benchmarking

423 chaptersExpertHow do I run inference at scale?

  • M14Multi-GPU inference and parallelism
  • M15Distributed serving and routing
  • M16Economics and the inference control plane
- CCapstone: ship one service

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

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.

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

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

Learn why · 3.3 → “Longer prompts make every output token slower.”

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

Learn why · 0.2 → “Batching users together makes everyone slower.”

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

Learn why · 3.3 → “The model weights are what fill GPU memory.”

↻Tap to flip 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 → “Quantization only saves memory.”

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

Learn why · 12.1 → “With enough replicas, routing doesn’t matter.”

↻Tap to flip 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
  • repoAI Inference Resources
── more in #ai-infrastructure 4 stories · sorted by recency
── more on @inference engineering, from scratch 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/inference-engineerin…] indexed:0 read:4min 2026-12-05 · —