KV cache cost savings: what avoided prefill is worth

When a long prefix comes back, your GPUs redo work they already paid for. Reading it back freed about 19 GPU-seconds per reuse of a 110k-token prompt on an L40S in our test.

Last updated

Worked example: one long prompt, reused 1,000 times a day

Two measured times, two assumptions, four lines of arithmetic. Swap in your own numbers with the formula below.

110,016-token prompt, Qwen2.5-7B BF16, one L40S

MeasuredAssumed

  1. 1GPU time freed per reuse

    20.8 srecompute the promptMeasured
    minus
    1.52 sread it from KVStashMeasured
    equals
    19.28 sGPU-seconds freed per reuse
  2. 2GPU time freed per day

    19.28 sfreed per reuse
    times
    1,000reuses a dayAssumed
    equals
    5.36 h19,280 GPU-seconds a day
  3. 3Value of that time

    5.36 hGPU-hours a day
    times
    $2.00per GPU-hour, an example price, not a quoteAssumed
    equals
    $10.71a day, about $321 per 30 days
  4. 4Minus what the store costs you

    631 GBto keep 100 such prompts (6.31 GB each) in DRAM and NVMe, plus the CPU for the daemonYour cost

The result is money only if those 5.36 GPU-hours are cut or reused. Same fleet, same hours, same bill: then the gain is latency and headroom. The 110k read also varied by machine: 13‑19x faster time to first token than recomputing, across 8 runs on separate machines (median about 14x).

Measured times: SGLang 0.5.15.post1, Qwen2.5-7B BF16, one L40S, median of 5 reads after a verified cache flush, 29 Oct 2026. Read the study

Saved per reuse, by prompt length

Recompute grows faster than the read, so the saving per reuse grows with the prompt. Short prompts need many more reuses to matter.

FIGURE 1. Recompute minus read, per reuse. SGLang 0.5.15.post1, Qwen2.5-7B BF16, one L40S, median of 5 reads after a verified cache flush, 29 Oct 2026.

Why we count these seconds as GPU time

  • Recompute was timed on one request with nothing else running, so it is almost all GPU prefill.
  • We subtract the whole read time, though the GPU is mostly copying during it, so single-request savings err low.
  • Under batched serving prefill shares the GPU: see the load test and measure your own.

How to estimate your KV cache savings

The same arithmetic with your hit count, your recompute and read times for the lengths you serve, and your GPU price.

GPU-seconds saved per day=hits per day×(recompute s−read s)

Money saved per day=GPU-seconds saved÷3,600×GPU hourly price−store cost per day

  1. Avoided prefill

    A reused prefix is read, not recomputed.

  2. GPU-seconds freed

    Recompute time minus read time, on every reuse.

  3. Headroom

    The freed time serves other requests, or the same requests start sooner.

  4. Fewer GPU-hours

    Money only when you act on it: fewer GPUs, fewer hours, or growth without new capacity.

Input throughput per GPU under load

Single requests show the saving per reuse. A load test shows what one GPU does with the freed time.

19,939→60,835

Input tokens per second after a server restart, SGLang's own cache against SGLang plus KVStash: 3.1x. Mean time to first token fell from 3.08 s to 0.34 s.

Single passes at fixed concurrency, not a sustained capacity figure. Plan capacity with your own latency target and traffic. Default-settings results are in the restart and load study.

FIGURE 2. Input tokens per second. SGLang bench_serving, generated shared-prefix workload, 8k-token prefixes, 512 requests per pass, one pass per row. SGLang 0.5.15.post1, Qwen2.5-7B BF16, one L40S, host pool 48 GB, 29 Oct 2026.

When KV cache savings are nil

A store adds memory, disk, CPU and one more service to run. In these cases that costs more than the work it avoids.

  • Low reuse

    Prefixes rarely come back, so most stored blocks are written and never read.

  • Short prompts

    At 8k tokens one reuse saved about 0.52 s in our test. It takes many reuses to pay for the store.

  • The cache already fits

    If the engine's own GPU and host cache keeps everything you reuse, a store adds nothing.

  • Nothing changes in the fleet

    Same GPUs for the same hours means the same bill; the gain is latency, not money.

  • The prefix differs early

    A timestamp or user ID near the start makes every request unique. See prompt layout.

  • Hosted model APIs

    KVStash runs under engines you operate, not under a provider's API.

Estimate it on your own traffic

Four steps, in order. The last one decides whether you report money or latency.

  1. Count reuse

    From request logs, count how often each long prefix returns, and how much your engine already serves from its own cache.

  2. Time both paths

    Recompute and read on your GPU for the lengths you serve, after a verified cache flush. See our method.

  3. Apply the formula

    Hits per day times seconds saved, then your GPU price, minus the store.

  4. Name the change

    Which GPUs or hours you would cut, or how much more traffic the same fleet takes.

Savings questions

Need bytes per token for your model? The KV cache calculator sizes the store side.

How much GPU time does one KV cache reuse save?

It depends on prompt length and GPU. On one L40S with SGLang and Qwen2.5-7B BF16, a 110k-token prompt took 20.8 s to recompute and 1.52 s to read from KVStash, so each reuse saved about 19 GPU-seconds. At 8k tokens it saved about 0.52 s.

Does a faster time to first token lower my GPU bill?

Only if you change something. Freed GPU time becomes money when you serve more requests on the same GPUs or run fewer GPU-hours for the same traffic. If the fleet stays the same size for the same hours, the bill stays the same and the gain is latency and headroom.

What does the store itself cost to run?

Memory and disk for the blocks plus the CPU that runs the daemon. Size it from your KV bytes per token: a 110k-token prompt on Qwen2.5-7B BF16 is 6.31 GB. Hot prefixes go in DRAM, more capacity on NVMe, and the long tail on S3.

Why is time to first token not the same as GPU time?

Time to first token is what a user waits; GPU time is what you pay for. For one long request on an otherwise idle GPU, nearly all of the recompute wait is prefill on the GPU, so the two are close. Under batching, prefill shares the GPU with other work, so measure throughput under your own load as well.

Is there a calculator for my numbers?

Use the formula on this page with your hits per day, your measured recompute and read times, and your GPU price. The KV cache calculator gives the bytes per token and per prompt you need to size the store.

Put your numbers into the formula with us.

Send your engine, model, GPUs, prompt lengths and how often context comes back. We reply with the measurement we would run and an honest estimate, including when the store is not worth it.

Or write to rudray@kvstash.com