Skip to main content

memkv-vllm

MemKV secondary tier for vLLM's native KV offloading feature (OffloadingConnector + TieringOffloadingSpec). vLLM offloads completed KV blocks from GPU to a pinned CPU pool; this plugin adds a memkv tier behind that pool, so blocks evicted from CPU (or produced by another vLLM instance) are served from a shared MemKV cluster over RDMA instead of being recomputed.

This is MemKV's third vLLM-adjacent integration and does not replace the others: lmcache-plugin/ (LMCache connector path, current production recommendation) and plugin/ (NIXL storage backend for Dynamo KVBM).

Requirements

  • vLLM main at or after commit 6cf7b26bd (v0.23.1rc1.dev962). The tiering framework (vllm.v1.kv_offload.tiering) has shipped in releases since v0.22.0, but the secondary-tier API this plugin implements (LookupResult lookups, ScheduleEndContext, get_stats/build_metric_definitions) is newer than the latest stable release (v0.24.0); it first appears in the v0.25.0 release candidates. The offloading spec API is experimental upstream and has already been reworked once (a9531edfa, between v0.25.1 and v0.26.0 — renamed OffloadingSpec construction and several fields this plugin reads). Rather than pinning to one side of that boundary, _vllm_compat.py detects and handles both; confirmed working on v0.25.0, v0.25.1, v0.26.0, v0.27.0, and v0.27.1.
  • Linux with RDMA userspace (libibverbs, ibverbs-providers) for the data path. The client falls back to TCP where RDMA is unavailable.
  • PYTHONHASHSEED pinned (e.g. 0) on every vLLM instance that should share KV — vLLM's block content hashes are seeded per process otherwise.

Install

pip install memkv-vllm

The wheel registers itself via the vllm.general_plugins entry point memkv_tier — no vLLM patches, no extra flags. If you restrict plugins with VLLM_PLUGINS, include memkv_tier in the list.

Configure

MemKV connection settings come from the standard MEMKV_CONFIG yaml or MEMKV_* env-var chain (MEMKV_SERVERS, MEMKV_AUTH_KEY, …) — identical to the other MemKV plugins. The tier entry in secondary_tiers carries only tier tuning:

PYTHONHASHSEED=0 vllm serve <model> \
  --kv-transfer-config '{
    "kv_connector": "OffloadingConnector",
    "kv_role": "kv_both",
    "kv_connector_extra_config": {
      "spec_name": "TieringOffloadingSpec",
      "cpu_bytes_to_use": 10737418240,
      "block_size": 256,
      "secondary_tiers": [
        {"type": "memkv", "n_read_threads": 8, "n_write_threads": 8}
      ]
    }
  }'
Tier config key Default Meaning
type Must be "memkv".
prefix "" Key-namespace prefix inside MemKV (multi-fleet separation).
n_read_threads 8 Load-priority I/O threads (promotions; these gate time-to-first-token).
n_write_threads 8 Store-priority I/O threads (cascades).
blocks_per_op 8 Max blocks per batched client call.
load_failure_grace_s 60 Withhold a failed load's completion from vLLM for this long, keeping its target slots pinned so a server write abandoned by a client timeout cannot land in reused memory. 0 disables.
max_store_backlog_mb 2048 Shed store jobs once this much store work is queued/in flight, so a slow MemKV cannot pin the CPU pool solid. Shed blocks just skip MemKV; loads are never shed. Keep below cpu_bytes_to_use/2.
lookup_timeout_s 5 Deadline for async exists probes: a lookup still unresolved past it resolves as MISS (recompute) instead of holding the request deferred on RETRY. Any value <= 0 disables. Requires a vLLM with the async-lookup-deadline patch (upstream/0002); ignored (with a warning) otherwise.

Sizing notes: block_size (offloaded block, in tokens) controls the MemKV value size — prefer values ≥ 1 MiB (long blocks) so reads are bandwidth-bound, not per-key-overhead-bound. cpu_bytes_to_use is the CPU tier working set; MemKV only sees traffic once blocks cascade (immediately on store) and promote (on CPU-tier misses).

How it maps

One MemKV value per (block hash, KV cache group): the full offloaded block across all TP ranks (stride bytes of the CPU pool). Keys reuse vLLM's FileMapper naming — <prefix>/<model>_<configdigest>…/<hash>.bin — so runs with the same model/layout share blocks and incompatible layouts can't collide. Lookups are batched async exists probes (one round per scheduler step); stores/loads are chunked batch_put_views/batch_get_into calls straight against the pool slots (no Python-side copies). Capacity is governed server-side by MemKV lane eviction; a value evicted between lookup and load degrades to recompute, never corruption.

Test

cargo build -p memkv            # loopback server binary for the fixture
maturin develop --manifest-path vllm-plugin/Cargo.toml
pytest vllm-plugin/tests -v    # requires vllm importable; Linux for data path

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ x86-64

memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

File details

Details for the file memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9b902944ce15d4ce1805c147913f94fa5737b1245f6db2135339c208503df3f
MD5 302996de9c56a9ea231b350ab2bed532
BLAKE2b-256 8988d8cd8bfc1b9265ae004a46093099306983e845ad72ca0bbccfbc6b063504

See more details on using hashes here.

File details

Details for the file memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for memkv_vllm-1.0.6-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 33db550804057ce7813788eed01dc10af3db0eb7d69a99141ada2da19da291a8
MD5 d97f7c7dad9f8c47229a75b0052e63dd
BLAKE2b-256 2fe474959479d08126b1c7c39bcbdf45854d0b48b1ce5dba7aadf7699822d023

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.7

2 files

This release

1.0.6 This release

2 files

1.0.5

2 files

1.0.4

2 files

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