Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.2.1 instead.
Reason given by maintainers: some glitches

sglang-kvblockd

SGLang HiCache storage backend for KVStash. KVStash becomes SGLang's third cache tier, under GPU and host memory: a restarted SGLang server, or a second one serving the same model, loads prompt KV from the KVStash daemon instead of recomputing it.

Tested with SGLang 0.5.23 (the official lmsysorg/sglang:v0.5.23 image) and 0.5.15.post1, tensor parallel 1.

Install

pip install sglang-kvblockd

Configure

The backend only shares KV between engines that declare the same weights and cache encoding. Generate that identity with the same dtype, KV dtype and page size the engine runs with:

python -m sglang_kvblockd.identity Qwen/Qwen2.5-0.5B-Instruct \
  --dtype bfloat16 --kv-dtype bfloat16 --page-size 64

It prints five fields (model_revision, model_dtype, kv_dtype, cache_layout, model_config_hash). Put them in the storage extra config next to the connection settings:

python -m sglang.launch_server --model-path Qwen/Qwen2.5-0.5B-Instruct \
  --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": "..."
  }'

STORE_HOST:9440 is the daemon's data port; keep it on a private network. The namespace and token must match an entry in the daemon's namespaces.yaml.

Cache identity

  • A Hugging Face model id is pinned to the commit it resolves to when you run the helper. A local directory needs --revision (a commit or a digest of the weights) unless it is a Hugging Face snapshot directory.
  • Pass --rope-override with the JSON the engine applies on top of config.json (for example a YaRN rope_scaling), so it enters the hash.
  • Missing or contradictory identity fields stop the backend from starting. They are declarations, not a check of the loaded weight bytes: regenerate them whenever the model, dtype, KV dtype, page size or SGLang version changes. A different identity gives different keys, so old pages are never read and simply expire.

Tuning

streams (default 16) sets the connections to the daemon and get_fanout (default min(16, streams), from 1 through streams) how many of them a load uses in parallel. On an L40S with SGLang 0.5.15.post1 and a 110k-token prefix, 4 shards gave 12x faster time to first token than a cold prefill, 16 gave 18.7x and 32 no more. Measure on your own hosts; machines with fewer CPU cores may do better with smaller values.

Size SGLang's host-memory pool (--hicache-size) for your traffic: every page read from KVStash passes through it.

Limits

  • Host layout page_first only. Other layouts log an error and return misses, so SGLang recomputes.
  • Decode context parallel (dcp_size above 1) is refused at start-up.
  • Tensor parallel above 1 is not tested yet.
  • If the daemon is unreachable, requests recompute at normal speed.

Experimental modules

sglang_kvblockd.redknot (RedKnot fork integration) and sglang_kvblockd.dca_readout (Qwen DCA final-prompt readout) are opt-in and not enabled by importing the package. Ask before using them in production: https://kvstash.com/contact/

Metadata

Release files for sglang-kvblockd 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sglang-kvblockd 0.2.0
File Size Uploaded Provenance Actions
sglang_kvblockd-0.2.0.tar.gz 241.5 kB Without provenance Details for sglang_kvblockd-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sglang-kvblockd 0.2.0
File Interpreter ABI Platform Actions
sglang_kvblockd-0.2.0-py3-none-any.whl Python 3 none any Details for sglang_kvblockd-0.2.0-py3-none-any.whl

Total release size: 282.6 kB

Release files / sglang_kvblockd-0.2.0.tar.gz

Download URL sglang_kvblockd-0.2.0.tar.gz
Size 241.5 kB
Tags Source
SHA-256 checksum
How to use checksums
76380865a0c3c2e1845046a5cba7f4248159228329999e9a8b1fac54e0d616c7
BLAKE2b-256 checksum
How to use checksums
4cfe2fa954086e35759dfab0d93c7bb843cdad4d0080c81bcea4a1fb0de15a17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / sglang_kvblockd-0.2.0-py3-none-any.whl

Download URL sglang_kvblockd-0.2.0-py3-none-any.whl
Size 41.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7b7fff689eb2199879c8ba337a5eb3430113b696b3644032658c42737b3a205
BLAKE2b-256 checksum
How to use checksums
ac7cf8f491772e705b855715262f22602c0b4a4f44eb66d5261061dc89634c5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for sglang-kvblockd 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page