Unit 7 of 13 · about 5 hours · explain
Reconstructing the block manager, prefix cache, model runner and attention backend
Reuse your allocator and paged-attention invariants. The new task is to find their actual enforcement points and follow a schedule into the selected backend.
You'll be able to
- Trace logical token positions through cache lookup, physical allocation and runner metadata to attention dispatch.
- Identify cache ownership and lifetime boundaries in two miniature engines and vLLM V1.
- Explain which runner assumptions constrain a scheduler or cache contribution.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Nano-vLLM block ownership and attention addressesNano-vLLM and Mini-SGLang as Engine Reconstruction Bridges
can_allocate,allocate,deallocate,may_appendandhash_blocks; follownanovllm/engine/model_runner.py:allocate_kv_cache,prepare_prefill,prepare_decodeandrun_model; thennanovllm/layers/attention.py:Attention.forward - Mini-SGLang radix ownership and runner preparationNano-vLLM and Mini-SGLang as Engine Reconstruction Bridges
RadixPrefixCache.lock_handle,match_prefix,insert_prefix,evictand_tree_walk; followpython/minisgl/scheduler/scheduler.py:_prepare_batch, including page-table allocation and attention metadata preparation - vLLM 0.31.0 cache-manager entry pointsvLLM V1 Architecture Overview
KVCacheManager.get_computed_blocks,allocate_slotsandfree; followvllm/v1/worker/gpu_model_runner.py:_prepare_inputs,_build_attention_metadata,execute_modelandinitialize_attn_backendTrace one supported dense text model and selected backend. Hybrid cache groups and distributed connectors are interface reading, not an implementation requirement.
Focus on
- Record the cache key, lookup result, references, free/used accounting and invalidation scope. Equal prompt suffixes are not equal prefixes.
- Separate cache storage from attention addressing. The allocator chooses physical pages; the runner supplies positions, lengths, slot mappings and block tables; the backend consumes them.
- Nano-vLLM excludes the final prompt block from prefix lookup at this commit. Follow the exact recomputed suffix rather than assuming every complete prompt block is reused.
- Graph replay, padding and asynchronously prepared metadata extend lifetimes. A free operation must respect in-flight consumers, not merely the host request status.
Common mistakes · 3
- Calling an unreferenced cached page unused memory. It may remain reusable until eviction; release and eviction are different operations.
- Assuming a cache hash supplies model, tokenizer and tenant isolation. Verify the full identity scope separately.
- Treating Mini-SGLang's
check_integrityas a complete invariant suite. It is an empty method in the pinned radix implementation; write independent checks.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Which two maps are needed to find a cached token's physical KV?Answer
The request's logical token position to logical page/offset, and its block table from logical page to physical page. Layer and KV-head layout then locate the values.
2.Why can released KV still occupy cache storage?Answer
Release removes active references, but a prefix index may retain reusable content. Eviction makes that storage available for replacement.
3.Does a prefix hit prove the runner skips the whole prompt?Answer
No. Lookup rules, block alignment and the need to recompute a final token or suffix determine actual skipped work. Trace returned token counts and scheduled inputs.
You're done when
Your three annotated cases reconcile token positions, page ownership and runner metadata, and each attention input has an identified producer and lifetime.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 12 more in the section
- vLLM V1 Architecture OverviewvLLM Project · required
Map API server, EngineCore, scheduler, KV cache manager, model executor and distributed deployment from the current documentation into exact source files. Select the bounded contribution only after identifying its state and fallback boundaries.
- Nano-vLLM and Mini-SGLang as Engine Reconstruction BridgesGeeeekExplorer and SGLang Project · required
Reconstruct Nano-vLLM first, then compare Mini-SGLang cache, scheduler, overlap and model-runner boundaries. Move to vLLM or SGLang only when you can predict where the same responsibility lives.
Also in this section
- Hands-On LLM Serving and Optimization - Chapters 8 and 9, frameworks and optimization in practiceChi Wang and Peiheng Hu (O'Reilly) · primary
Read Chapter 9 as a worked sequence from traffic generation and baseline through quantized and distributed variants, then the vLLM architecture and scheduler sections of Chapter 8. Replace its model, engine version and hardware with your own fixed contract.
- TensorRT-LLM Benchmarking GuideNVIDIA · required
Use the benchmark workflow, configuration capture, startup metrics and online-serving path as a benchmark-governance reference. Apply the same discipline to your engine and never import NVIDIA results as your own evidence.
- UCSD CSE 291A (Spring 2026) - Guest lecture: Engineering vLLMUC San Diego · support
Read the scribe notes, Sections 3, 6 and 7: the architecture overview, model parallelism and serving topology, and the hybrid KV allocator with offloading. Use it to predict where a change would live before reading code.
- AI Performance Engineering - Inference Engine and Benchmark LanesWafer · reference
A curated index. Use Sections 4 and 5 only to find a mechanism source for the contribution.
- AI Systems Performance Engineering companion code - inference labsChris Fregly (O'Reilly) · required
Use
labs/dynamic_router,labs/cache_aware_disagg_inference,labs/speculative_decodeorlabs/flashinfer_attentionas a pattern for a controlled baseline, optimization and profile. Rerun everything under your own manifest. - Etalon: Holistic Performance Evaluation Framework for LLM Inference SystemsMicrosoft Research · required
Use its per-request SLO and goodput framing to audit the benchmark. Preserve raw outcomes, quality acceptance and load shape so a throughput increase cannot hide missed latency targets.
- Machine Learning Systems, Volume 2 - The Economics and Architecture of InferenceHarvard (Vijay Janapa Reddi) · support
Read the opening sections of Inference at Scale for cost per token, utilization and serving-architecture dimensions, then build your own capacity and cost model from measured numbers.
- MLPerf Inference Datacenter BenchmarkMLCommons · support
Study scenario definitions, audit discipline and reproducibility. Borrow governance ideas appropriate to the capstone; submitting to MLPerf or reproducing its fleet hardware is outside the gate.
- Artificial Analysis - Performance benchmarking methodologyArtificial Analysis · reference
Read how its latency, output speed and price figures are measured. Use its public numbers as an outside comparison for your capacity plan, never as your own evidence.
- LLM Inference Systems Laboratory - Full CapstoneRoadmap-Final · required
Complete the architecture map, contribution, fallbacks, correctness and fault suite, raw benchmark package, negative result, capacity and cost plan, independent reproduction and design defense. This artifact supplies the track milestone.
- SciPy bootstrap confidence intervalsSciPy · support
Read the resampling procedure, paired parameter, Notes on degenerate data and Examples. Apply it to independent trials; do not assume correlated serving requests are independent samples.
- Machine Learning Systems, Volume 2 - Sustainable AIVijay Janapa Reddi · support
For optional energy/carbon accounting, read Energy measurement techniques, System-level energy profiling and Operational carbon calculation. State meter boundaries and apply PUE only to complete IT energy, once.