Guide

KV cache offloading, explained

Where the attention cache can live outside GPU memory, when reading it back beats recomputing it, and what vLLM, SGLang, LMCache, Mooncake, Dynamo and KVStash each do about it.

Last updated

15 minute read, sources linked inline

On this page
  1. What is KV cache offloading?
  2. Why the KV cache gets lost
  3. Where the KV cache can go
  4. When reloading beats recomputing
  5. How vLLM and SGLang offload
  6. LMCache, Mooncake, Dynamo and others
  7. Who does this in production
  8. How to measure offloading
  9. When offloading does not help
  10. FAQ

KV cache offloading is moving a language model's attention cache (the keys and values computed for earlier tokens) out of GPU memory into larger, cheaper storage such as CPU DRAM, local NVMe, a remote store or object storage, so the engine can load it back later instead of recomputing it.

What is KV cache offloading?

Before a model writes its first output token it has to process the whole prompt. That step, called prefill, produces a key and a value vector for every token in every layer: the KV cache. The engine keeps it in GPU memory while a request runs and, with prefix caching, for a while afterwards, so a later request that starts with the same tokens can skip that work (vLLM prefix caching, SGLang RadixAttention).

GPU memory is small next to the amount of context worth keeping. Offloading adds tiers below it. When a request arrives whose prefix was computed before, the engine looks for the blocks in those tiers, copies what it finds back to the GPU and computes only the new tokens.

How KV cache offloading works GPU memory holds blocks for running requests. When it fills, cold blocks are offloaded to a larger tier such as DRAM, NVMe, a remote store or S3. When a later request repeats the same prefix, those blocks are read back to the GPU and only the new tokens at the end of the prompt are computed. GPU memory Fast, small, private to the engine in use cold Offload tier DRAM, NVMe, remote store or S3 Larger; can outlive the engine 1. Offload cold blocks 2. Read back when the prefix repeats The next request with the same prefix Cached prefix: read back, not recomputed 3. New tokens: computed How KV cache offloading works GPU memory holds blocks for running requests. When it fills, cold blocks are offloaded to a larger tier such as DRAM, NVMe, a remote store or S3. When a later request repeats the same prefix, those blocks are read back to the GPU and only the new tokens are computed. GPU memory Fast, small, private to the engine in use cold 1. Offload cold blocks 2. Read back on a repeat Offload tier DRAM, NVMe, remote store or S3 Larger; can outlive the engine The next request, same prefix Cached prefix: read back 3. New Only the new tokens are computed.
FIGURE 1. Cold blocks move down to a tier with more room. When the same prefix returns, they are read back and only the new tokens are computed.

For long prompts this is often much faster than prefill. In our own SGLang test, a 110,016-token prompt took 20.8 s to recompute and 1.52 s to read back (conditions below).

The idea is older than the current engines. CachedAttention (USENIX ATC 2024) kept multi-turn KV caches in cheaper memory and storage and reported up to 87% lower time to first token. Mooncake (FAST 2025) built a disaggregated KV cache from the CPU, DRAM and SSD of a GPU cluster. LMCache moves the KV cache out of vLLM and SGLang into outside storage. What changed in 2025 and 2026 is that the engines now ship offloading paths of their own, and many stores plug into them.

Why does the KV cache get lost?

An engine reuses a prefix only while its blocks are still where the engine can find them. Four things take them away, and each one turns into extra prefill: GPU time spent again, and a longer wait for the first token.

Eviction
Weights, activations and every running request share GPU memory. When it fills, the engine drops cached blocks, usually least recently used first (vLLM documents LRU). A long document that has not been used for a few minutes goes first.
Restarts
A new model version, a config change, a crash, a node drain or a spot reclaim ends the engine process, and its GPU and host-memory caches with it. See keeping the cache across restarts.
More than one server
Behind a load balancer each replica builds its own cache. Server B recomputes what server A computed a minute earlier, unless both read from a shared tier.
Split prefill and decode
In disaggregated serving, one GPU pool runs prefill and another runs decode, so the cache has to move between machines anyway. The same transfer path is often reused for offloading.

Where can the KV cache go?

There are five common places. Each step down trades speed for capacity, and the lower tiers can outlive the engine process and be shared between servers. The figures are examples from vendor specifications, not measurements of one system: the real limit is usually how the engine copies blocks.

  1. GPU memory

    HBM, or GDDR on cards such as the L40S

    • Lost on restart
    • One server
    Capacity
    80 GB per H100 SXM, 48 GB per L40S (H100, L40S)
    Bandwidth
    3.35 TB/s on H100 SXM, 864 GB/s on L40S
    Latency
    None: attention runs here
  2. CPU DRAM

    Host memory on the GPU server

    • Kept if outside the engine
    • Same host only
    Capacity
    2 TiB on an AWS p5.48xlarge with 8 H100s (AWS P5)
    Bandwidth
    Set by PCIe to the GPU: Gen5 128 GB/s bidirectional per H100, Gen4 x16 64 GB/s per L40S
  3. Local NVMe

    SSDs inside the GPU server

    • Kept if the index is rebuilt
    • One server
    Capacity
    8 x 3.84 TB on a p5.48xlarge, up to 30.72 TB per drive (Micron 9550)
    Bandwidth
    14.0 GB/s sequential read per PCIe Gen5 drive, then PCIe to the GPU
  4. Remote store

    Other machines, over the network

    • Survives restarts
    • Shared by servers
    Capacity
    The pooled DRAM and NVMe of the store machines
    Bandwidth
    100 GbE is about 12.5 GB/s before protocol overhead; Mooncake reports 87 GB/s on 4 x 200 Gbps RoCE (README)
    Latency
    A network round trip plus the store's own work
  5. Object storage

    S3 and S3-compatible buckets

    • Survives restarts
    • Shared by servers
    Capacity
    Sized by the bucket, billed per GB stored
    Bandwidth
    Scales with parallel connections and byte-range GETs (AWS guidelines)
    Latency
    Median often tens of milliseconds for requests under 512 KB; S3 Express One Zone is designed for single-digit milliseconds (AWS)
FIGURE 2. Example figures as each linked source stated them on 4 November 2026. Bandwidth to the GPU is bounded by the slowest link in the path.

To make capacity concrete: Qwen2.5-7B in BF16 uses 57,344 bytes of KV cache per token (how that is worked out). The chart shows how many tokens of it each tier in one AWS p5.48xlarge could hold if it held nothing else. The GPU never holds only cache: weights and activations come first.

FIGURE 3. Capacity divided by 57,344 bytes per token, before weights, activations or any overhead. Use the KV cache calculator for your own model and precision.
Two choices matter as much as the tier
  • Where the index lives decides whether a tier is still useful after a restart. Blocks on disk are worthless if nothing remembers which prefix they belong to.
  • Who evicts decides whether the tier stays healthy. A shared filesystem with no eviction fills up, which is why llm-d pairs its filesystem tier with a separate evictor job.

When is reloading faster than recomputing?

Reloading wins when moving the cached bytes to the GPU takes less time than computing them again:

fixed cost + bytes per token × prefix tokenseffective bandwidth < prefill time for those tokens

The left side grows in a straight line with the prefix: twice the tokens, twice the bytes. The right side grows faster, because each new token attends to every token before it, so the attention part of prefill grows with the square of the length. That is why offloading pays more as prompts get longer, and why the break-even depends on your GPU, model and precision.

Worked example: one 110k-token prompt

20.8 s→1.52 s

Qwen2.5-7B-Instruct in BF16: 110,016 tokens x 57,344 bytes = 6.31 GB of KV cache in 3,436 blocks, on one L40S.

Recompute
20.8 s to the first token, about 189 microseconds per prompt token.
Fixed cost
0.26 s to tokenise the text prompt and schedule it. A GPU cache hit pays this too.
Transfer
1.26 s to move 6.31 GB at about 5.0 GB/s end to end, roughly 11 microseconds per token.
Result
13.7x on this machine, and 13‑19x faster time to first token than recomputing, across 8 runs on separate machines (median about 14x).

About 5.0 GB/s is well below what the L40S's PCIe Gen4 link allows. In SGLang the transfer from the store into host memory and the copy from host memory to the GPU run one after the other; overlapping them is the next large gain and needs an engine change. The same holds for any offloading system: the engine's copy path and the store's read path set the rate together, not the datasheet of the slowest device.

PromptKV cacheRecomputeRead backFaster by
8,016 tokens 0.46 GB 0.64 s 0.12 s 5.3x
32,016 tokens 1.84 GB 3.38 s 0.42 s 8.0x
64,016 tokens 3.67 GB 9.03 s 0.85 s 10.6x
110,016 tokens 6.31 GB 20.80 s 1.52 s 13.7x

FIGURE 4. Time to first token, recompute against a read from KVStash, by prompt length. Full study and method.

  • SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S, KVStash on the same host, default settings, median of 5 reads per point after a verified cache flush.
  • Run r20261029-sweep1, 29 Oct 2026.

How to estimate it for your setup

  1. Bytes per token for your model and precision (calculator). Grouped-query attention, multi-latent attention and FP8 caches all shrink it.
  2. Prefill time at two or three prompt lengths on your GPU, with every cache flushed.
  3. Effective read rate of your offload path, measured end to end, not taken from a datasheet.
  4. Fixed cost per request, which a GPU cache hit also pays.
  5. Compare. A slower link moves the break-even to longer prompts: reading 6.31 GB over 100 GbE takes at least half a second on the wire alone.
Slower tiers move the break-even, not the gain

Measured on KVStash's NVMe tier. 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).

How do vLLM and SGLang offload the KV cache today?

Both engines now ship their own offloading, and most outside stores plug into these paths rather than patching the engine.

vLLM: the offloading connector and tiers

vLLM's OffloadingConnector is set through --kv-transfer-config. Its default spec keeps one CPU tier, sized by cpu_bytes_to_use. The tiering spec adds secondary tiers below it; the CPU tier stages every GPU transfer.

  • fs writes blocks as files under a root directory, in a subdirectory named from the model and a digest of the run configuration, so different configurations do not collide.
  • obj writes to an S3-compatible bucket through the NIXL object backend.
  • p2p shares blocks between vLLM instances over RDMA through NIXL, with no shared filesystem.
  • Out-of-tree tiers, policies and specs load by module_path.

The primary tier evicts with LRU by default, or ARC. The vLLM team's September 2026 post says tiering has shipped since v0.22, describes a host layout that lets nodes with different GPUs or parallelism share chunks, and reports more than double the prefill throughput of the alternatives on 2 x H100 with a filesystem tier on local NVMe, once the conversation pool outgrew GPU and CPU memory.

SGLang: HiCache L1, L2 and L3

SGLang's HiCache has three levels: L1 is the GPU pool, L2 is host memory (--hicache-ratio or --hicache-size), and L3 is an optional storage backend chosen with --hicache-storage-backend. The docs are explicit: "L1 and L2 are private to a single inference instance; only L3 can be shared." Built-in backends include a local file store, Mooncake, 3FS, NIXL and AIBrix, and a dynamic loader takes any class that implements get, exists and set.

Size the host poolSGLang stages everything it reads from L3 through the L2 host pool, so a small pool caps how much of a stored prefix can be used at once, however fast the backend is.

What do LMCache, Mooncake, Dynamo KVBM and other stores add?

The engines' built-in tiers cover one server well. The projects below add sharing across servers, more storage targets, transfer engines for fast networks and management features. Each row summarises the project's own documentation; LMCache alternatives goes deeper.

  • vLLM native tiers

    Built into vLLM 0.22 and later

    Cache lives in
    CPU memory, then a filesystem, S3-compatible objects or peer servers
    Transport
    NIXL and UCX
    Adds
    No extra service to run; LRU or ARC on the CPU tier; a canonical layout shared across parallelism settings
  • SGLang HiCache backends

    Built into SGLang

    Cache lives in
    GPU, host memory, then one L3 storage backend
    Transport
    Depends on the backend
    Adds
    Pluggable L3 (file, Mooncake, 3FS, NIXL, AIBrix or your own class), attached at runtime
  • LMCache

    Library and server under vLLM and SGLang

    Cache lives in
    CPU, local disk and 19 storage adapters, including S3, Redis or Valkey, Mooncake Store and 3FS
    Transport
    NIXL over NVLink, RDMA or TCP
    Adds
    CacheGen compression, CacheBlend, peer sharing, prefill-decode transfer, Grafana dashboards
  • Mooncake Store

    Distributed store with a master and clients

    Cache lives in
    DRAM pooled across nodes, optional SSD offload, S3-compatible spill
    Transport
    TCP by default in the client; RDMA, EFA, NVLink and CXL
    Adds
    Lease TTL, soft pins, watermark eviction, replication, etcd high availability
  • NVIDIA Dynamo KVBM

    KV block manager in NVIDIA Dynamo

    Cache lives in
    G1 GPU, G2 CPU, G3 disk, G4 S3-compatible object store
    Transport
    NIXL: UCX and RDMA, GPUDirect Storage, TCP through UCX
    Adds
    Offload filters, KV-aware routing in Dynamo, Grafana dashboards; vLLM and TensorRT-LLM integrations
  • Storage vendors

    WEKA, VAST, DDN and others

    Cache lives in
    The vendor's storage cluster or appliance
    Transport
    RDMA and GPUDirect Storage
    Adds
    Large shared capacity, reached through NIXL, LMCache or Dynamo; priced by quote
  • KVStash

    One Go daemon under SGLang and vLLM; daemon a free download, adapters on PyPI

    Cache lives in
    DRAM, then NVMe, then S3, inside the daemon
    Transport
    Batched multi-stream TCP; no RDMA
    Adds
    Leases, pins and TTL; S3-FIFO eviction in DRAM; namespaces with bearer tokens; per-block checksums verified on NVMe and S3 reads; Prometheus metrics
Summaries of each project's public documentation, checked 3-4 November 2026. Corrections welcome.
Where KVStash is weaker today
  • No RDMA or GPUDirect path, so on fast fabrics, transfer engines built for them move more bytes per second.
  • No compression or cache blending: blocks are opaque bytes by design.
  • Younger than every project above, with no public documentation site, container image or Helm chart yet.
  • GPU-tested on SGLang 0.5.15.post1, 0.5.23 and vLLM 0.25.1, 0.27.1, 0.33.0, behind the current releases. The LMCache path is not GPU-qualified, and the S3 tier has not been measured under SGLang.

Who already does this in production?

Keeping KV caches on storage is established practice at large model providers. Three public examples, with figures as each provider states them. They are other teams' systems on their own hardware, so their figures are not comparable with ours or with each other.

  • DeepSeek

    Context caching on disk for its API since 2 August 2024, on "a distributed disk array", matched by prefix and cleared when unused. DeepSeek states first-token latency for a 128K prompt with high reuse fell from 13 s to 500 ms (announcement, guide). In February 2025 it reported 56.3% of input tokens in one 24-hour window hitting the on-disk cache (inference overview). Its file system 3FS lists KV caching as a use case.

  • Moonshot AI

    Serves Kimi on Mooncake, which pools CPU, DRAM and SSD across the GPU cluster. The FAST 2025 paper reports 115% and 107% more requests handled on A800 and H800 clusters, and over 100 billion tokens a day across thousands of nodes (paper).

  • AWS

    Launched a managed tiered KV cache for SageMaker HyperPod in November 2025, with a CPU tier and a second tier on HyperPod storage or Redis (announcement).

How do you measure KV cache offloading?

Most published offloading numbers are hard to reproduce because the cache state during the test is unclear. A fair test controls where the cache can come from.

  1. Pin the setup. Record engine and version, model and revision, weight and KV precision, GPU, page size, prompt length and date. Change one thing at a time.
  2. Run cold. Recompute the whole prompt with every cache empty. This is the baseline.
  3. Flush, then check the flush. Empty the engine's own GPU and host caches so the prefix can only come from the tier under test. In SGLang, /flush_cache clears the radix cache; check host-memory tiers too, or restart the engine.
  4. Run warm. Send the same prefix with a new suffix, at least five times, and report the median.
  5. Test under load. Single requests hide queueing. Use a serving benchmark at realistic concurrency and report p50 and p99 time to first token and input tokens per second.
  6. Read the counters. vLLM exports vllm:prefix_cache_hits and vllm:time_to_first_token_seconds (metrics); a store should report hits, misses and bytes. KVStash exposes these on /metrics.
  7. Check outputs. Compare generated text with the engine's own cache at the same reuse split, not with no cache at all.
  8. Break it on purpose. Kill the store mid-load, corrupt a block, change the model, cancel requests. The engine should fall back to recompute and return correct output.

How we measured the figures on this page. Cold = the whole prompt recomputed. KVStash = the server's GPU and host caches flushed and verified empty, so the prefix can only come from KVStash. Time to first token (TTFT) measured at the client.

When does offloading not help?

  • Prompts are short or unique. Nothing repeats, so nothing is reused.
  • Only the end of the prompt repeats. Prefix caching needs an exact match from the first token. Put stable parts first.
  • The working set already fits. If GPU and host memory hold every prefix you reuse, a lower tier adds cost and moving parts.
  • The read path is slower than prefill. A slow network, one ranged read at a time from object storage, or a small staging buffer can make reloading lose. Measure.
  • You use a hosted API. Providers such as DeepSeek run their own cache; offloading is for engines you operate.

Frequently asked questions

Is KV cache offloading the same as prefix caching?

They work together. Prefix caching is the rule for reuse: if a new request starts with exactly the same tokens as an earlier one, the engine can skip computing that part. Offloading is where the cached keys and values are kept when they no longer fit in GPU memory: CPU DRAM, local NVMe, a remote store or object storage. Without offloading, prefix caching only helps while the prefix is still in GPU memory.

Does offloading the KV cache change the model's output?

It should not, as long as the stored bytes come back unchanged and the cache identity (model, revision, precision, layout) matches. Lossy compression of the cache is a different trade-off. In our SGLang test, outputs with KVStash matched SGLang's own cache at the same reuse split in 12 of 12 cases.

Can I offload the KV cache to S3?

Yes. vLLM's offloading connector has an S3-compatible object tier through NIXL, NVIDIA Dynamo KVBM has an S3-compatible G4 tier, LMCache has an S3 adapter, Mooncake can spill from SSD to S3-compatible storage, and KVStash has an S3 tier behind NVMe. Object storage has far higher per-request latency than DRAM or NVMe (AWS quotes median latencies in the tens of milliseconds for small requests), so it works as a deep tier read with many parallel ranged requests, not as the first place to look.

How much memory does the KV cache need?

Bytes per token = 2 x layers x KV heads x head dimension x bytes per value. For Qwen2.5-7B in BF16 that is 57,344 bytes per token, so a 110,016-token prompt is 6.31 GB. Multiply by the number of distinct prefixes you want to keep. The KVStash KV cache calculator does this for common models.

Do I need RDMA to offload the KV cache to another machine?

No. RDMA and GPUDirect raise bandwidth and cut CPU work, and several systems use them by default, but TCP works too: the Mooncake store client defaults to TCP and KVStash runs over plain TCP. What matters is whether the read finishes sooner than recomputing the prefix on your GPU, which you can work out from bytes per token, prompt length and the bandwidth you actually get.

Does offloading help short prompts?

Less. Recompute time grows faster than the size of the cache as prompts get longer, so the gain grows with length. In our SGLang sweep on one L40S, reading the prefix was 5.3x faster than recomputing at 8k tokens and 13.7x at 110k tokens. We have not measured below 8k tokens; fixed per-request costs weigh more as prompts get shorter, and unique prompts gain nothing.

Something here out of date? Tell us and we will correct it.

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