Skip to main content

HyperCache connector for LMCache (Rust)

Lets an LMCache MP-mode server keep KV-cache chunks on HyperCache's NVMe and RAM tiers. LMCache loads it through its native_plugin adapter type. Below LMCache's own wrapper, all the work runs in Rust worker threads without the Python interpreter lock.

Install

From PyPI, in the environment that runs the LMCache server (Linux x86_64, CPython 3.10 to 3.13), from the first HyperCache release that publishes it:

pip install hypercache-lmcache-native

Use the same version as the HyperCache daemon; the two are released together.

Build

To build it yourself, you need a Rust toolchain and maturin. Build against the Python that runs LMCache:

cd lmcache-connector
maturin build --release -i python3.12
pip install target/wheels/hypercache_lmcache_native-*.whl

Quick start with vLLM

This is the setup the vLLM results (benchmarks/results/lmcache_rust_connector_vllm.md) ran with: vLLM 0.33.0, LMCache 0.5.7.post1 in multiprocess (MP) mode, and HyperCache on one NVMe drive. In MP mode, vLLM sends KV cache to a separate LMCache server process. That server keeps it in memory (L1) and hands it to this connector (L2), which stores it on the drive through the HyperCache daemon.

1. Start the daemon on a dedicated drive. The daemon writes to the raw device, so use a drive with nothing on it: no filesystem, not mounted. Save as kv.toml:

device_discovery_mode = "manual"
block_devices = ["/dev/nvme1n1"]
include_partitions = false
exclude_root_device = true
storage_backing_mode = "raw_block"
chunk_size_bytes = 4194304
device_start_offset_bytes = 4096
metadata_persistence_enabled = true    # keep the KV cache across daemon restarts
agent_enabled = false
metrics_enabled = false
ram_cache_enabled = false
# KV blocks are local-only and never flushed. The backend defaults to S3, so point it at an
# address that answers nothing: nothing can then be uploaded by mistake.
authoritative_backend = "s3"
s3_endpoint = "http://127.0.0.1:9"
s3_region = "us-east-1"
s3_bucket = "unused"
allow_synthetic_s3_fallback = false
sudo hypercache -c kv.toml start      # socket: /run/hypercache/hypercache.sock

2. Install LMCache and the connector where the LMCache server runs. Use LMCache 0.5.7.post1. The vllm/vllm-openai:v0.33.0 image ships 0.5.6, whose GPU kernels don't load there (see below), so install 0.5.7.post1 over it. Install the connector as in Install, then check the kernels:

pip install "lmcache==0.5.7.post1"
pip install hypercache-lmcache-native
python3 -c "import hypercache_lmcache_native as h; print(h.check_lmcache_gpu_ops())"   # must print None

3. Start the LMCache server with the connector as its L2. Pick a namespace that names the model and its revision (see Use):

lmcache server --host 127.0.0.1 --port 18555 --l1-size-gb 6 --eviction-policy LRU --chunk-size 256 \
  --l2-adapter '{"type": "native_plugin", "module_path": "hypercache_lmcache_native",
                 "class_name": "HyperCacheNativeConnector", "max_capacity_gb": 0,
                 "adapter_params": {"namespace": "qwen2.5-7b-awq-b250375", "tier": "nvme"}}'

4. Start vLLM pointed at that server:

vllm serve Qwen/Qwen2.5-7B-Instruct-AWQ --kv-transfer-config \
  '{"kv_connector": "LMCacheMPConnector", "kv_role": "kv_both",
    "kv_connector_extra_config": {"lmcache.mp.host": "127.0.0.1", "lmcache.mp.port": 18555}}'

5. Check it works. Send the same long prompt twice: the second first-token time should drop sharply. Then restart the LMCache server and vLLM, leave the daemon running, and send it again. LMCache's Prefetch request completed log line should count the keys as L2, which means they came from the drive. scripts/e2e/lmcache_vllm_e2e.py automates this and compares the answers. The connector prints any store or checksum failure to the LMCache server's stderr.

In containers: the LMCache server's container needs the daemon's socket directory mounted (-v /run/hypercache:/run/hypercache) and the drive itself (--device /dev/nvme1n1), because the connector reads and writes the drive directly. Without --device, every store fails and LMCache quietly runs on L1 alone, so check its log for failed L2 stores. With tier: "ram", it needs the host's /dev/shm instead.

Troubleshooting:

Symptom Cause
Every store fails with "no local-only commit support" The daemon is older than the connector. Upgrade the daemon.
Every store fails with a permission or "No such file" error on the drive The process can't open the drive: add --device, or add its user to the daemon's client_gid.
Warning "cuda_ops compiled extension not found" LMCache doesn't match the installed torch. Its fallback can store wrong KV data: fix the install, then change namespace.
Hits but no speedup after a restart L1 is too small for the load to fit (LMCache only evicts L1 down to 80%), or the prompt is shorter than one 256-token chunk.

Use

{
  "type": "native_plugin",
  "module_path": "hypercache_lmcache_native",
  "class_name": "HyperCacheNativeConnector",
  "adapter_params": {
    "namespace": "qwen2.5-7b-awq-rev1234",
    "socket_path": "/run/hypercache/hypercache.sock",
    "tier": "nvme",
    "num_workers": 32
  },
  "max_capacity_gb": 0
}
Setting Meaning
namespace Required. Must change when the model weights, dtype or engine settings change. LMCache's key has a model name but no revision, so without this a weight change could return wrong KV data.
socket_path Daemon socket. Defaults to the same search order as the Python client.
tier nvme (default) or ram. For ram, LMCache must share /dev/shm with the daemon.
num_workers Objects read or written at once, per direction (default 32). Each object is read one chunk at a time, so this sets the queue depth. On one drive, 8 loaded fastest. On 4 drives, 32 did.
timeout_s Daemon request timeout in seconds (default 30). Commits get at least 300.
max_capacity_gb Keep at 0. The daemon owns capacity and evicts under pressure.

Check LMCache's GPU kernels first

LMCache copies KV data between the GPU and its memory tier with compiled kernels in lmcache.cuda_ops. If they don't load, LMCache falls back to plain torch ops and logs a single warning:

lmcache.cuda_ops compiled extension not found; CudaDeviceOps stays on the torch baseline for all ops.

With that fallback, answers at temperature 0 changed after a cache hit on 24 or 25 of 25 test prompts, with or without HyperCache. LMCache #6673 traces it to the fallback's copy not waiting for the GPU kernel that fills it, so a store can save stale KV data. HyperCache then keeps exactly those bytes, so anything stored while the fallback was active may be wrong, and stays wrong after the fix: change namespace once the kernels load. It happens in the vllm/vllm-openai:v0.33.0 image, whose LMCache 0.5.6 was built for torch 2.13 while the image has 2.14. See benchmarks/results/lmcache_rust_connector_xeon.md.

Check before going live, in the environment that runs the LMCache server, with a GPU visible:

python3 -c "import hypercache_lmcache_native as h; print(h.check_lmcache_gpu_ops())"

It prints None when the kernels load, and the reason when they don't. The connector runs the same check at startup and prints a warning to stderr on a problem. It does not stop LMCache from starting. Fix it with an LMCache build that matches the installed torch. vLLM 0.31.0 with LMCache 0.5.5 is a tested pair whose answers matched. In the vLLM 0.33.0 image, LMCache 0.5.7.post1 from PyPI loads its kernels, and with batch invariance cached answers matched cold answers on 25 of 25. The connector's safety and failure tests pass on 0.5.7.post1, and answers from KV loaded off the drive matched no-cache answers on 9 of 9 prompts (benchmarks/results/lmcache_rust_connector_vllm.md).

What isn't supported

  • list_l2_keys and LMCache's IsolatedLRU quotas.
  • Versions other than LMCache 0.5.5, 0.5.6 and 0.5.7.post1, which are the ones tested. Nothing in the connector enforces that yet.
  • A daemon without local_only commits. Stores fail before writing any data, and lookups miss.

Behaviour

  • Any doubt about a block is a miss. Lookup only accepts committed local-only blocks with a checksum for every chunk, and load verifies every chunk before reporting success.
  • If the daemon restarts, the connector reconnects by itself. A request that couldn't be sent is resent once, and one the daemon may have received is never resent, so it reports a failure.
  • Blocks are never flushed to a backend. Against an older daemon, stores fail before any data is written and lookups miss. Support is checked again on every new connection, because a restarted daemon may be a different version, and a commit only counts when the daemon confirms LOCAL_ONLY.
  • A commit names the layout this connector staged, so if another writer replaced the block in between, the daemon refuses it and the store fails.
  • Two stores of the same block in one process run one after the other, and each reports its real outcome. A block already stored counts only if its size and layout match.
  • In a process forked from the one that opened the connector, closing it does nothing: the workers belong to the parent.
  • A block that fails its checksum is evicted, unless it was replaced during the read.
  • On raw block devices, writes use O_DIRECT. Page-aligned L1 buffers (--l1-align-bytes 4096) go to and from the drive with no copy. A partial last block goes through the page cache on writes and an aligned copy on reads.

LMCache's wrapper

LMCache's NativeConnectorL2Adapter wrapper sits between LMCache and this connector, which leads to some behaviour worth knowing.

  • Locks. The wrapper tracks lookup locks itself and doesn't check them before a delete, so a locked block can be deleted. The later load is a miss, never wrong data. LMCache only calls delete from global eviction, which max_capacity_gb: 0 turns off.
  • Status. report_status doesn't include this connector's counters. Checksum failures are logged to stderr, and adapter._client.stats() returns the counters.
  • Store accounting. The wrapper counts bytes per key it hasn't seen in this process, so after a restart a store of an existing block reports its bytes even though nothing was written.
  • Partial store failures. A store task with any failed key reports zero bytes, even if other keys in it were stored.

Test

cargo test                                   # no Python, LMCache or GPU needed
scripts/e2e/lmcache_l2_ci.sh --python python3   # 30 checks against real LMCache on a loop device
python3 scripts/e2e/lmcache_l2_e2e.py --socket /run/hypercache/hypercache.sock
python3 scripts/e2e/lmcache_vllm_e2e.py --fillers 40   # against a running vLLM + LMCache

lmcache_l2_ci.sh needs LMCache, torch (CPU is fine) and the connector wheel installed for that Python, and sudo for losetup; CI runs it on every pull request. lmcache_l2_e2e.py runs the same checks against a daemon you already started, on a real device, and damages one stored chunk on purpose. lmcache_vllm_e2e.py checks that answers loaded from L2 match cold ones. Results are in benchmarks/results/lmcache_rust_connector.md, lmcache_rust_connector_xeon.md and lmcache_rust_connector_nvme.md.

Metadata

Release files for hypercache-lmcache-native 0.10.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 hypercache-lmcache-native 0.10.0
File Size Uploaded Provenance Actions
hypercache_lmcache_native-0.10.0.tar.gz 36.1 kB With provenance Details for hypercache_lmcache_native-0.10.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for hypercache-lmcache-native 0.10.0
File Actions
hypercache_lmcache_native-0.10.0-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for hypercache_lmcache_native-0.10.0-cp313-cp313-manylinux_2_28_x86_64.whl
hypercache_lmcache_native-0.10.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for hypercache_lmcache_native-0.10.0-cp312-cp312-manylinux_2_28_x86_64.whl
hypercache_lmcache_native-0.10.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for hypercache_lmcache_native-0.10.0-cp311-cp311-manylinux_2_28_x86_64.whl
hypercache_lmcache_native-0.10.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for hypercache_lmcache_native-0.10.0-cp310-cp310-manylinux_2_28_x86_64.whl

Total release size: 1.9 MB

Release files / hypercache_lmcache_native-0.10.0.tar.gz

Download URL hypercache_lmcache_native-0.10.0.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0511a80630560a2dc6094ea00f213a6f62ab16885485f11439ad27f96522afee
BLAKE2b-256 checksum
How to use checksums
eff6309cb9df063beb8d8b0135a7c30d2bc71ed6fc3e92b0fe032ccdfdf6dc1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / hypercache_lmcache_native-0.10.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL hypercache_lmcache_native-0.10.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 465.1 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2026d5bade21471dcfa553d8e03510641bd0813313633d727b214f4b8ac94e8d
BLAKE2b-256 checksum
How to use checksums
d3e2b245caf05bc3dcd3be9cd8dd7709a30743ca02b3c8279637a7632b7b313e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / hypercache_lmcache_native-0.10.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL hypercache_lmcache_native-0.10.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 465.8 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8fc623303cc2597579a5a18e58a69ba66fc9074e1626e986b6a7928d284a71bb
BLAKE2b-256 checksum
How to use checksums
b7eac5609235cf1698a68f5c0c27b64520ce3431d74e48c064e3226522e17dfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / hypercache_lmcache_native-0.10.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL hypercache_lmcache_native-0.10.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 466.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
869f4b4140c15bfd39c74d39e59ee7edcc683d271651b97f7715fb7b0c42fa5d
BLAKE2b-256 checksum
How to use checksums
e697531a219c0b56883e0b5f53ef19a334a0f27a5057ff41f0d2adcb94032aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / hypercache_lmcache_native-0.10.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL hypercache_lmcache_native-0.10.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 466.4 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
29648edb2a9e5c90a2f633d056b75278d11ad35f16947c42a6c8fff8a1709062
BLAKE2b-256 checksum
How to use checksums
fd8a58dd3ada730f3d10dbd1880f8b9c90c8ebd5c6369cfd7310833c2b924b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for hypercache-lmcache-native 0.10.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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for hypercache_lmcache_native-0.10.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

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.

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