Rust, CUDA
paged-kv-cache
A KV-cache memory manager modeled on vLLM’s PagedAttention, written from scratch: a refcounted block allocator, per-sequence block tables with copy-on-write forking, prefix caching, and a continuous-batching scheduler with preemption. The core crate has no dependencies and runs on a CPU reference backend that doubles as the numerical oracle for the CUDA kernels.
With prefix caching on, a chat workload where most requests share a system prompt computes 69% fewer prompt tokens and nearly doubles the mean batch. The workspace has 130 tests, including randomized checks that every block’s refcount matches the block tables that point at it.
Live demo Source The demo sleeps when idle and can take a few seconds to wake.