Skip to main content

HyperCache Python Client & Data Plane (client-py)

The hypercache Python package integrates transparently into AI training and inference pipelines (PyTorch, Hugging Face, Safetensors) to provide zero-copy Direct Block DMA / GPUDirect Storage (GDS) checkpoint loading.


Key Features

  • Transparent hypercache:// Protocol: Seamless fsspec filesystem implementation.
  • Dual Direct / Buffered Handles: Uses O_DIRECT with sector/page-aligned DMA buffers for maximum hardware read throughput (up to ~7 GB/s per PCIe Gen 4 NVMe and ~14 GB/s per PCIe Gen 5 NVMe), with automatic transparent fallback for arbitrary unaligned byte slices.
  • Sub-Millisecond Metadata: Resolves physical drive offsets from the local HyperCache control plane daemon in < 1 ms over Unix Domain Sockets.
  • Zero-Copy GPU Direct: Direct DMA transfers bypassing host CPU and Linux page cache.

Installation

# Install from PyPI (imports as `import hypercache`)
pip install hypercache-io

# Or install in editable mode from the repository
cd client-py
pip install -e .

# Optional GPU Direct Storage acceleration dependencies
pip install "hypercache-io[gpu]" --extra-index-url https://pypi.nvidia.com

Usage Examples

1. Reading with fsspec (PyTorch, Safetensors)

Importing hypercache.fsspec_fs registers the hypercache:// protocol with fsspec (installing the package also registers it, through an entry point).

import fsspec
import safetensors.torch
import hypercache.fsspec_fs  # noqa: F401  registers hypercache://

# The first read fetches the object from the backend into the cache; later reads come from NVMe or RAM
with fsspec.open("hypercache://models/llama-3/weights.safetensors", "rb") as f:
    tensors = safetensors.torch.load(f.read())

2. Writing checkpoints

Opening a hypercache:// path for writing stages the data on NVMe in 4 MiB chunks, so host memory use stays small for large checkpoints. Closing the file commits it, and the daemon then copies it to the backend in the background (write-back).

import fsspec
import torch
import hypercache.fsspec_fs  # noqa: F401

with fsspec.open("hypercache://checkpoints/run-7/step-1000.pt", "wb") as f:
    torch.save(model.state_dict(), f)

# Options go through fs.open: stage in RAM, and wait until the backend has the copy before close() returns
fs = fsspec.filesystem("hypercache")
with fs.open("hypercache://checkpoints/run-7/step-1000.pt", "wb", tier="ram", write_through=True) as f:
    torch.save(model.state_dict(), f)

A write that doesn't finish is never committed, so the backend keeps the previous copy:

  • If the with block exits with an exception (for example torch.save fails part way), the staged data is discarded. This works with fsspec.open() and fs.open(), and for close() in a finally block. A file opened inside an except block (an emergency save after a failed step) still commits, unless a new exception is raised while it is open.
  • A file that is garbage-collected without close() is discarded the same way, with a warning in the log.
  • f.abort() discards a write explicitly.
  • If the commit fails, close() raises IOError: the object was not saved.

The daemon also removes a staged write that is never committed, after staged_write_timeout_secs (default 30 minutes) or when it restarts. Until it is committed, locate reports the object as a miss with sync_status "STAGED", so a reader never sees a half-written checkpoint.

3. Direct Python Client API

from hypercache.client import HyperCacheClient
from hypercache.datapath import get_data_reader

# Connect to local Control Plane Daemon (auto-resolves /run/hypercache/hypercache.sock)
client = HyperCacheClient()

# Check daemon health & discovered drives
devices = client.get_devices()
print(f"Discovered {len(devices)} active striped devices.")

# Locate an object, fetching it into the cache if it isn't there yet
layout = client.locate("hypercache://models/llama-3/weights.safetensors", auto_ingest=True)
if layout.is_hit:
    reader = get_data_reader()
    data = reader.read_range(layout.chunk_layout, 0, layout.object_size)
    print(f"Read {len(data) / (1024 * 1024):.2f} MiB")

LMCache

The LMCache integration isn't part of this package. It's a separate Rust connector, covered in lmcache-connector/README.md. For code that manages its own KV blocks, use HyperCacheKVStore from this package.


Running Unit Tests

pytest tests/

Metadata

Release files for hypercache-io 0.12.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-io 0.12.0
File Size Uploaded Provenance Actions
hypercache_io-0.12.0.tar.gz 46.5 kB Without provenance Details for hypercache_io-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypercache-io 0.12.0
File Interpreter ABI Platform Actions
hypercache_io-0.12.0-py3-none-any.whl Python 3 none any Details for hypercache_io-0.12.0-py3-none-any.whl

Total release size: 79.7 kB

Release files / hypercache_io-0.12.0.tar.gz

Download URL hypercache_io-0.12.0.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2aa1e9a8abe0b45e970adb5d827657296ad2fdbe896b1851f993d1909ac5b3d3
BLAKE2b-256 checksum
How to use checksums
0a371d3c701b552903292e11c9596eadd86fa7d28dd5b0e90693617e92396744
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / hypercache_io-0.12.0-py3-none-any.whl

Download URL hypercache_io-0.12.0-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68cdecae9e017aebb795e3a8637f640589c1cc7e2c76fa2f0ae04a6e1898405b
BLAKE2b-256 checksum
How to use checksums
6844354671bc3ac0ff0c5cd8e9c9dfaa1ab5583b49c5dd9dd34dfc8cb406d2b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for hypercache-io 0.12.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.

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