vLLM defaults to a page size of 16. Pick what makes 1 and 1024 worse choices.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.