LLM Inference | For You

LLM Inference | For You

A course about how large language models are served. It is built on the open textbook “LLM Inference Systems: Principles, Mathematics, and Practice” and redesigned here as interactive lecture-blogs you can study on your own, at your pace.

convenience

Easy to find, learn or recap the material: every lecture carries its derivations, worked numbers, and pitfalls with it.

clarity

Each page is a result of care not only about what to say, but how to say and, especially, how to show something.

you

These materials exist so that you (yes, you!) could study what you like, at your pace. The purpose is to help you enter your own very personal adventure. For you.

A Guide to Your Adventure

Lecture-blogs

Which we tried to make: intuitive, clear and engaging; complete (the full lecture and more); and honest about trade-offs, because in serving there is no single right answer, only workloads. Each lecture carries Research Thinking cards, worked numeric examples, and a Have Fun! corner.

Research Thinking

Learn to think as a systems researcher: find the flaw in an approach, think why/when something can help, come up with ways to improve, then look at previous attempts.

It is well-known that you learn something easier if you are not given the answer right away, but think about it first. In every card you will see ? a question. Think about it for a minute, a day, a week... and only then open the possible answers. You are not supposed to reinvent a paper that took its authors months; it's the habit of thinking that counts.

Interactive parts

Often we ask you to walk through a figure step by step, to play with a small playground, or just to think with a pen. The roofline is only truly yours after you've derived it once with your own numbers. Lecture 1's playground is a good place to start.

What's inside: the course map

One spine, nine lectures. The spine is the decode arithmetic intensity \(I \approx \frac{2PB}{2P + B\cdot kv}\) from Lecture 1. Every later lecture is an intervention on one of its terms.

1Principles, Metrics, and the Roofline

  • Prefill vs decode: two different machines
  • KV cache: legal, minimal, costly to lose
  • The 2P rule, the roofline, decode intensity
  • TTFT / TPOT / ITL / goodput, benchmarking honestly
✎ 3 research cards♟ playground⚒ lab 1

2Systems Centered on the KV Cache

  • PagedAttention: virtual memory for KV
  • Prefix caching across requests
  • Tiered storage: swap vs recompute
  • MLA: architectural compression; hybrid states
✎ research cards⚒ lab 2

3Long Context and Sparse Attention

  • The changing cost structure of long context
  • NSA → DSA → hybrid architectures
  • Reading a subset of the past
✎ research cards⚒ lab 3

4Batching and Scheduling

  • Static batching's two misalignments
  • Continuous batching, iteration-level scheduling
  • Chunked prefill; admission & preemption
✎ research cards⚒ lab 4

5Prefill–Decode Disaggregation

  • Why one pool cannot satisfy two SLOs
  • KV transfer cost
  • Sizing the pools; the Mooncake form
✎ research cards⚒ lab 5

6Parallelism: DP, TP, PP, EP, CP & MoE at Scale

  • TP: buy TPOT with all-reduces
  • EP: turning sparsity into bandwidth
  • Prefill CP and decode CP: sharding a single sequence
✎ research cards⚒ lab 6

7The Kernel Level: Attention and MoE

  • The GPU execution model essentials
  • From O(L²) traffic to FlashAttention and beyond
  • Grouped GEMM; launches, graphs, fusion
✎ research cards⚒ lab 7

8MTP and Speculative Decoding

  • Why verification is almost free
  • An exact algorithm: the accept/reject rule
  • Draft sources; interaction with the system
✎ research cards⚒ lab 8

9Frameworks, Evolution, and New Workloads

  • The serving-framework landscape
  • Four lines of evolution
  • RL rollout: the third workload class
✎ research cards⚒ lab 9
To be continued... Seminars, labs and exams from the source course are summarized at the end of each lecture under “Seminar & Homework”.