Pre-release
This release is a pre-release and may not be stable for production use.
redhare (Python connector)
In-process Python binding around RedhareClient. Ships two API layers
that share the same embedded Rust client:
KvStore— low-level SDK (this README).redhare.vllm_connector.RedhareConnector— vLLM v1 native KV connector. Full schema and mode-picking guide:docs/08-vllm-connector.md.
The low-level SDK below exposes batch gather/scatter methods for custom connector implementations:
from redhare import KvStore
store = KvStore(
redis_url="redis://127.0.0.1:6379",
client_id="rank0",
data_plane_addr="127.0.0.1:7000",
capacity="64MB", # int bytes also accepted
transport="nixl", # "nixl" (default) | "tcp" | "inmemory"
shared_fs_root=None, # optional cold-tier path
shared_fs_backend="posix", # "posix" (default) | "gds"
block_size_bytes=None, # optional fixed per-key block size
hot_cache_fraction=0.20,
hot_cache_min_shared_fs_reads=2,
default_ttl_ms=30 * 60 * 1000,
cache_node_rpc_addr=None, # optional: enable cache-node mode
enable_remote_dram=False, # originator: place into discovered cache-nodes
)
# Pre-register the KV cache region once; later reads DMA straight into it
# without re-registering per call.
store.register_buffer(kv_cache.data_ptr(), kv_cache.numel() * kv_cache.element_size())
# Save: each key's payload is gathered from N (addr, size) pairs (one memcpy).
rc = store.batch_put_from_multi_buffers(keys, addrs_per_key, sizes_per_key)
# Load: NIXL scatters the payload across the same N (addr, size) pairs.
# True zero-copy when destinations live inside a register_buffer region.
rc = store.batch_get_into_multi_buffers(keys, addrs_per_key, sizes_per_key)
# Experimental local-only load: enqueue the scatter copy on Redhare's CUDA
# copy stream and poll or wait for completion. This raises if any key is not
# local, so callers should fall back to batch_get_into_multi_buffers.
handle = store.batch_get_into_multi_buffers_submit_local(
keys, addrs_per_key, sizes_per_key
)
# Either poll handle.is_done() from your scheduler loop, or block explicitly.
handle.wait()
# Optional fixed-block size can also be set once after construction when the
# exact per-key KV block byte size is learned during runtime setup.
store.set_block_size_bytes(256 * 1024)
# Declare up front whether this embedder will stage at all; a model with
# nothing to snapshot then stops prewarming staging slots it never uses.
store.set_staging_enabled(True)
# Snapshot memory the engine is about to recycle. `batch_put_from_multi_buffers`
# reads the caller's buffers during the call, which does not work for sources
# freed before the put runs (vLLM releases Mamba/SSM state blocks a couple of
# steps after writing them). Staging copies them now, on this thread, into a
# pinned pool slot; the returned addr/size can be put from any thread later.
# Hold the StagedBuffer for as long as anything points at `addr`.
staged = store.stage_regions(addrs, sizes)
rc = store.batch_put_from_multi_buffers([key], [[staged.addr]], [[staged.size]])
# Range scatter: read byte subranges from stored objects into destination
# buffers. This is mainly for advanced connector paths.
rc = store.batch_get_ranges_into_multi_buffers(keys, offsets, lengths, addrs, sizes)
# Existence check (1 = exists, 0 = missing, -1 = error per key)
rc = store.batch_is_exist(keys)
store.close()
Return convention uses per-key int lists where 0 is success and a negative
value indicates failure.
Build
pip install maturin # once
cd crates/redhare-py
export CARGO_TARGET_DIR=/tmp/redhare-target # NFS-safe (see project memory)
maturin develop --release # installs into the active env
A wheel is built with maturin build --release; install via pip install target/wheels/redhare-*.whl.
Notes
transport="nixl"is the only one with true zero-copy load.tcpandinmemorywork but fall back to read-then-memcpy for scatters.batch_get_into_multi_buffers_submit_local()is a local-only optimization for custom connectors. It does not read from remote peers or cold storage; usebatch_get_into_multi_buffers()as the fallback path.data_plane_addris what peers connect to (NIXL control channel or TCP). Must be reachable from other clients in the cluster.- Remote DRAM uses
data_plane_addrfor payload movement andcache_node_rpc_addronly for control. Withtransport="nixl", remote writes use NIXL Write into the cache-node arena after an RPC reservation. - One connector
keymaps to one Redhare object: the per-key(addrs, sizes)lists are concatenated on save (one memcpy) and scattered on load (zero copy). - With
block_size_bytes=..., each key is forced to one fixed-size block: shorter saves are zero-padded, larger saves fail.
Metadata
Release files for redhare 0.5.0rc7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| redhare-0.5.0rc7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details |
Release files / redhare-0.5.0rc7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | redhare-0.5.0rc7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b2010c59838ac2569aeee28da3a10cb3866bc84813e5dbefd3d7da17cf995cdb
|
|
BLAKE2b-256 checksum How to use checksums |
033b1f75a6a08413a6741a9898c5aaf0f8252a7001c49df009104fecc7cc2bae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|