Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Token | A piece of text the model reads or writes, roughly three-quarters of an English word (12.b). |
| KV cache | Saved attention results for every token a request has seen, kept in GPU memory so earlier tokens are never recomputed (12.e). |
| Page | In an operating system, a small fixed-size piece of memory (often 4 KiB) handed to a program only when it needs it. |
| Block | vLLM’s page: room for the KV cache of a fixed number of tokens (16 by default). |
| Block table | For one request, the list of block numbers that hold its KV cache, in order. |
| Continuous batching | Re-deciding which requests run on every step, so a new request can join the moment another finishes (12.j). |
| Commit / tag | A commit is one saved version of a code repository, named by a hash such as 5df63a7. A tag is a human name for one commit, such as v0.32.0. |
1. What is it?#
A language model produces text one token at a time. Every request therefore needs the GPU thousands of times in a row, and every request keeps a growing pile of intermediate results (its KV cache) in GPU memory while it does so. An inference engine decides, many times a second, which requests get the GPU next and where each request’s memory lives (15.a).
vLLM is the most widely used open-source inference engine. It is a Python program with C++, CUDA and (in an optional frontend) Rust inside it. It loads a model from Hugging Face, exposes the same HTTP API as OpenAI, and pushes far more requests through one GPU than a naive loop can.
It began with one idea (treat the GPU memory requests use the way an operating system treats RAM, in small fixed-size pages) and everything else grew around that idea.
Modules 16–19 read vLLM from its source. Everything quoted was read at tag v0.32.0
(commit 5df63a7, 17 October 2026; released 18 October 2026). Facts checked on
12 November 2026.
flowchart LR
U[":i-users: <b>Many clients</b><br/><small>chat apps, agents, batch jobs</small>"] -->|"HTTP, OpenAI format"| API[":vllm: <b>API server</b><br/><small>tokenise, validate, stream</small>"]
API -->|"token IDs"| ENG[":vllm: <b>Engine core</b><br/><small>scheduler + KV cache manager</small>"]
ENG -->|"this step's batch"| W[":pytorch: <b>GPU worker</b><br/><small>runs the model</small>"]
W --> GPU[":nvidia: <b>GPU</b><br/><small>weights + KV cache blocks</small>"]
W -->|"one new token per request"| ENG
ENG -->|"new tokens"| API
API -->|"text, streamed"| U
HF[(":huggingface: <b>Model files</b>")] -.->|"loaded once"| W
class U neutral
class API io
class ENG queue
class W compute
class GPU memory
class HF memoryThree boxes do all the work, and these modules take them apart one at a time: the API server (text in, text out), the engine core (the decisions) and the worker (the arithmetic).
2. Why does it exist?#
Suppose you write the obvious server: one request arrives, you run the model until the answer is finished, then you take the next request. Three things go wrong.
- The GPU is mostly idle. A GPU is fastest when it processes many sequences in one call. One request at a time uses a small fraction of it.
- Batching by hand is rigid. If you wait to collect eight requests and run them together, the short answers finish early and their slots sit empty until the longest one is done.
- Memory is wasted. You do not know in advance how long an answer will be, so the obvious approach reserves KV cache for the longest possible answer for every request. Most of that reservation is never used.
Point 3 was the one nobody had solved cleanly in 2023. A KV cache for one request can be hundreds of megabytes, and reserving the maximum for everyone meant a 24 GB GPU could hold only a handful of requests even when all of them were short.
3. Simple analogy#
A hotel that gives every guest the largest suite “in case they need it” is full after ten guests, while most rooms stand empty. A hotel that gives each guest one small room, and another next door only when they ask, fits far more guests in the same building. The front desk keeps a list of which rooms belong to whom: that list is the block table.
4. Tiny example: reserving versus paging#
Measure the problem before reading any vLLM code. This program serves the same requests two ways: reserving the maximum length for each, and handing out 16-token blocks on demand.
package main
import (
"fmt"
"math/rand"
)
const (
maxTokens = 4096 // the longest sequence the server accepts
blockSize = 16 // tokens per block
gpuCapacity = 1 << 20
)
func main() {
rng := rand.New(rand.NewSource(7))
// Real traffic is skewed: most requests are short, a few are long.
lengths := make([]int, 0, 4000)
for i := 0; i < 4000; i++ {
n := 100 + int(rng.ExpFloat64()*400)
if n > maxTokens {
n = maxTokens
}
lengths = append(lengths, n)
}
// Strategy 1: reserve the maximum for every request.
reserved := gpuCapacity / maxTokens
// Strategy 2: give each request only the blocks it uses.
used, paged := 0, 0
for _, n := range lengths {
blocks := (n + blockSize - 1) / blockSize
if used+blocks*blockSize > gpuCapacity {
break
}
used += blocks * blockSize
paged++
}
actual := 0
for _, n := range lengths[:paged] {
actual += n
}
fmt.Printf("capacity: %d tokens of KV cache\n", gpuCapacity)
fmt.Printf("reserve-the-maximum: %d requests fit\n", reserved)
fmt.Printf("paged, 16-token blocks: %d requests fit\n", paged)
fmt.Printf("improvement: %.1fx\n", float64(paged)/float64(reserved))
fmt.Printf("memory wasted by paging: %.2f%% (rounding up to a block)\n",
100*float64(used-actual)/float64(used))
}Output:
capacity: 1048576 tokens of KV cache
reserve-the-maximum: 256 requests fit
paged, 16-token blocks: 2076 requests fit
improvement: 8.1x
memory wasted by paging: 1.50% (rounding up to a block)With this traffic the paged server holds about eight times as many requests in the same memory, and wastes one and a half percent on rounding. That gap is the reason vLLM exists.
5. Technical explanation#
The idea vLLM started from: pages#
Operating systems met the same problem decades ago. A process does not get one contiguous slab of RAM sized for its worst case. It gets pages, handed out only when used, and a page table that records which pages belong to it. vLLM does this for the KV cache:
| Operating system | vLLM |
|---|---|
| Page (4 KiB) | Block: room for the KV of 16 tokens by default |
| Physical memory | One large tensor per layer, cut into blocks, allocated at start-up |
| Page table | Block table: for each request, the list of block numbers it owns |
| Process grows its heap | Request generates more tokens, takes one more block |
| Shared read-only pages | Two requests with the same prompt prefix point at the same blocks |
| Free list | A queue of unused blocks |
The attention code was rewritten to read a request’s KV cache from blocks scattered anywhere in the tensor, following the block table. That kernel is PagedAttention (12.l), the subject of the paper that introduced vLLM (Kwon et al., SOSP 2023).
With pages, a request holds only the memory for tokens it has actually produced, rounded up to one block. Waste per request is at most 15 tokens’ worth instead of thousands.
What grew around it#
Paging made the second idea practical: continuous batching. Because memory is handed out in small pieces, a new request can join the batch the moment another finishes, without waiting for the whole batch to drain. The engine re-decides the batch on every step.
Since 2023 the project has added, layer by layer:
| Layer | What it does | Where in this material |
|---|---|---|
| Scheduler | Chooses which requests run each step, under a token budget | 17.a–17.d |
| Block pool and prefix cache | Hands out blocks; reuses blocks for repeated prompt prefixes | 17.e–17.i |
| Model runner | Turns a schedule into tensors and calls the model | 18.a, 18.b |
| Attention backends | FlashAttention, FlashInfer and others, chosen per GPU and model | 18.c |
| Features | Speculative decoding, LoRA, multimodal, structured output, tool calling | 18.e–18.j |
| Parallelism | One model across many GPUs, or many copies across many GPUs | 19.a, 19.b |
6. Under the hood: vLLM by the numbers#
Read from the project on 12 November 2026. They change every fortnight; the ideas in these modules do not.
| Fact | Value |
|---|---|
| Latest stable release | v0.32.0, 18 October 2026 (814 commits from 363 contributors) |
| Next release | v0.33.0rc3, 2 November 2026 |
| Release rhythm | A minor version roughly every two weeks (v0.30.0 on 22 September, v0.31.0 on 5 October, v0.32.0 on 18 October) |
| Licence | Apache 2.0 |
| GitHub stars / forks | about 96,800 / 24,700 |
| Contributors | more than 2,000, by the project README |
| Python source | about 1.04 million lines under vllm/ |
| Supported Python | 3.11 to 3.14 (3.10 was dropped in v0.32.0) |
| PyTorch pinned by the CUDA build | 2.13.0; the default wheel targets CUDA 13.0 |
| Model architectures | “200+” on Hugging Face, by the project’s count |
| Origin | Sky Computing Lab, UC Berkeley; first public release June 2023 |
What vLLM is not#
- It is not a model. It runs models that others trained.
- It is not a training framework. It only does the forward pass (though reinforcement-learning loops use it to generate, 16.g).
- It is not a gateway. It serves one model (plus adapters) per process; routing between models, per-customer rate limits and billing sit in front of it (21.i).
- It is not the only engine. SGLang, TensorRT-LLM and llama.cpp solve the same problem with different trade-offs (15.f).
7. Performance implications#
- Capacity is blocks. The number of requests a server holds at once is the size of its block pool divided by the blocks each request uses. 16.b shows where that number is printed.
- Block size is a trade-off. Smaller blocks waste less memory but make block tables longer and attention kernels do more bookkeeping; larger blocks waste more. 16 tokens is the default for most attention backends.
- The win depends on traffic. Paging helps most when lengths vary a lot. If every request used the full context, paging would give no extra capacity (exercise 2).
8. Production implications#
Most people use vLLM as a black box with forty flags. That works until latency doubles at 3 p.m. and the only tool you have is guessing. Every flag is a constant in a loop you can read:
--max-num-batched-tokensis the number the scheduler subtracts from on each step (17.b).--gpu-memory-utilizationdecides how many blocks the pool has (17.h).- “Preemption” in the logs is one request’s blocks being taken away to feed another (17.c).
Reading the loop once makes those flags stop being folklore. It also lets you read release notes critically: a release moves fast (two weeks), so pin the version, and read what changed in the parts you depend on.
9. Common mistakes#
- Thinking vLLM “is” PagedAttention. Paging was the start; the scheduler, prefix cache, async scheduling and kernels matter as much today.
- Reading an old blog post as current. Code paths, defaults and flags change every release. Check the version a source was written against.
- Expecting vLLM to route between models. One process serves one model; routing is a layer above (21.g).
- Assuming paging helps every workload equally. Uniformly long requests gain little.
10. Hands-on exercise#
- Change
blockSizeto 1, 64 and 512 and rerun. What happens to the waste, and why would a block size of 1 be a bad idea even though it wastes nothing? (Think about the size of the block table.) - Change the traffic so every request is exactly 4,096 tokens. What is the improvement now? What does that tell you about when paging helps?
- Open the vLLM releases page and find the date of the newest release. How many releases have there been since v0.32.0?
11. Interview questions#
- Why can a server not know how much KV cache a request needs when it arrives?
- What is a block table, and what is its operating-system equivalent?
- Name the three parts of a running vLLM server and what each is responsible for.
- Why does paging make continuous batching practical?
- When does paging give little or no extra capacity?
12. Further reading#
Checked on 12 November 2026.