arXiv:2609.11744cs.DCSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.11744

Building py-kvcache: A Performance Characterization of External KV Caching for vLLM with NVMe SSDs

Joseph Kanichai, Tiziano De Matteis, Animesh Trivedi

Abstract

Prefix caching can reduce the time to first token (TTFT) of long-context LLM requests by reusing previously computed key-value (KV) states, but for short prefixes or fast GPUs, recomputation can be faster than loading from an external cache. We characterize this tradeoff in vLLM across GPU, CPU, and NVMe tiers using synthetic workloads, long-context benchmarks, production traces, and find that cache performance depends on transfer granularity, intermediate memory use, and when transfers enter the request schedule, not only on device bandwidth.

These findings motivate py-kvcache, a vLLM KV Offload connector with asynchronous direct I/O, bounded shared staging, and scheduler-aware preloading, which starts disk reads while requests are still waiting, overlapping with compute. At 80k tokens, py-kvcache loading from disk is 2.0×2.0\times faster than LMCache, with preloading contributing 1.34×1.34\times. With GPU, CPU, and disk caching enabled, it is 1.23×1.23\times faster than LM-Cache and within approximately 4% of the native vLLM KV Offload implementation.

LongBench and SCBench show that these benefits extend to irregular prefix chains and multi-turn workloads. Bailian trace replays improve TTFT on a weaker GPU, but on an H100 the average request falls below the break-even point and GPU memory alone retains enough prefixes. External KV caching should therefore be treated as a setup specific admission decision.

The py-kvcache implementation is available at github.com/atlarge-research/py-kvcache.

1 Introduction

Modern large language model (LLM) serving is increasingly a systems problem as much as a model problem. Transformer attention becomes increasingly expensive as context length grows, as during prefill, each token pays “attention” to all earlier tokens, making attention computation scale quadratically with prompt length. To avoid recomputing attention for previously processed tokens, each layer’s key and value tensors can be stored in a key-value (KV) cache [33]. This cache can be essential for efficient decoding, but it grows linearly with context length, batch size, model width, and number of layers. As a result, long-context workloads can become limited by both quadratic prefill computation and KV cache capacity and data transfer rates. Recent work on PagedAttention, KV cache quantization, and KV cache offloading all treat KV memory as a serious bottleneck in LLM inference systems [13, 17, 21].

Prefix caching is a particularly attractive optimization because many real serving workloads contain repeated context. Examples include querying the same long document, multi-turn chat with a system prompt, retrieval-augmented generation (RAG) over repeated passages, and batch evaluation where many questions share a common prefix. In these cases, an inference engine can cache the KV blocks produced during prefill and reuse them for later requests, reducing time-to-first-token (TTFT) as well as the total request time. vLLM is an open source LLM serving engine. Its core abstraction, PagedAttention, manages the KV cache in blocks, allowing requests with variable length prompts and generations to share GPU memory efficiently while being scheduled together [13]. vLLM exposes repeated prefix reuse through automatic prefix caching and manages KV blocks on the GPU using PagedAttention [13,34]. However, GPU memory is finite, and once the reusable working set exceeds video RAM (VRAM) capacity, the system must either evict useful KV blocks or move KV data to slower but larger tiers.

External KV caching extends prefix caching beyond GPU memory by storing KV blocks in CPU DRAM, local NVMe storage, shared filesystems, or even remote KV stores such

This work is partially supported by Netherlands-funded projects NWO MLS (OCENW.KLEIN.561). This work used the Dutch national e-infrastructure with the support of the SURF Cooperative using grant no. EINF-15777. This work was carried out between January and July 2026, supervised by Tiziano De Matteis and Animesh Trivedi.

as Redis. Systems such as LMCache, vLLM's own external caching mechanisms, and llm-d offloading components make the KV cache a distributed multi-tier storage platform rather than a simpler GPU-only data structure [7, 18, 19, 35]. This design is appealing because modern NVMe SSDs offer far better cost per gigabyte when compared to GPU VRAM or traditional DRAM. External caching is not automatically beneficial, since a cache hit replaces GPU prefill computation with cache lookup, disk or host memory reads, and a CPU ↔ GPU transfer, not to mention scheduling, synchronization, etc. For short prompts or prompts with low cache hit rates, or when using fast GPUs, these costs can exceed the recomputation time that caching is meant to avoid. This creates a gap in existing systems: they provide mechanisms for storing and retrieving KV blocks from larger tiers, but pair them with a fixed policy that treats every prefix hit as a win. What is missing is a policy that decides when a lookup pays for itself, and writing one requires knowing where the dominant overheads arise and how scheduling decisions interact with I/O and transfer placement.

This work studies that tradeoff in vLLM, in various tiers and external KV caching systems. Our starting point is an implementation and measurement effort around the vLLM KV Transfer API, LMCache, and the newer vLLM KV Offload API. A significant part of the work is code path tracing, where we followed KV blocks as they move through vLLM scheduling logic, KV connector and transfer interfaces, CPU memory, GPU memory, and filesystem/NVMe storage to determine which operations lie on the TTFT critical path. The early experiments showed that API structure matters: blocking transfer paths, the granularity of KV chunks, and whether copies overlap with model forward passes can substantially change TTFT. These are not fixed properties that can be tuned once, since the same configuration wins or loses depending on prompt length, hardware, model, and how long a request waits before execution. Later experiments therefore shifted the focus from raw I/O bandwidth to request scheduling and critical-path placement. In particular, our notes show that reading KV data only after a request is scheduled leaves disk I/O on the TTFT critical path, while preloading data for waiting requests can leave only the final CPU-to-GPU transfer when the request begins service.

Based on these observations, we built py-kvcache, an external Python KV-cache backend designed for vLLM and filesystem/NVMe storage. The design emphasizes four principles. First, the cache should be simple to deploy and share across multiple vLLM instances by using an ordinary filesystem layout. Second, the I/O path should be efficient for the large, contiguous KV objects produced by block-based serving engines, avoiding excessive worker-thread coordination when a smaller number of outstanding large reads and writes is sufficient. Third, intermediate CPU memory should be explicitly bounded rather than growing with request size. Fourth, cache policy should be hardware and workload aware: external KV reuse should be bypassed below the measured break-even point instead of treating every prefix hit as a win.

The main question we ask is therefore not merely whether external KV caching can work, but when it should be used. Our experiments compare LMCache, vLLM KV Offload, and py-kvcache across synthetic long-document workloads and trace-derived workloads. The results preview a nuanced answer. For long repeated documents, py-kvcache with preload reduces TTFT substantially relative to LMCache and to py-kvcache without preload. In the tiered configuration at 80k-token document sizes, py-kvcache is 1.23×1.23 \times faster than LMCache and stays within 1.04×1.04 \times of the native vLLM KV Offload implementation. Preload is essential: in the disk-only configuration it halves TTFT relative to LMCache at 80k tokens, and against py-kvcache without preload it lowers TTFT by 1.34×1.34 \times at 80k tokens and by 1.66×1.66 \times at 40k tokens. However, Bailian trace experiments indicate that some real workloads have average request sizes below the break-even point for our setup, so external KV caching offers no TTFT benefit over GPU prefix caching alone despite cache hits.

This work makes the following contributions:

• We trace and characterize the performance behaviour of vLLM's KV Transfer API and KV Offload API and related KV-cache systems, including how scheduling, copy granularity, and copy/compute overlap affect TTFT.

• We design py-kvcache, a Python external KV cache engine for vLLM for use with a shared filesystem, utilizing io_uring.

• We introduce and evaluate a preload mechanism that reads KV data for waiting requests before they enter execution, shifting disk I/O off the request critical path, and improving overlap of copy and compute.

• We show that external KV caching has hardware and workload dependent break-even points, motivating cache admission and bypass policies instead of unconditional loading and storing.

References (22)