Connect an engine to KVStash

Each inference engine reaches KVStash through a small adapter package. Pick the one for your engine, give it a namespace on the daemon, and check that blocks really flow.

Last updated

Choose a connector

  • Storage backend (L3) for HiCache, SGLang's hierarchical cache.

    GPU-tested. Tested: SGLang 0.5.15.post1, 0.5.23 on L40S, H100.

  • Native KV connector, set with one vLLM flag.

    GPU-tested. Tested: vLLM 0.25.1, 0.27.1, 0.33.0 on L40S, A10G, A100, L4.

  • Remote storage plugin, loaded by name from the LMCache config.

    Works in CI, not GPU-qualified. Tested: LMCache 0.5.6 (not recommended) on L40S.

  • Running vLLM? Use the native connector, vllm-kvblockd. It needs no LMCache and produced every vLLM result on this site.
  • Running SGLang? Use sglang-kvblockd as the storage tier under SGLang's hierarchical cache (HiCache).
  • Already on LMCache? lmcache-kvblockd adds KVStash as a remote backend. It is tested in CI against the real LMCache package but not yet on GPUs.

PyPI packages, checked end to end on 8 November 2026 with the official engine images: kvblockd 0.2.0 with vllm-kvblockd 0.1.2 on vLLM 0.33.0, and sglang-kvblockd 0.2.1 on SGLang 0.5.23. Both store, reload into a restarted engine and give the answer the engine gives from its own cache. lmcache-kvblockd 0.2.1 is not recommended yet: in LMCache's own image (LMCache 0.5.6, vLLM 0.31.0) a prompt reloaded from LMCache's own cache answered wrongly, with or without KVStash. On vLLM, use the native vllm-kvblockd connector.

Prepare the daemon

  1. Make it reachable. If the engine runs on another machine, bind the data port to a private address. Port 9440 carries tokens in clear text, so it belongs on a private network or VPC only.
    config.yaml
    # config.yaml on the store machine: listen on the private interface
    listen_addr: "10.0.0.5:9440"     # the daemon warns on a non-loopback bind; keep it private
    metrics_addr: "10.0.0.5:9442"    # so Prometheus can scrape it
  2. Give the engines a namespace. Engines that should share cache use one namespace. Store a SHA-256 of each token instead of the token itself.
    Shell
    echo -n 'the-token-you-give-the-engine' | shasum -a 256
    namespaces.yaml
    # namespaces.yaml: one namespace per group of engines that share cache.
    # ids are permanent; never reuse one for a different tenant.
    namespaces:
      - { name: vllm,   id: 2, token_sha256: "SHA256_OF_THE_TOKEN" }
      - { name: sglang, id: 3, token_sha256: "SHA256_OF_THE_TOKEN" }

    Restart the daemon to load the file, or add namespaces without a restart through the admin plane: see kvbctl namespace add.

  3. Check from the engine host. curl STORE_HOST:9442/healthz answers ok when the daemon is ready and the metrics port is reachable.

Across machines and clouds (AWS, GCP, Azure)

The store and the engines talk plain TCP on port 9440. In a cloud that means: one private network, the store's private IP, and a firewall rule that admits only the engines. Tokens and block bytes are not encrypted on this port, so never open it to the internet; if you must cross an untrusted network, carry it over a VPN or WireGuard tunnel.

  1. Bind the daemon to the private interface. Set listen_addr to the store's private IP (or 0.0.0.0:9440 with the firewall below) and metrics_addr to the same IP on 9442. The daemon prints a warning for any non-loopback bind; that is expected.
  2. Open the port to the engines only. On AWS, add an inbound rule to the store's security group for TCP 9440 from the engines' security group.
    Shell (AWS CLI)
    # AWS example: allow the engines' security group to reach the store, nothing else
    aws ec2 authorize-security-group-ingress --group-id sg-STORE \
      --ip-permissions 'IpProtocol=tcp,FromPort=9440,ToPort=9440,UserIdGroupPairs=[{GroupId=sg-ENGINES}]'
    # Prometheus (or your laptop through a tunnel) on the metrics port
    aws ec2 authorize-security-group-ingress --group-id sg-STORE \
      --ip-permissions 'IpProtocol=tcp,FromPort=9442,ToPort=9442,UserIdGroupPairs=[{GroupId=sg-MONITORING}]'
  3. Prove the path from the engine host before starting the engine. If these pass, the engine will connect.
    Shell, on the engine host
    # on the ENGINE host: both must succeed before you start the engine
    nc -vz STORE_PRIVATE_IP 9440                 # data port: "succeeded" / "open"
    curl -s STORE_PRIVATE_IP:9442/healthz         # ok  (needs metrics_addr on that IP, not 127.0.0.1)
    
    # then one real round trip with the namespace and token the engine will use
    python3 -m venv .venv && . .venv/bin/activate   # system Pythons refuse a global pip install
    pip install kvblockd
    python - <<'PY'
    from kvblockd.client import Client
    c = Client("STORE_PRIVATE_IP:9440", namespace="vllm", token=open("vllm.token").read().strip())
    print("put", c.put(b"k" * 32, b"hello"), "exists", c.batch_exists([b"k" * 32]))
    c.close()
    PY
  • Connection refused

    Nothing listens on that address. The daemon is down, or listen_addr is 127.0.0.1, or the engine uses the public IP while the daemon is bound to the private one. Check the startup line kvblockd listening addr=... on the store host.

  • Timed out, no answer at all

    A firewall drops the packets: security group, network ACL, host firewall (ufw, firewalld) or a different VPC. Open TCP 9440 from the engines' security group, and connect over the private IP inside one VPC (or through VPC peering or a transit gateway).

  • curl :9442/healthz fails but nc :9440 works

    metrics_addr defaults to 127.0.0.1:9442. Set it to the private IP (or 0.0.0.0 with the port closed to everyone but monitoring) to check health from another host.

  • server fatal: status 0x21 at connect

    Authentication failed: the namespace name or token does not match namespaces.yaml (with token_sha256, hash the exact token with no trailing newline). The daemon counts these in kvb_auth_failures_total.

  • Works on the store host, not from the engine

    You tested 127.0.0.1. Repeat the checks above from the engine host with the private IP.

  • Works in one region, not across regions

    Supported only over a private link (peering, transit gateway, VPN). Cross-region latency also shrinks the speedup; keep the store in the same zone as the GPUs.

The engine adapters take the address as kvblockd://HOST:9440; the Python client and kvbctl -addr take plain HOST:9440. A hostname works as well as an IP.

Engine setup pages

Each page has the exact flags, a table of every setting, the tested versions and the known limits.

Verify it is working

A connector that the engine ignores fails quietly: serving works, nothing reaches the store. Check these three things once after setup.

  1. The engine loaded the adapter. vLLM logs Creating v1 connector with name: KvblockdConnector. LMCache logs Created remote backend for plugin: kvblockd. No such line means the setting was not read.
  2. Blocks arrive. Send one long prompt. kvb_bytes_total{dir="in"} for the engine's namespace id rises.
  3. Blocks come back. Restart the engine, not the daemon, and send the same prompt. kvb_hits_total rises and time to first token drops. That drop is the product.
Shell
# on the store machine: watch writes (in), reads (out) and hits per namespace id
watch -n 2 "curl -s 10.0.0.5:9442/metrics | grep -E '^kvb_(bytes_total|hits_total|misses_total)'"

Share across servers

Any number of engines can read each other's blocks when all of these match:

  • The same namespace and token.
  • The same model weights and revision, KV precision and block or page size. Any difference gives different keys, so nothing is shared; that is deliberate.
  • PYTHONHASHSEED=0 on every worker.
  • Tensor parallel size 1 for the vLLM connector; SGLang above tensor parallel 1 is not tested yet.

Mixing engines in one namespace does not share cache between them, because vLLM and SGLang lay out KV blocks differently. Give each engine type its own namespace.

Dynamo and NIXL

Not supported yet. The daemon has an S3-compatible endpoint (s3compat_addr, off by default) that NIXL's object plugin can point at, and a native NIXL plugin in beta. Neither has been tested with an engine on GPUs. Tell us if you need this path and we will prioritise it.

Something missing or wrong on this page? Email rudray@kvstash.com and it gets fixed.