Stage 1 — Core Concepts
You can look at a model card and a GPU spec and estimate whether it will fit, and how many concurrent requests you'll get. · ~1 week
Stage 0 ended with an arithmetic identity you derived on a laptop:
max concurrent seqs = (KV cache bytes available) ÷ (KV bytes per token) ÷ max_model_len
Three quantities, and Stage 0 handed you the first one — it's the memory left after the weights. This stage explains the other two, and then explains what the engine does with the capacity that results.
The pages are in dependency order and it is a strict one:
- The KV cache is the scarce resource. Understand what it is and you can compute
KV bytes per tokenfor any model from its config file. - Prefill and decode are the two phases that consume it, and they behave nothing alike — which is why a single "tokens per second" number is almost always misleading.
- PagedAttention is how vLLM allocates that resource without wasting most of it.
- Continuous batching is what efficient allocation makes possible: keeping the batch full.
- Sampling parameters are the per-request settings that change how much of all of the above a single request consumes.
The last one is here, rather than filed with the API documentation where most guides put it, for a
specific reason: max_tokens and n are not formatting preferences. They are memory reservations,
and you can't reason about a batch until you know that.
Pages
| # | Topic | What it covers | Status |
|---|---|---|---|
| 1 | The KV Cache | Why generation re-reads the whole prompt without it; the memory formula and how to compute it for a real model; why it, not the weights, is the constraint | 🚧 |
| 2 | Prefill vs Decode | The two phases and why they behave nothing alike; compute-bound versus memory-bandwidth-bound; TTFT, ITL and TPOT defined | 🚧 |
| 3 | PagedAttention | The OS virtual-memory analogy, then the real thing: blocks, block tables, internal versus external fragmentation, copy-on-write for shared prefixes | 🚧 |
| 4 | Continuous Batching | Static batching and its convoy problem; iteration-level scheduling; the chef who never lets the pass go empty; the workloads where it changes nothing | 🚧 |
| 5 | Sampling Parameters | temperature, top_p, top_k, max_tokens, stop, seed, n — what each does to the distribution, and what each costs the scheduler |
🚧 |
What you'll be able to do by the end
- Compute KV cache cost per token for any model from its
config.json, and explain why two models with identical parameter counts can differ several-fold. - Predict roughly how many concurrent users a given GPU will support, before renting one.
- Explain why your server's throughput and its per-user speed are different numbers that move in opposite directions.
- Read a
SamplingParamsobject and say what it costs the scheduler, not just what it does to the text.
Nothing here requires a GPU except the optional measurement in The KV Cache, which confirms the formula empirically and is worth running on a Colab T4 if you have one.