How to keep the KV cache across restarts

When a vLLM or SGLang server restarts, its KV cache is gone and the first requests pay full prefill again. Here are the ways to keep it, what each needs, and what we measured.

Last updated

9 minute read

On this page
  1. Why a restart empties the cache
  2. Options that keep it
  3. What it saves: a measured restart
  4. Production checklist
  5. FAQ

To keep the KV cache across a restart, store it in a tier that lives outside the inference engine's process (a disk directory, a remote store or object storage) and start the restarted engine with the same cache identity, so it finds and reloads those blocks instead of recomputing them.

Why does a restart empty the KV cache?

Engines cache prompt prefixes in GPU memory and, optionally, in host memory. Both belong to the engine process. A deploy, a config change, a crash, a node drain or a spot reclaim ends that process, and the cache goes with it.

FIGURE 1. What an engine restart takes with it. Tiers outside the process only help if the restarted engine, or the store, can find the blocks again.

For short prompts that costs little. For long system prompts, tool lists, shared documents and agent histories, the first minutes after every restart run at cold-start speed, often exactly when traffic is shifting between replicas. Background: what a KV cache is and how offloading works.

What are the options for keeping the KV cache across restarts?

Each option below moves cached blocks somewhere an engine restart does not touch. Each row summarises the project's own documentation as of November 2026. Where a project does not state its restart behaviour, we say so: we have not tested the other options ourselves.

  • vLLM native tiers

    Built in: fs and obj tiers of the offloading connector

    Restart reuse not stated
    How it attaches
    Built-in OffloadingConnector with the tiering spec, vLLM 0.22 and later
    Where the cache lives
    Files under a root directory, in a subdirectory named from the model and a digest of the run configuration; or an S3-compatible bucket through NIXL
    What it needs
    A disk or bucket, the same configuration after the restart so the digest matches, and your own clean-up of old directories
    After an engine restart
    The files stay and the same configuration maps to the same directory. The docs do not describe reuse after a restart.
  • SGLang HiCache L3

    Built in: --hicache-storage-backend

    Depends on the backend
    How it attaches
    File, Mooncake, 3FS, NIXL, AIBrix or a dynamic class
    Where the cache lives
    L1 GPU and L2 host memory are private to the instance; L3 is the chosen backend (the file backend defaults to node-local /tmp/hicache)
    What it needs
    A backend that keeps data outside the process, and a host pool large enough to stage what is read back
    After an engine restart
    Only what the L3 backend keeps. L1 and L2 are lost.
  • LMCache with a remote backend

    LMCache connector in vLLM

    Restart reuse not stated
    How it attaches
    remote_url such as redis://, lm:// or mooncakestore://
    Where the cache lives
    CPU memory, then local storage, then the remote service
    What it needs
    The remote service running before vLLM starts, as the docs say
    After an engine restart
    The remote copy is outside the engine process, so it can outlive a restart while the service keeps its data (for Redis, its own persistence settings).
  • PegaFlow

    Sidecar process with a vLLM connector; SGLang also named

    Stated: survives restarts
    How it attaches
    An independent sidecar beside the engine
    Where the cache lives
    Host memory or SSD; RDMA for sharing across nodes
    What it needs
    pegaflow-llm from PyPI and the sidecar running beside the engine
    After an engine restart
    Its README states "KV cache survives engine restarts".
  • Lifeboat Cache

    Plugin for vLLM 0.32 and later, or a HiCache dynamic backend

    Stated: survives restarts
    How it attaches
    A secondary tier of vLLM's offloading connector, or a dynamic backend for SGLang
    Where the cache lives
    Local disk by default (~/.lifeboat_cache/kv), also NFS, ONTAP or S3; compressed to FP8 by default
    What it needs
    The lifeboatcache package, under a proprietary licence
    After an engine restart
    Its package page states "Persisted KV survives restarts" and reports measurements after a full restart; the index is rebuilt from disk at startup.
  • Mooncake Store

    Connectors in vLLM, SGLang and LMCache

    Restart reuse not stated
    How it attaches
    A mooncake_master plus clients that contribute memory
    Where the cache lives
    DRAM pooled across store clients; optional SSD offload, off by default
    What it needs
    The master (etcd for high availability) and the clients running
    After an engine restart
    Data held by clients outside the engine is not tied to it. The docs call a master without high availability a single point of failure.
  • KVStash

    Separate daemon under SGLang and vLLM; adapters on PyPI

    Measured: survives
    How it attaches
    SGLang HiCache storage tier; vLLM KV connector
    Where the cache lives
    A separate daemon: DRAM, then NVMe, then S3
    What it needs
    The daemon (a free download from the install page), a private network, a namespace and a bearer token
    After an engine restart
    Everything in the daemon survives an engine restart: measured below. A daemon restart keeps the NVMe tier and loses blocks held only in DRAM.
From each project's public documentation, checked 4 November 2026. "Not stated" means we did not find a statement, not that it fails. Corrections welcome.

Two differences matter more than the brand.

  • Who owns the index. Blocks on disk are only useful if the restarted engine or store can find them again.
  • Who evicts. A directory nobody cleans up fills the disk, which is why llm-d pairs a shared filesystem tier with a separate evictor, while stores such as Mooncake and KVStash evict on their own.

What does keeping the cache save after a restart?

We measured it with SGLang's own load generator. The SGLang server was stopped and started again between passes while the KVStash daemon kept running. Both setups have SGLang's GPU radix cache and host-memory HiCache; the second also has KVStash as the storage tier.

9.02 s→0.80 s

p99 time to first token in the first pass after an SGLang restart

Mean
3.08 s to 0.34 s
Prompt reused
54% to 99%
Input throughput
3.1x
SetupMeanp50p99Input tokens/sPrompt reused
SGLang cache 3.08 s 2.94 s 9.02 s 19,939 54%
SGLang cache + KVStash 0.34 s 0.32 s 0.80 s 60,835 99%

FIGURE 2. First pass after an SGLang server restart, concurrency 16. Full study.

  • SGLang bench_serving, generated shared-prefix workload: 8k-token prefixes, 128 groups x 4 questions, 512 requests per pass.
  • One L40S, Qwen2.5-7B-Instruct BF16, SGLang host-memory pool 48 GB, KVStash response budget raised, store on the same host.
  • SGLang cache = GPU radix cache + host-memory HiCache.
  • One pass per row, 29 Oct 2026.
  • KVStash: 0 misses, 0 aborts in every pass.

The reuse in the SGLang cache row comes from requests in the same pass that share a prefix: after the restart, the first request for each prefix recomputes it and later ones hit the fresh GPU cache. With KVStash, the first request for each prefix also reads it back.

Failure cases matter as much as the speed-up

  • Store killed mid-load: 512/512 requests completed; SGLang recomputed. The engine falls back to recompute instead of failing requests.
  • Empty store after a restart: requests served; cache refilled (64/64, 75% reuse).
  • Store crash during writes: Daemon killed with SIGKILL during a write storm, 100 loops: 0 corrupt and 0 phantom blocks over 18,160 acknowledged writes. Linux crash-test harness; every acknowledged write either survived recovery byte-identical or was reported gone.
Limits of this result
  • One GPU per server, one model (Qwen2.5-7B BF16), 8k-token generated prefixes, store on the same host over loopback TCP, one pass per row.
  • On an H100 with 30k-token prefixes the gain was smaller: mean 6.35 s to 2.53 s, p99 12.54 s to 4.66 s, 81% of prompt tokens reused. The misses after that restart were capacity evictions, not errors.

Checklist: keeping the KV cache across restarts in production

  • Put stable content first.

    Reuse needs an exact prefix from the first token, in whole blocks or pages (64 tokens in our SGLang setup). System prompt, tool definitions and shared documents go first; per-user text goes last. A timestamp or request ID at the top defeats every option above.

  • Keep the cache identity fixed.

    Model and revision, KV precision, page or block size, parallelism, tokenizer, chat template and rope scaling must match, or the cached bytes are wrong for the model. Give each identity its own namespace or directory. A good store treats a mismatch as a miss; KVStash's correctness run included a wrong model identity and every case behaved correctly (r20261029-correct1).

  • Run the cache outside the engine's lifecycle.

    A separate process, and on Kubernetes a separate pod or node service, so a rolling deploy of the engine does not take the cache with it.

  • Size capacity from bytes per token.

    One 8,192-token prefix of Qwen2.5-7B in BF16 is about 470 MB. Multiply by the distinct prefixes you want to keep warm, plus room for what each pass writes. On SGLang, also size the host pool that stages reads (see below).

  • Warm up deliberately.

    After deploying a new model identity the store is empty for it. Replay your most common prefixes before moving traffic, or accept one cold pass.

  • Plan for the cache being unavailable.

    The engine must treat a missing or unreadable block as a miss and recompute. Kill the store during a load test and confirm every request completes.

  • Watch hits, misses and evictions.

    Alert when the hit rate falls after a deploy: it usually means the identity or the prompt prefix changed. Compare p99 time to first token before and after restarts.

  • Treat the cache like the prompts.

    Cached keys and values are derived from user content. Keep the store on a private network, authenticate clients and separate tenants.

On SGLang, size the host poolIn our SGLang load test, a 16 GB host-memory pool held reuse at 33-45% even though KVStash reported 0 misses; with a 48 GB pool and nothing else changed, reuse reached 99%. SGLang stages everything it reads from a storage tier through that pool. (L40S, 8k-token prefixes, 512 requests per pass, 29 Oct 2026.)

Frequently asked questions

Does vLLM keep its prefix cache after a restart?

Not by itself. vLLM's prefix cache lives in GPU memory and its CPU offload tier lives in host memory owned by the engine process, so both are gone when the process exits. To keep the cache you need a tier outside the process: vLLM's filesystem or object tiers, LMCache with a remote backend, or a separate KV-cache store such as PegaFlow, Lifeboat Cache, Mooncake or KVStash.

Does SGLang HiCache survive a restart?

Its L1 (GPU) and L2 (host memory) tiers do not: SGLang's docs say they are private to a single inference instance. Only the L3 storage backend can outlive the process, and only if that backend keeps its data, for example a file directory on disk or an external store that keeps running.

What happens if the cache store restarts, not the engine?

It depends on the store. With KVStash, blocks held only in DRAM are lost when the daemon restarts, blocks on the NVMe tier are recovered from its on-disk log, and blocks held only in S3 are currently treated as misses after a daemon restart. In every case the engine recomputes what it cannot read. We tested an empty store after a restart: requests were served and the cache refilled.

Can I reuse the cache after upgrading the model?

No. Keys and values depend on the exact weights, so a new model revision, a different KV precision, page size or parallelism layout needs a fresh cache. Use a new namespace or directory per model identity and let the old one age out.

How do I check that reuse after a restart is working?

Watch three things in the first minutes after the restart: the store's hit and miss counters, the share of prompt tokens the engine reports as cached, and p99 time to first token compared with the same traffic before the restart. If there are no hits, the usual causes are a changed cache identity, a token or namespace mismatch, or a prefix that changed at the start of the prompt.

Does this help autoscaling and spot instances too?

Yes, for the same reason: a new or replacement server that reads from a shared store starts with the cache other servers built. Three SGLang servers on one H100 machine sharing one KVStash on the same host (no network between them): the two servers reading what the first computed got 1.8-1.9x requests per second and 4x lower p99 TTFT, 98.5% of prompt tokens cached, 0 errors. With too little store memory they fell back to normal speed without errors (run r20261029-shared3b).

Restarts costing you warm-up time?

Tell us your engine, model, GPUs and how often servers restart or scale. We reply with what we would measure and whether a store is worth it for your traffic.

Or write to rudray@kvstash.com