SGLang HiCache storage backend for KVStash
The sglang-kvblockd package makes KVStash the storage tier under SGLang's GPU and host-memory caches, so a prefix one server computed is read back by other servers and after restarts.
- Status
- GPU-tested
- Adapter
- sglang-kvblockd
- Interface
- HiCache L3 storage, v1
- Tested on
- SGLang 0.5.15.post1
- GPUs
- L40S, H100
Last updated
How KVStash plugs into SGLang HiCache
HiCache has three levels: L1 is the GPU radix cache, L2 is a pool in host memory, and L3 is a pluggable storage backend (LMSYS: SGLang HiCache, SGLang HiCache docs). KVStash is an L3 backend.
SGLang serverone process per GPU server
- L1 GPU radix cache Hot pages in GPU memory
- L2 Host-memory pool Sized with --hicache-size; every page read from storage passes through it
- L3 sglang-kvblockd HiCache storage backend, writes and reads pages in KVStash
KVStash daemon
One store for every server. Survives engine restarts.
- DRAMhot
- NVMewarm
- S3cold
- No fork. SGLang loads the backend through its own dynamic backend factory, so SGLang itself is not modified.
- No extra copy. With
interface_v1: 1, page reads land directly in SGLang's pinned host-memory pool. - Explicit cache identity. The backend refuses to start without the weights revision, data types, layout and a SHA-256 of the effective model config (including RoPE scaling). Different identities do not share pages.
Configure SGLang to use KVStash
We checked 0.2.1 end to end on SGLang 0.5.23 (store, restart, reload; the reloaded answer is the one SGLang gives from its own prefix cache). It also ties keys to the host pool SGLang actually builds: in the same test, an engine restarted with --hicache-io-backend direct, which stores pages in another byte order, got clean misses instead of the first engine's pages. 0.2.0 shared those keys, so upgrade; the first run after upgrading is cold. The 0.1.0 package does not start on SGLang 0.5.16 and newer. The measurements on this page used SGLang 0.5.15.post1.
Install the adapter next to SGLang and add the storage backend flags to the launch command. These are the flags from our test runs.
pip install sglang-kvblockd # into the Python environment SGLang runs in
# run where the engine runs; pass the same cache settings (see the table below)
python -m sglang_kvblockd.identity MODEL --page-size 64
# stdout: the five identity values; stderr: the commit to launch with
python -m sglang.launch_server --model-path MODEL --revision COMMIT \
--page-size 64 \
--enable-hierarchical-cache --hicache-size 48 \
--hicache-mem-layout page_first --hicache-io-backend kernel \
--hicache-storage-backend dynamic \
--hicache-storage-backend-extra-config '{
"backend_name": "kvblockd",
"module_path": "sglang_kvblockd.backend",
"class_name": "KvblockdHiCacheStorage",
"interface_v1": 1,
"endpoint": "kvblockd://STORE_HOST:9440",
"namespace": "sglang",
"token": "YOUR_TOKEN",
"model_revision": "...", "model_dtype": "...", "kv_dtype": "...",
"cache_layout": "...", "model_config_hash": "..."
}' | Replace | With |
|---|---|
STORE_HOST:9440 | The KVStash daemon's address. Port 9440 is the data plane; keep it on a private network. |
namespace, token | The namespace and bearer token the daemon has for this engine. |
| The five identity values | The JSON printed by python -m sglang_kvblockd.identity. It pins the weights to a commit and hashes the model config with every cache setting you pass it: --dtype (default auto, resolved like SGLang), --kv-dtype, --page-size, --layout (page_first_direct when you use --hicache-io-backend direct), --quantization, --quantization-param-path and --config-override for --json-model-override-args. Run it again whenever any of them or the SGLang version changes. A local model directory needs --revision or --hash-weights. |
COMMIT | The commit the identity command pinned (it prints it). Launch SGLang with it so every server loads the same weights. |
--hicache-size | The host-memory pool, in GB. Size it for your traffic (see known limits). |
SGLang's default storage prefetch policy gives up on a fetch that takes too long and recomputes. --hicache-storage-prefetch-policy wait_complete waits for the whole fetch. We tested both.
Check it is working
The daemon's Prometheus metrics show whether pages arrive and come back. They are served on its metrics port, loopback by default: curl 127.0.0.1:9442/metrics.
- Send one long prompt.
kvb_bytes_total{dir="in"}rises as SGLang writes pages to KVStash. - Restart the SGLang server, not the daemon. Or point a second server with the same model and identity at the same namespace.
- Send the same prompt again.
kvb_hits_totalrises and time to first token drops.
Measured results with SGLang
Time to first token for one prompt, recomputed or read back from KVStash after the server's own caches were flushed. Full tables and raw data are on the benchmarks pages.
-
9.02 s→0.80 s
p99 time to first token after a server restart
The restarted server read its prefixes back from KVStash: mean 3.08 s to 0.34 s, 99% of prompt tokens reused, 3x input throughput.
L40S, 8k-token shared prefixes, 512 requests, concurrency 16, SGLang 0.5.15.post1 + Qwen2.5-7B BF16, 29 Oct 2026, one pass. Both modes: SGLang host pool 48 GB. The KVStash side also has an 80 GiB DRAM store on the same machine that the baseline does not, and a raised response budget. With default settings, on a smaller workload (32 groups, two passes): mean 1.9 s to 0.5 s, p99 8.3 s to 1.2 s. Study
-
34%→73%
Prompt tokens reused by a second server on the same machine
Server B read what server A had computed. Mean time to first token went from 2.50 s to 1.65 s.
Server A computes 128 prompts with 8k-token shared prefixes; server B (separate process and GPU memory, same machine) then receives the same prompts. Server B shown. One H100, both servers and the store on the same machine, SGLang host-memory pool 8 GB, 29 Oct 2026. Without a shared store, B cannot use what A computed.
-
12/12
Outputs identical to SGLang's own cache
The same prompts at the same reuse split, with the prefix read from SGLang's GPU cache or from KVStash. KVStash returns the bytes SGLang wrote.
12 prompts, each reusing the same 6,976-token prefix either from SGLang's own GPU cache or from KVStash after a verified flush. SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S, default settings, 29 Oct 2026. Run r20261029-parity1.
Tested setup
The conditions behind every SGLang result on this page.
| Engine | SGLang 0.5.15.post1 (official cu129 runtime image), HiCache with KVStash as the storage tier, page size 64 |
|---|---|
| Model | Qwen/Qwen2.5-7B-Instruct (revision a09a3545), BF16 weights and KV cache (57,344 bytes per token), one GPU |
| GPU | NVIDIA L40S 48 GB on Modal (some runs on H100 80 GB) |
| Store | KVStash daemon on the same host as the GPU server, reached over TCP (loopback), DRAM arena unless stated |
| Long context | YaRN x4 rope scaling for prompts above 32k tokens |
| Dates | 29-30 October 2026 |
Known limits
SGLang stages every page it reads from storage through its host-memory pool, so the pool caps how much KVStash can return at once. With a 16 GB host-memory pool, prompt reuse through KVStash plateaued at 33-45% even with 0 KVStash misses. With 48 GB and nothing else changed, it reached 99%.
SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S, 8k-token shared prefixes, 512 requests per pass, 29 Oct 2026. SGLang's own cache also improves with a larger pool, so both were compared at the same size.
- Performance numbers are from 0.5.15.post1. The latest release as of November 2026, 0.5.23, is GPU-tested for correctness with sglang-kvblockd 0.2.1, not benchmarked. See how we track releases.
- KV-derived host pools are not supported yet. SGLang 0.5.22 added host-memory pools derived from the KV pool. The backend cannot map them: it logs an error and returns misses, so SGLang recomputes.
- Tensor parallel above 1 is not tested. Page keys include the parallel rank and size, but every published run used one GPU per server.
- HiCache v2 is not implemented. The v2 controller interface is still changing upstream (sgl-project/sglang#18239); the backend implements v1.
- S3 tier not measured under SGLang. Results use the DRAM tier, plus one NVMe-tier run on a cloud container disk.
- One model, one host. Tests used Qwen2.5-7B-Instruct with the store on the GPU machine. Larger models and a store across the network are not yet measured.
SGLang integration FAQ
Which SGLang version does KVStash support?
The measurements on this site used SGLang 0.5.15.post1 (official cu129 runtime image, L40S and H100). sglang-kvblockd 0.2.1 is also checked end to end on 0.5.23, the latest release as of November 2026, with the official image: it stores, reloads after a restart and gives the answer SGLang gives from its own prefix cache.
Do I still need SGLang's host-memory cache?
Yes. KVStash is the L3 tier under SGLang's GPU (L1) and host-memory (L2) caches, and SGLang stages every page it reads from storage through its host-memory pool. Size that pool (--hicache-size) for your traffic: in our L40S load test, raising it from 16 GB to 48 GB took prompt reuse from 33-45% to 99%.
What page size and layout does the backend need?
We test with --page-size 64 and --hicache-mem-layout page_first. The backend maps SGLang's page-first host layouts directly; on another layout it logs an error and returns misses, so SGLang recomputes.
What happens if the KVStash daemon stops?
SGLang recomputes the prompt as if the page were not cached. We killed the daemon with SIGKILL during a 512-request load test: all 512 requests completed, at normal recompute speed.
Can several SGLang servers share one KVStash?
Yes, if they run the same model with the same cache identity and connect to the same namespace. In our H100 test, a second server on the same machine, reading prompts the first had computed, went from 34% to 73% of prompt tokens reused. Tensor parallel above 1 is not tested yet.
Running SGLang with long, repeated prompts?
Tell us your SGLang version, model, GPUs and how often the same context comes back. We reply with what we would measure and when KVStash is not worth it.
Or write to rudray@kvstash.com