vLLM Dismantled: Paged Attention, Continuous Batching, and Scheduling Explained Through Code
What happened. Aleksa Gordić published a technical breakdown of vLLM component by component: from the KV cache manager with paged attention, to the scheduler with continuous batching, through to the multi-node serving layer. The post traces the V1 engine code (August 2025 commit) and builds up layer by layer from the fundamentals.
Why it matters. If you’re serving open-weight models in production, vLLM is probably running under your stack. Understanding how it manages GPU memory, schedules requests, and handles continuous batching helps you diagnose bottlenecks and configure it properly instead of treating it like a black box. When throughput drops or latency spikes, knowing what the scheduler does under the hood means the difference between informed tuning and blind guessing.
If you want to learn it. The article is free, starting from a Python example on a single GPU and building up. Layer by layer: scheduler, paged attention, continuous batching, prefix caching, speculative decoding, multi-GPU, serving layer.
In depth
vLLM is the inference engine most teams serving open-weight models in production have under the hood. The project introduced paged attention: instead of reserving one contiguous block of GPU memory per request, the KV cache is split into fixed-size pages, allocated and freed on demand. Memory gets reused without fragmentation, and throughput rises significantly versus naive allocation. Think of an office where each person gets a dedicated cabinet, half empty: you waste space. With pages, you assign only the shelves you need, when you need them, and free them as soon as you’re done.
Gordić’s article walks through the V1 engine code bottom-up. It starts with the simplest case: offline, single-GPU, synchronous. From there it adds layers. The scheduler and its FCFS or priority policy decide who enters the batch and who waits, based on available memory. The KV cache manager with its free_block_queue tracks which blocks are free and occupied, like a hotel’s roster of empty rooms. The model executor runs the forward passes (the actual model computations on the GPU).
Then it scales up. Continuous batching: vLLM doesn’t wait for a full batch to finish before loading new requests. At each decoding step, the scheduler reshuffles active requests, inserting new ones where there’s room. A short request doesn’t wait for a long one to free up the batch. In traditional systems, batch ten requests together and one is much longer than the rest, and the nine short ones block waiting for the tenth. With continuous batching, every time a request finishes, its slot in the batch goes to the next one in the queue.
Prefix caching recognizes when multiple requests share the same prefix (system prompt, shared context) and caches its output, saving compute. If a hundred users send the same system prompt, vLLM computes those prefix tokens once. Speculative decoding uses a small model to generate token drafts that the large model verifies in a single forward pass, trading throughput for latency. The small model suggests, say, five tokens; the large model checks in one shot how many are correct and accepts them, regenerating only the rest.
The last two layers handle the jump from one GPU to many GPUs and nodes: data parallelism, tensor parallelism, pipeline parallelism, expert parallelism. Tensor parallelism splits the model weights across GPUs, so a model too large for one card fits split up. Pipeline parallelism assigns different layers to different GPUs, passing results forward in turn. The serving layer puts it all behind an async API, handling thousands of simultaneous requests without blocking.
One caveat: vLLM moves fast. The V0 engine is already deprecated, V1 evolves week by week. The article anchors to a specific commit, and some interfaces may have shifted. The core concepts stay solid: master them and you can diagnose throughput issues, configure memory parameters better, and decide when vLLM is the right tool versus alternatives like SGLang or TensorRT-LLM.