Domain

LLM Systems

How language models are served: prefill and decode, KV-cache memory, batching and scheduling, decoding rules, and techniques such as speculative decoding that cut latency.

5 notebooks5 demos
Preview the recommended route
First notebookDecoding & Sampling: Temperature, Top-p & Inference-Time Control

Start here. Make one prediction, then note what carries over to the next notebook.

tokensKVbatchlatency
Open first notebook
QuestionWhat carries over from Decoding & Sampling into LLM Serving at Scale?
PredictionBefore opening the first demo, predict which quantity changes first.
Demos5 interactive demos in this domain
Before moving onSay in one sentence how the idea works before going to the next notebook.
LearnerWhich notebook should I read first?

Read the first notebook, make one prediction in its demo, then go on to the next.

Open the first notebook

Recommended route

Read these in order: each notebook comes after the notebooks in this domain that it builds on, and the label beside it gives its level. A prerequisite with no page here yet is marked as outside reading. A notebook is left out of the route only when a prerequisite has neither a page here nor a named outside reading; the full list below marks it.

  1. 01
    Decoding & Sampling: Temperature, Top-p & Inference-Time Control

    How decoding settings reshape the next-token distribution before a token is drawn: temperature, nucleus (top-p) sampling, and why the decoding rule changes what a model writes.

    Intermediate16 mincodedemoafter Maximum Likelihood, Scaled Dot-Product Attention & Transformer Layers
  2. 02
    LLM Serving at Scale: Prefill, Decode & Continuous Batching

    How LLM inference is served: prefill and decode, time to first token and time per output token, batching and scheduling, and why KV-cache memory often limits batch size.

    Advanced22 mincodedemoafter Scaled Dot-Product Attention & Transformer Layers, Efficient Attention at Scale: KV Cache, GQA & FlashAttention
  3. 03
    Structured Decoding: Token Masks From Schema Automata

    How a schema automaton or parser state turns next-token logits into constraint-valid generation by masking invalid continuations, while leaving truth and task success outside the formal guarantee.

    Advanced22 mincodedemoafter Decoding & Sampling: Temperature, Top-p & Inference-Time Control, Tokenization & Vocabulary Design
  4. 04
    Speculative Decoding: Lossless Multi-Token Generation

    Draft several tokens with a fast model, score all the draft prefixes with the target model in one parallel pass, then use modified rejection sampling so the output distribution matches the target model's.

    Advanced18 mincodedemoafter Maximum Likelihood, Scaled Dot-Product Attention & Transformer Layers, LLM Serving at Scale: Prefill, Decode & Continuous Batching
  5. 05
    MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism

    Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.

    Advanced20 mincodedemoafter Scaled Dot-Product Attention & Transformer Layers, Efficient Attention at Scale: KV Cache, GQA & FlashAttention, LLM Serving at Scale: Prefill, Decode & Continuous Batching

All notebooks

Every published notebook in this domain.