Decision guide

When context reuse is worth it

Repeated context is a chance to skip repeated computation. It is not, on its own, a reason to run another storage service. Here is how to tell the difference on your own traffic.

On this page
  1. The short answer
  2. What is reused
  3. Similar is not the same
  4. Engine cache first
  5. Reading has a cost
  6. Retention and durability
  7. Five questions
  8. Where KVStash fits

The short answer

A KV-cache store is worth running when three things are true at once:

  1. The same exact prefix comes back. Counted from the first token, not similar text.
  2. It comes back after the engine lost it. Evicted, restarted, or on another server.
  3. Reading beats recomputing. True at every length we measured, 8k to 110k tokens.

The third held on an L40S at every length we tried. The first two depend on your traffic, and they are what to check first.

What gets reused

Before a language model writes an answer, it processes the whole input. This step, prefill, produces the attention state for every token: the KV cache. Generation then reads that cache instead of recomputing earlier tokens at every step.

A later request that starts with the same tokens can load that cache and compute only what is new. The answer is still generated fresh: KV-cache reuse is not a response cache. In our SGLang test, outputs with the prefix read from KVStash matched SGLang's own cache at the same reuse split in 12 / 12 prompts.

Similar words are not enough

Take an assistant whose prompt is a shared system prompt, then an unchanged document, then a new question. The first two parts form a reusable prefix for every later question about that document.

A prompt laid out for KV cache reuse The prompt runs left to right: system prompt, tool definitions, shared document, earlier turns, then the new question. Everything before the first changed token, where the new question starts, is read from KVStash in whole 64-token pages. The last partial page and the new question are computed on the GPU. Read from KVStash Computed on the GPU System prompt same on every call Tool definitions same tools, same order Shared document byte-identical text Earlier turns appended, never edited New question differs per request 64-token pages (the page size in our SGLang tests) first changed token last partial page: recomputed A prompt laid out for KV cache reuse From top to bottom: system prompt, tool definitions, shared document and earlier turns are read from KVStash in whole 64-token pages. Below the first changed token, the new question is computed on the GPU. Read from KVStash, in 64-token pages System prompt same on every call Tool definitions same tools, same order Shared document byte-identical text Earlier turns appended, never edited first changed token Computed on the GPU New question plus the last partial page
FIGURE 1. Reuse runs from the first token to the first changed token, in whole 64-token pages.

Now put a user-specific greeting before the document, change one line of the system prompt, or reorder retrieved passages. The visible document is the same, but the prefix is not, and nothing after the first changed token can be reused. In our SGLang setup a prompt sharing 3,507 tokens reused 3,456, the 54 full pages, and recomputed the rest.

Reuse also depends on the model, tokenizer and cache layout. A block that matches the text but came from another model is a correctness bug, not a hit, so the store's keys include the model identity.

Counting repeated words overstates what a cache will save. Count shared prefixes from the first token.

Start with the cache the engine already has

Both main engines reuse prefixes on their own. vLLM has automatic prefix caching on top of PagedAttention; SGLang has RadixAttention and HiCache, which adds host memory and a storage tier. While the prefix is still in GPU or host memory, that is the fastest path, and a store adds nothing.

The store's chance comes at the edges of that working set:

  • Eviction. Long prefixes are large (6.31 GB for a 110k-token prompt on Qwen2.5-7B BF16), so GPU and host memory hold only a few, and they are pushed out before they come back.
  • Restarts. A deploy, crash or spot reclaim empties the engine's cache. A separate store keeps its blocks.
  • More than one server. Each server's cache is private, so a prefix computed on server A is recomputed on server B.

Measure how much context you lose at each edge before you count on any of it.

Reading has a cost of its own

Moving the cache takes time: the bytes cross the network or a local link, land in host memory, and are copied to the GPU. Recompute grows faster than linearly with prompt length (attention compares every token with every earlier one), while the read grows roughly with the number of bytes. So the advantage widens with length.

  • 8k5.3x
  • 32k8.0x
  • 64k10.6x
  • 110k13.7x
FIGURE 2. Time to first token, and how many times sooner the read was. SGLang 0.5.15.post1, Qwen2.5-7B BF16, one L40S, median of 5 reads after a verified cache flush, 29 Oct 2026.

Below 8k tokens we have not measured. The saving per reuse there is fractions of a second, so it takes many reuses to cover the cost of storing the blocks. Count the other side too: the first request still pays full prefill and writes the blocks, some stored blocks are never read again, and every byte kept costs memory or disk.

Retention and durability are different questions

A store outside the engine keeps the cache when the engine process ends. That is not the same as keeping it when the store's own process or machine goes down. Name the tier and the event you need to survive:

DRAM
Fastest, and lost when the daemon restarts. With an empty store after a restart: requests served; cache refilled (64/64, 75% reuse).
NVMe
Holds far more. A 32k-token prefix read wholly from the NVMe tier in 0.77 s, against 3.6 s to recompute (4.7x); 0.42 s from DRAM. 28 GB passed through a 4 GiB DRAM arena with 0 misses. Modal GPU container disk (not a dedicated NVMe drive), SGLang 0.5.15.post1, Qwen2.5-7B BF16, nvme_admit_min_hits set to 0, 30 Oct 2026 (run r20261030-tier1).
S3
Holds the long tail. We have not measured S3-tier reads under SGLang yet, so we quote no number for it.

If the store is unreachable the engine recomputes, as it would without a store. Store killed (SIGKILL) during a 512-request load: 512/512 requests completed; SGLang recomputed. And a block kept on disk may still be useless after an upgrade: a different model identity changes the key, so old blocks stop matching and are recomputed.

A practical way to decide

Take a representative slice of traffic and answer five questions, in order:

  1. What repeats? Shared prefixes counted from the first token, their length, and how long they stay useful.
  2. What does the engine already reuse? Its cached-token counts at realistic concurrency and memory pressure.
  3. What falls out of reach? Prefixes that come back after eviction, after a restart, or on another server.
  4. What does a read cost against recompute? Time both on your GPU for the lengths you serve, after a verified cache flush.
  5. Which outcome matters? Faster first tokens, more requests per GPU, or fewer GPU-hours. Measure that one directly; savings shows the arithmetic.

If the engine's cache already serves the working set, prompts rarely share a prefix, or prompts are short, keep what you have. If long prefixes keep coming back after the engine has lost them, a store is worth measuring.

Where KVStash fits

KVStash is a store under the engine, not a replacement for its cache. SGLang uses it as the HiCache storage tier and vLLM through a KV connector, so the engine's own GPU and host caches stay first in line. KVStash holds what they cannot: blocks in DRAM, NVMe and S3, kept across engine restarts and shared by every server that connects. See use cases for the patterns where that has paid off in our tests, and how we measure cache value for the method.

Bring one workload. We will measure it with you.

Tell us your engine, model, GPUs and where context repeats or gets lost. We reply with what we would measure, what success looks like, and when KVStash is not worth it.

Or write to rudray@kvstash.com