Zenaique

Explain why vLLM became the default serving runtime for self-hosted open-weights models

Flashcard·Easy·4.0 · 0·~30s·Asked atBrowserbaseCapgeminiComet Ml
Attempt it
TL;DR

PagedAttention recovers 2-4x of wasted KV-cache GPU memory; continuous batching keeps the GPU saturated by admitting new requests mid-batch. Together they crush naive serving on cost per million tokens.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a parking garage. Old serving was 'reserve a whole row of spots for each car the moment it enters, in case it parks at the very end.' Most cars take only a few spots, and the rest sit empty. PagedAttention is 'each car takes only the spots it actually uses, and we keep a map of which car owns which spots', way more cars fit. Old batching was 'wait until the entire row of cars is ready to leave before any new car can park.' Continuous batching is 'a new car can park into any empty spot in any row right now, without waiting.' Apply both to a GPU and you get a fleet of cars in and out far faster, at much lower cost per car.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Self-hosted LLM inference economics are set by tokens per second per GPU. Get more tokens out of the same hardware and cost per million tokens drops. Most of the headroom comes from two structural inefficiencies in naive transformer serving: KV-cache memory is allocated for worst-case sequence length even when most sequences are short, and batches are scheduled statically so the GPU idles whenever any sequence in a batch is still generating. vLLM addresses both with PagedAttention and continuous batching, and that is why it became the default serving runtime in 2026.

This walkthrough explains both mechanisms, places vLLM against the rest of the serving-stack (TGI, SGLang, Triton, Ray Serve, and the managed-inference tier), and names where vLLM is not the right pick.

PagedAttention, the memory win

Standard attention implementations store the KV cache (the keys and values produced for every past token in a sequence) as a contiguous tensor per sequence, sized for the maximum context length the server will accept. If your server accepts 32K-token contexts and a typical request is 800 tokens, you have allocated 32K worth of KV memory and used 800 worth. The other 31,200 slots are reserved but empty, locked away from other sequences that could use them.

PagedAttention borrows the operating-system virtual-memory model. The KV cache is split into fixed-size blocks of 16 tokens (the canonical vLLM block size; tunable). Each sequence has a page table mapping its logical KV positions to physical blocks. Blocks are allocated from a global page pool only as the sequence grows. When a sequence finishes, its blocks return to the pool and become available for other sequences. The result is GPU memory utilization that approaches 90% rather than 30%, which translates to 2-4x more concurrent sequences per GPU on realistic length distributions, and even more for bursty or long-context workloads.

The implementation cost is one extra level of indirection per attention operation: the attention kernel gathers KV from possibly non contiguous pages instead of reading a flat array. The vLLM team wrote custom CUDA kernels that do this gather efficiently, so the indirection overhead is small relative to the memory-saving win.

A secondary benefit: the page-pool model makes KV-cache sharing across sequences with identical prefixes trivial. Two requests that begin with the same 2000-token system prompt can share the physical KV pages for those 2000 tokens; only the divergent suffix needs its own pages. This is the foundation for prefix caching, which SGLang's RadixAttention takes further with a trie-indexed prefix tree.

Continuous batching, the time win
Where vLLM sits in the broader stack
Where vLLM is not the right pick
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Production deployment of Llama 4 70B on vLLM achieving 2-3x higher tokens per second than naive Hugging Face Transformers serving.
  • Modal and BentoML packaging vLLM into managed endpoints for teams that want self-hosted economics without the ops overhead.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QExplain how prefix caching builds on PagedAttention and when it materially changes cost economics.
A

PagedAttention stores KV in pages indexed by a page table. Prefix caching adds a hash from the prefix tokens to the physical KV pages, so a new request with a matching prefix can re-use the cached KV instead of recomputing. SGLang's RadixAttention generalizes this to a trie. The economics flip dramatically for workloads with repeated system prompts or few-shot examples (RAG with stable system instructions, chat applications with long system prompts): prefill cost on the cached portion goes to near-zero, which can cut total compute 30-70% depending on the prompt to generation ratio. The trade-off is cache eviction logic and the additional GPU memory the prefix cache occupies.

1 more follow-up an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Attributing vLLM's win to 'faster CUDA kernels' or 'better quantization support'. Those are nice to haves; the structural advantages are PagedAttention and continuous batching, which others have since copied with varying completeness.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What PagedAttention does and why it saves 2-4x of GPU memory

  • What continuous batching does and why it raises GPU utilization

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Why a circuit breaker around the primary LLM provider is more than a fancy retry
Flashcard·Medium