Research notebook

How much KV-cache space do variable-length requests waste? notebook

Edit a Python cell and run it here. Your code runs in this browser tab; the notebook runtime and packages are served by this site.

Python starts when you choose Run.

How much KV-cache space do variable-length requests waste?

Original static CPU allocation accounting; no inference, copy-on-write implementation, external-fragmentation simulation, or vLLM benchmark.

This notebook runs the complete saved experiment, checks its assertions, and regenerates the SVG from the computed results. Python 3.10+ and standard-library modules only. Place experiment.py and figure_generation.py beside the notebook. The exact loaded assets are recorded in notebook metadata.

Python · cell 1
reserved: slots=96, unused=65
page=4: slots=40, unused=9
page=8: slots=48, unused=17
page=16: slots=64, unused=33
prefix-sharing: separate=44, shared=36
metadata cost=0.0 token-slot equivalents/block: best tested page=1, cost=31.0
metadata cost=0.25 token-slot equivalents/block: best tested page=2, cost=38.25
metadata cost=1.0 token-slot equivalents/block: best tested page=4, cost=50.0
metadata cost=4.0 token-slot equivalents/block: best tested page=8, cost=72.0
Python · cell 2
Regenerated figure.svg from results.json.

Inspect the saved result

The article's static figure is available before running code. The regenerated figure.svg uses results.json, and every plotted quantity comes from the experiment.

Computed figure

Change an input in experiment.py, rerun both code cells, then compare the saved result and figure.

Python runs locally in this page. Saved results and figures are visible before execution.

Download full experiment notebook