Serving is where an LLM bill actually lives, and the paged KV cache is the reason vLLM can serve
more concurrent requests than a naive loop on the same GPU.

I rebuilt that architecture to understand it, one phase at a time, in
mini-llm-engine. It is based on the nano-vLLM
reference — that lineage should be stated plainly, because the value of the exercise is the
implementation and the measurements, not the invention of the idea.

The fragmentation problem in one paragraph

A naive cache allocates a contiguous block per sequence, sized for the worst case. A request that
generates 900 tokens reserves the same memory as one that generates 100, because the runtime
cannot move a block that a kernel is reading. Ten concurrent requests later, most of the cache is
free space that no other sequence can use. Paging fixes that: allocate fixed-size blocks, map them
per sequence, and let the scheduler decide how many blocks a running sequence actually needs.

How I measured it

The number that gets quoted from this project is 86.9% effective KV utilisation on a synthetic
fragmentation workload — sequences with deliberately uneven lengths arriving together. That is the
interesting case: it is the workload where a contiguous allocator wastes the most memory, and
therefore the one where paging has to earn its complexity.

What that number is not:

  • It is not a throughput claim. On the machine I had, the whole engine runs at 3.7 tokens/second, with TTFT p50 1613 ms and TPOT p50 1006 ms — on an RTX 3050 Laptop with 4 GB.
  • It is not a data-centre benchmark. The harness targets a Kaggle T4 with 15 GB; the laptop number is a structural baseline, not a serving result.

Every phase has a gate script (tests/test_phase*.py) and the methodology is in
docs/benchmark.md, so the claim can be reproduced or refuted on your hardware instead of taken
on my word.

The parts that are easy to get wrong

  • Block tables are the whole game. Prefix sharing only works if two sequences can point at the same physical block, and eviction is only safe if the table is updated before the block is reused. Sharing was verified across 16 of 16 blocks in the test workload.
  • Continuous batching is a scheduler problem. Admitting a new sequence mid-decode changes the shape of every kernel call. The OpenAI-compatible HTTP surface is the easy part; the token budget arithmetic is not.
  • Quantization has to be exact where it claims to be. GGUF Q8_0 and Q4_K_M are checked for dequantization parity against BF16, because a quantized model that silently drifts is worse than no quantization at all.

Why this belongs next to agent work

An agent that makes thirty calls is a customer of an inference stack. Whether those calls queue
behind each other or batch together decides the cost per run as much as the model choice does.
Understanding the scheduler is how you stop treating latency as a property of the vendor.

Start at the case page or go straight
to github.com/RavaniRoshan/mini-llm-engine.