How KVStash works
KVStash is one daemon that stores the KV-cache blocks your engines compute, in DRAM, NVMe and S3, and serves them back to any server over plain TCP, so a prefix computed once is read instead of recomputed.
- Runs as
- One daemon, kvblockd
- Tiers
- DRAM, NVMe, S3
- Network
- Plain TCP, no RDMA
- Engines
- SGLang, vLLM
- Hosting
- Self-hosted
Last updated
Where KVStash sits: under the engine, beside the GPU servers.
The engine still runs the model and keeps its own GPU and host-memory cache. KVStash is the shared layer underneath, reached over the network, so work done on one server is there for every other server and after every restart.
The engine
vLLM or SGLang runs the model, schedules requests and keeps its own GPU and host-memory cache, as it does today.
The adapter
A small Python package inside each engine process. It writes finished KV-cache blocks to KVStash and asks for them back.
The daemon
One kvblockd process serves many engine servers. It keeps opaque blocks in DRAM, NVMe and S3 and does not read tensors.
How a prompt prefix is stored and reused.
Four stages, the same on every engine. The rule that decides what comes back is in stage three: only an exact prefix counts.
-
Store
After the engine reads a prompt (prefill), the adapter cuts its KV cache into blocks and writes them in batches. Each key hashes the whole prefix up to that block plus the model identity.
Blocks are write-once, opaque bytes with a checksum.
-
Keep
Blocks land in DRAM. Colder ones move to NVMe and then S3, and eviction honours leases, pins, TTLs and each namespace's quotas.
Every read takes a 5 s lease by default.
-
Find
When a request reaches any server, the adapter sends all of the prompt's block keys in one batched call. KVStash answers with how many consecutive blocks it holds from the start.
A block counts only if every block before it is there.
-
Continue
The adapter reads those blocks over several TCP streams into the engine's buffers. The engine computes only the tokens after the last stored block.
A missing, slow or damaged block is a miss: recomputed.
- 1First requestA long document, then a question
All 16 blocks computed, then written to KVStash.
- 2Same document, new questionAny server, any time later
14 blocks read back; only the new question is computed.
- 3Document edited at block 4The rest of the text is unchanged
3 blocks read. Block 4 changed, so it and every block after it are computed.
DRAM, NVMe and S3: what each tier does.
One daemon manages all three. Only DRAM is required; NVMe adds capacity and S3 adds retention, each switched on in the config.
- DRAM Required
The hot working set, in one memory arena you size.
- Blocks arrive
- Every write lands here.
- Blocks leave
- At 95% full, S3-FIFO evicts a batch. With NVMe configured, blocks are demoted at 90% full instead.
- Plan for
- Contents are lost if the daemon or its host goes down. Too small an arena shows up as misses, not errors.
- NVMe Optional
Blocks demoted from DRAM, in append-only 256 MiB segments on local drives.
- Blocks arrive
- Blocks read at least once are written to flash; the rest are dropped at demotion.
- Blocks leave
- A second hit within 60 s promotes a block back to DRAM.
- Plan for
- Drive endurance and read speed. The tier is recovered from its segment log after a restart.
- S3 Optional, needs NVMe
Sealed NVMe segments, one S3 object each, for the long tail.
- Blocks arrive
- Sealed segments are copied to the bucket in the background; local reads continue.
- Blocks leave
- Once a local segment is reclaimed, its blocks are served by ranged GETs, checksum-verified first.
- Plan for
- Request latency (a read slower than 2 s is a miss), request charges, one node id per daemon.
# kvblockd.yaml: the three tiers
dram_arena_bytes: 1073741824 # 1 GiB hot tier, the only required one
eviction_policy: "s3fifo" # or sampled-lru, none
nvme_paths: ["/mnt/nvme0/kvb"] # warm tier, one directory per drive
nvme_max_bytes: 3400000000000 # budget across drives
nvme_admit_min_hits: 1 # 0 also admits blocks not yet read
s3_bucket: "your-kv-bucket" # cold tier, needs nvme_paths
s3_node_id: "node-a" # unique per daemon
# S3 credentials come from the host's AWS credential chain Keys and defaults from the daemon's example config. Workloads that write once and read later set nvme_admit_min_hits: 0.
Measured: NVMe tier
3.6 s→0.77 s
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).
Not measured yet: S3 tier
We have not benchmarked the S3 tier under SGLang, so this site publishes no S3 latency or throughput figures. If S3 retention matters to you, we will measure it with you on your bucket and region.
What the store manages for you.
The parts of running a shared cache that are easy to get wrong, handled inside the daemon rather than in each engine.
Leases, pins and TTL
A read takes a short lease so a block is not evicted mid-transfer. Clients can pin blocks, within a per-namespace pin quota, and set TTLs.
Eviction
S3-FIFO is the default DRAM policy; sampled-LRU or a hard wall that refuses writes when full can be selected.
Namespaces and quotas
Each tenant is a namespace with its own bearer token and byte quotas per tier. Tenants sharing a daemon see only their own blocks.
Checksums
Every block carries an xxh3 checksum, verified on NVMe and S3 reads; frame headers carry CRC32C. A block that fails is a miss.
Metrics and health
Prometheus /metrics for hits, misses, bytes, evictions, tier movement, checksum errors, auth failures and per-tenant quotas, plus /healthz.
Batched, multi-stream TCP
Many keys per request over several streams, on the network you already run. No RDMA or special network card.
What happens when something fails.
KVStash is built to fail open: anything the adapter cannot read becomes a cache miss, and the engine recomputes it. These are the cases we have tested.
| What we tested | Result | Run |
|---|---|---|
| Output matches SGLang's own cache at the same reuse split | 12/12 identical | r20261029-parity1 |
| Store killed (SIGKILL) during a 512-request load | 512/512 requests completed; SGLang recomputed | Load test |
| Empty store after a restart | requests served; cache refilled (64/64, 75% reuse) | Load test |
| Partial prefix, request cancellation, store killed mid-read, wrong model identity | all correct | r20261029-correct1 |
| Bytes flipped in the NVMe tier | 47 checksum errors caught; no damaged block reached an output | r20261029-correct1 |
| Cost of checksum verification | about 20 ms on a 28k-token prompt | r20261029-correct1 |
| Daemon killed with SIGKILL during a write storm, 100 loops (store only) | 0 corrupt and 0 phantom blocks over 18,160 acknowledged writes | Crash-test harness |
Not tested yet
- An S3 outage under a serving engine.
- A KVStash daemon on a separate machine under SGLang load; the SGLang studies ran the store on the GPU host.
What KVStash is not.
Knowing the edges saves an evaluation. KVStash is a storage layer and nothing more.
- Not a semantic or response cache. It does not store answers or match similar questions; reuse needs an exact prefix.
- Not a router. It does not choose which server gets a request. Keep your load balancer or cache-aware router.
- Not an inference engine. vLLM or SGLang still runs the model.
- No compression or blending. Blocks come back exactly as the engine produced them; non-prefix reuse is not supported.
- No RDMA. This version uses TCP only, over the network you already run.
- Not a hosted service. You run the daemon in your own infrastructure.
Which engines KVStash works with.
Each adapter uses an interface the engine already has. Status says exactly what we have tested. All integrations
- SGLang Storage backend (L3) for HiCache, SGLang's hierarchical cache. sglang-kvblockd Tested on 0.5.15.post1, 0.5.23 GPU-tested
- vLLM Native KV connector, set with one vLLM flag. vllm-kvblockd Tested on 0.25.1, 0.27.1, 0.33.0 GPU-tested
- LMCache Remote storage plugin, loaded by name from the LMCache config. lmcache-kvblockd LMCache 0.5.6 (not recommended) Path exists
Security boundary in brief.
KVStash is self-hosted, so cached data stays in your infrastructure. Treat KV-cache blocks as sensitive as the prompts they came from.
Read the security page- Every connection starts with a HELLO frame carrying a namespace and bearer token; the server stamps that namespace on every operation.
- The data plane is plaintext TCP with bearer tokens. Keep it on a private network; TLS on the data plane is not available yet.
- The metrics endpoint listens on loopback by default.
- S3 credentials come only from the host's AWS credential chain, not from the config file.
Product questions.
Short answers. The evidence behind them is on the benchmark and security pages.
Is KVStash a response cache or a semantic cache?
No. KVStash stores the KV cache, the attention state an engine computes while reading a prompt. The model still generates a fresh answer for every request. Reuse needs an exact prefix from the first token; similar-looking questions do not match.
Do I have to modify vLLM or SGLang?
No fork is needed. You install a small Python adapter next to the engine (sglang-kvblockd or vllm-kvblockd) and point the engine's existing storage or KV connector setting at it. The KVStash daemon runs as its own process, on the same host or on another machine on your private network.
What happens if a block is missing, damaged or the store is down?
The engine recomputes what it could not read, as it would without KVStash. In our tests the store was killed with SIGKILL during a 512-request SGLang load and all 512 requests completed; 47 deliberately corrupted NVMe blocks were caught by their checksums and none reached an output.
What storage does KVStash need?
Memory to start: the DRAM tier is the only one required. Add local NVMe directories for more capacity, and an S3 bucket (which needs the NVMe tier) for the long tail. S3 credentials come from the standard AWS credential chain of the host, not from the KVStash config file.
Does KVStash need to understand my model?
No. Blocks are opaque bytes and the store does not read tensors or model shapes. The adapter folds the model identity (model, revision, data types, cache layout) into every block key, so different models or settings that share a store do not read each other's blocks.
Has the S3 tier been benchmarked?
Not under SGLang yet, so we publish no S3 performance numbers. The tier is implemented: sealed NVMe segments are copied to the bucket, read back with ranged GETs and checksum-verified before any byte is returned. Measure it on your own bucket and region before relying on 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