arXiv:2608.23658cs.ARAug 2026

Manuscript Offprint

arXiv:2608.23658

Elastic KV Cache for LLM Serving:A Working Reclamation Mechanism, and Why Chunked Prefill Already Closes the Gap

Sathishkumar Sivashanmugam

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

An LLM serving engine sizes its key-value (KV) cache once, at startup. To do that it permanently sets aside a reserve for the worst-case prefill activation. During decode-dominant phases that reserve sits idle, yet it cannot be handed to the KV pool because it is exactly the memory a large prefill needs. We ask whether this reserve is a reclaimable resource, so we built a mechanism to test it. Our elastic KV cache lends the reserve to the KV pool during decode phases and returns it before prefill, driven by the scheduler's one-step-ahead view of the next batch. The mechanism is pure userspace on the CUDA virtual-memory path: two physical handles mapped into one contiguous virtual range per layer, so the attention kernel is unchanged and no driver patch is required. It decommits the reserve in a few milliseconds and recommits it in tens of milliseconds, works with CUDA graphs and prefix caching enabled, and never triggers an out-of-memory (OOM) event. We show that a static commit of the same memory is unsafe. It crashes on prefill bursts, which makes the dynamic toggle necessary to capture the reserve at all.

Having built the mechanism, we then test the premise it rests on, and report an honest negative result. The technique only pays off if a small prefill chunk size badly hurts prefill latency, forcing operators to choose between prefill throughput and KV capacity. In a controlled experiment that injects long prompts into a live decode load, that penalty turns out to be small (median time-to-first-token differs by about 1% between chunk sizes of 8192 and 32768 tokens). The reason is structural: prefill is compute bound, so chunking splits the same work across steps, and decode consumes only about one token per sequence per step, so it never starves the prefill budget. Simply lowering max_num_batched_tokens recovers more KV than the elastic controller does, at nearly equal latency, so the controller does not beat that trivial baseline. We further show the reserve dilutes under tensor parallelism, shrinking from 16% of KV at TP1 to as little as 2.7% at TP4. Large models need high tensor parallelism, so this regime does not help either. We conclude with a precise statement of when reclaiming the reserve could still help, and we release the mechanism as a reusable userspace elastic-VMM allocator.

1 Introduction

Modern LLM serving engines such as vLLM [3] manage GPU memory by carving the device into a few fixed regions at startup: model weights, a CUDA-graph pool, a small activation working set, and everything left over becomes the KV cache. The KV cache is the scarce resource. It bounds both the number of concurrent requests and the maximum context length, so operators want it as large as possible.

The size of the KV cache is not a free parameter. Before it is sized, the engine profiles a worst-case forward pass and sets aside enough memory to run the largest prefill it will ever schedule.

The larger the prefill chunk, controlled by max_num_batched_tokens, the larger this activation reserve, and the smaller the KV cache. This sets up an apparent tradeoff. A large chunk gives fast prefill but a small KV cache; a small chunk gives a large KV cache but, one would assume, slow prefill. The reserve is provisioned for the peak and is idle whenever the engine is not running a large prefill, which for many workloads is most of the time.

This paper studies whether that idle reserve can be reclaimed. We treat the prefill-activation reserve as a resource that can be lent to the KV cache during decode-dominant phases and returned before the next large prefill, and we build a working mechanism to do exactly that. The design question is entirely about the memory substrate: the KV cache in vLLM is one contiguous tensor per layer, and the attention kernel indexes it by block id, so any scheme that grows and shrinks it must preserve a single contiguous virtual address range per layer or else touch the kernel. We solve this on the CUDA virtual-memory (VMM) API by reserving one virtual range per layer and backing it with two physical handles, a base handle and an elastic handle, mapping and unmapping only the elastic sub-range. The attention kernel never changes, no driver is patched, and the toggle costs a few milliseconds for the full 3 GiB reserve.

We report two kinds of result. First, the mechanism works and is necessary: a static commit of the reserve crashes on prefill bursts, while the dynamic toggle runs the same bursts clean, and on a low-tensor-parallel, long-context configuration the toggle reclaims about 18% more KV capacity and about 10% more decode throughput at zero OOM. Second, the premise does not hold on the workloads that matter. The prefill penalty of a small chunk size is small because prefill is compute bound and decode is cheap per step, so vLLM's chunked prefill already dissolves the tradeoff the technique was built to exploit. Lowering the chunk size is a better lever than an elastic cache. We show this with a direct time-to-first-token (TTFT) measurement, and we show that tensor parallelism removes the only regime where the reserve is large.

Our contributions are:

  • A userspace elastic KV mechanism on the CUDA VMM path that grows and shrinks the KV cache without changing the attention kernel or patching the driver, and toggles the full reserve in milliseconds (Section 3).

  • A necessity result: static reclamation of the reserve is unsafe and OOMs on prefill bursts, so only dynamic toggling can capture it (Section 4).

  • An honest negative result: a controlled TTFT-under-load experiment shows the prefill penalty of a small chunk size is about 1% at the median, so simply lowering max_num_batched_tokens recovers more KV at equal latency and the elastic controller does not beat it (Section 5).

  • A scope characterization, including a tensor-parallel dilution law that shrinks the reserve from 16% to as little as 2.7% of KV, that tells practitioners when reclaiming the reserve could be worthwhile and when it cannot (Section 6).

All measurements are on a single NVIDIA A100-SXM4-40GB, Qwen2.5-7B-Instruct in float16, vLLM 0.23.0, gpu_memory_utilization=0.9 and max_model_len=32768 unless stated otherwise.