vLLM defaults to a page size of 16. Pick what makes 1 and 1024 worse choices.
Page size trades lookup overhead against fragmentation. Size 1 pays per-token lookups and breaks GPU coalescing; size 1024 wastes most of each block. 16 amortizes lookups while keeping fragmentation under 10%.
Picture an airline assigning seats by buying rows of seats in bulk and parcelling them out. If you buy one seat at a time, you spend all day at the ticket counter and pay a fee per seat. If you buy 1000 seats at once for every passenger, you only do one big purchase, but a passenger flying alone wastes 999 seats. Buying 16 at a time is a sweet spot: you only visit the ticket counter once per group of 16 passengers, and groups smaller than 16 only waste a handful of seats. vLLM picks 16 for the same reason.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk the OS virtual-memory analogy, explain the lookup-overhead failure mode of B=1 and the fragmentation failure mode of B=1024, derive the throughput vs fragmentation tradeoff curve, connect to prefix-caching granularity, and close with workload-dependent tuning advice.
from vllm import LLM, SamplingParams
# Default block_size=16 is set inside vLLM and rarely overridden.
# Showing it explicitly for clarity.
llm = LLM(
model="meta-llama/Llama-4-Maverick",
block_size=16, # PagedAttention block size in tokens
gpu_memory_utilization=0.92,
)
# Smaller blocks (e.g., block_size=8) might marginally reduce fragmentation
# for short-form chat workloads but increase per-block overhead.
# Larger blocks (e.g., block_size=64) might help long-form generation but
# increase fragmentation on short requests.
sampling = SamplingParams(temperature=0.7, max_tokens=200)
outputs = llm.generate(["Hello, world!"], sampling)Real products, models, and research that use this idea.
- vLLM defaults to block_size=16 for PagedAttention across all supported models (Llama 4 Maverick, Mistral, Qwen 3.5, etc.) as of the 2026 releases.
- TensorRT-LLM uses similar block-based KV cache management with comparable block-size choices (default 64 in some configurations).
- SGLang and similar serving engines also adopt block-based KV management with default block sizes in the 16-64 range.
- DeepSeek V4's MLA reduces per-token KV bytes, which interacts with block-size choice but does not change the basic tradeoff.
- vLLM's prefix caching feature relies on block-aligned prefix matching, which is another argument for keeping block size small.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does the optimal block size change with FP8 KV cache versus FP16?
QWhy does PagedAttention eliminate external fragmentation but not internal fragmentation?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating page size as 'just a config parameter' and missing that the two extremes lose to the middle for fundamentally different reasons: per-token overhead at one end, wasted memory at the other.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.