Skip to main content

MX8: bounded data runtime (Rust) exposed to Python.

Project description

mx8 (Python)

MX8 is a bounded-memory data runtime exposed to Python (built with PyO3 + maturin).

The v0 focus is “don’t OOM”: MX8 enforces backpressure with hard caps (so prefetch can’t runaway).

Further docs:

  • Python API: ../../docs/python_api.md
  • Vision labels/layout: ../../docs/vision_labels.md
  • S3/runtime tuning: ../../docs/s3_runtime_tuning.md
  • Memory contract: ../../docs/memory_contract.md
  • Video GA checklist: ../../docs/video_ga_checklist.md
  • Troubleshooting: ../../docs/troubleshooting.md

Install (from wheel)

Once you have a wheel (from CI or local build):

  • python -m venv .venv && . .venv/bin/activate
  • pip install mx8-*.whl

Install (from PyPI)

  • python -m venv .venv && . .venv/bin/activate
  • pip install mx8
  • Optional vision/training deps: pip install pillow numpy torch

Quickstart (local, no S3)

import mx8

mx8.pack_dir(
    "/path/to/imagefolder",
    out="/path/to/mx8-dataset",
    shard_mb=512,
    label_mode="imagefolder",
    require_labels=True,
)

loader = mx8.image(
    "/path/to/mx8-dataset@refresh",
    batch_size_samples=64,
    max_inflight_bytes=256 * 1024 * 1024,
    resize_hw=(224, 224),  # (H,W); optional
)

print(loader.classes)  # ["cat", "dog", ...] if labels.tsv exists

for images, labels in loader:
    pass

Zero-manifest load (raw prefix)

import mx8

loader = mx8.load(
    "s3://bucket/raw-prefix/",
    recursive=True,  # default
    profile="balanced",
)

for batch in loader:
    pass

Mix multiple loaders

mx8.mix(...) composes existing loaders into one deterministic stream. weights are sampling proportions (not model-loss weights).

import mx8

loader_a = mx8.load("s3://bucket/dataset_a/@refresh", profile="balanced", autotune=True)
loader_b = mx8.load("s3://bucket/dataset_b/@refresh", profile="balanced", autotune=True)

mixed = mx8.mix(
    [loader_a, loader_b],
    weights=[1, 1],   # fairness baseline (50:50)
    seed=0,
    epoch=0,
)

for batch in mixed:
    pass

print(mixed.stats())

Skewed example:

mixed = mx8.mix([loader_a, loader_b], weights=[7, 3], seed=0, epoch=0)

seed and epoch define deterministic schedule behavior:

  • same seed + epoch => same source-pick sequence
  • same seed, different epoch => controlled schedule variation

starvation_window is an optional watchdog threshold in scheduler ticks used for starvation counters in mixed.stats(). Set MX8_MIX_SNAPSHOT=1 (and optional MX8_MIX_SNAPSHOT_PERIOD_TICKS=64) to emit periodic mix_snapshot proof events.

Bounded memory (v0)

Set a hard cap and periodically print high-water marks:

import mx8

loader = mx8.image(
    "/path/to/mx8-dataset@refresh",
    batch_size_samples=64,
    max_inflight_bytes=256 * 1024 * 1024,
    max_queue_batches=8,
    prefetch_batches=4,
)

for step, (images, labels) in enumerate(loader):
    if step % 100 == 0:
        print(loader.stats())  # includes ram_high_water_bytes

Avoid patterns that intentionally accumulate batches:

# ❌ Don't do this (will grow RSS regardless of any loader)
all_batches = list(loader)

Labels (optional)

label_mode="imagefolder" is designed to scale:

  • Per-sample records reference a numeric label_id (u64), not a repeated string.
  • The human-readable mapping is stored once at out/_mx8/labels.tsv.

If your input layout is mixed (files directly under the prefix and subfolders), label_mode="auto" may disable ImageFolder labeling. To enforce ImageFolder semantics, use:

mx8.pack_dir(..., label_mode="imagefolder", require_labels=True)

Project details


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.

mx8-1.0.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB view details)

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

mx8-1.0.4-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (21.6 MB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file mx8-1.0.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mx8-1.0.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21c15c483b9c77fb73fd5f0c9519f941635a267b1e5775ee7c3675754be562c1
MD5 47f86fd4420ed25727129a9d2abaeac2
BLAKE2b-256 59120e134c39fb0407b200a0016e92d9f6c022537a336d33f23ba0d85f157507

See more details on using hashes here.

File details

Details for the file mx8-1.0.4-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for mx8-1.0.4-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 a4a64357d41ea45f114328ca53703f5e335f2601a160e6077b9ffa7e5d124e09
MD5 0374d9a7c8fd843355b165424339ea3f
BLAKE2b-256 a703231a2c7f2a4661ada58aa07b605afb37bd44839a4094bf6e66346cce6cf0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page