Understand: state assumptions, shapes/units and a counterexample.
Implement: reproduce a numerical example and inspect boundaries.
Investigate: compare one alternative under a matched budget.
This technical article displays the English edition.
Mechanism & assumptions
PagedAttention addresses KV allocation and sharing. It does not erase the attention computation or guarantee a latency target. Measure prefill and decode separately; include queue time in user-visible latency. Prefix caching only helps when the prefix and cache identity match; account for eviction and isolation.
For 32 layers, 8 KV heads, head dimension 128, 4096 tokens and 2-byte elements, KV is 536,870,912 bytes = 512 MiB per sequence (excluding metadata). At block size 16, a 33-token sequence allocates 48 slots and wastes 15. Paging reduces contiguous-allocation requirements but still has final-block slack.
Implementation exercise
Compare block sizes 8/16/32 on a fixed list of sequence lengths. Report slot utilization, page-table entries and a separate measured latency profile; allocation arithmetic cannot predict GPU speed.
Deliver code, fixed seeds, raw results and one counterexample. These are experiment specifications, not executed GPU benchmarks.
Why can tokens/second improve while p99 worsens?
Larger batches can improve device utilization while increasing queueing or interference. Fix arrival process and input/output distributions; report throughput and latency together.
Original teaching examples; sources checked October 2026. These are foundational mechanisms relevant to engineering, not a claim to cover every latest model.
Count both K and V, KV heads rather than query heads, and sequence×batch exactly once. The byte formula excludes activations, weights, allocator fragmentation and attention workspace.
Formula conditions, units and worked arithmetic reviewed. The implementation isolates one numerical mechanism; it does not train a policy or control real hardware.
Mechanism map: follow the transformations from top to bottom.
Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.
Minimal executable example
Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node kv-serving.mjs. No third-party runtime dependencies.
Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.
Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.
The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope