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=64,
    inflight=256 * 1024 * 1024,
    resize=(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

mx8.run(...) is the convenience wrapper that chooses local vs distributed mode from environment (WORLD_SIZE). mx8.resolve(...) is a short alias for mx8.resolve_manifest_hash(...).

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", tune=True)
loader_b = mx8.load("s3://bucket/dataset_b/@refresh", profile="balanced", tune=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 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.

Minimal API naming note:

  • Top-level APIs use short kwargs (batch, ram_gb, coord, resume, ...).
  • Advanced objects keep explicit names:
    • mx8.Constraints(max_inflight_bytes=..., max_ram_bytes=...)
    • mx8.RuntimeConfig(prefetch_batches=..., max_queue_batches=..., want=...)
    • mx8.DistributedDataLoader(..., autotune=..., resume_from=...)

Bounded memory (v0)

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

import mx8

loader = mx8.image(
    "/path/to/mx8-dataset@refresh",
    batch=64,
    inflight=256 * 1024 * 1024,
    queue=8,
    prefetch=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.6-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (18.6 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

mx8-1.0.6-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (18.6 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

mx8-1.0.6-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl (18.6 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

mx8-1.0.6-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl (18.7 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

mx8-1.0.6-cp38-abi3-manylinux_2_28_aarch64.whl (18.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

mx8-1.0.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.8 MB view details)

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

mx8-1.0.6-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (33.9 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.6-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.6-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3b063ccfefe9f7a022fa927941b363463ad000588c015c1eddf1481d43a5695d
MD5 5f3e567c61f7baf8e2ecef06ae49d0a9
BLAKE2b-256 3a28341fb7321050d7c145d943146722cd1a6515111cf39415d69fa817439fe9

See more details on using hashes here.

File details

Details for the file mx8-1.0.6-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.6-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 44e3caf3966468a2883c8fde1cd87ac5f420e34fdb945911a6acab88533d0009
MD5 3880ae6993de931e23a5d385f28c4309
BLAKE2b-256 6002b282942a355a7e808aa572f098fc34f93c3231c2ac8d2ca4b56fa1934a73

See more details on using hashes here.

File details

Details for the file mx8-1.0.6-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.6-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3745329fa98ee02cdb90bd788b67499c7ea40982c93c75506f553453e032f6be
MD5 251cbe777d2dc5ba143bb664ec6c5981
BLAKE2b-256 24dfd44d631dc9396df4c050bfc9452c7a3bf2129bc3f4bfa2ea4fb21c6bc7e6

See more details on using hashes here.

File details

Details for the file mx8-1.0.6-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.6-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 101e7b79c908904eb368268bd8b8754181d376c040bbc7ee4cb0ecfd976bff06
MD5 da26c3f13c7beefe13d87057011de483
BLAKE2b-256 3ae7707dc643885df3ed4c5ede26469002e59316142f677eb3c73628460599d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.6-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3de37db9bd98090bc08d9fecb6ed4c3818df09cbef1ac71f0dc5ef380c6bf9e7
MD5 4f7f65302695e06e4532ef86631db0ce
BLAKE2b-256 129c527dff2b3c2f88fe410b3b4fe234c41de0001716dcd3690a80211a341e99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4d386fd31550d0ca614b1570c153cb9747cd6425a02c9f834492341821364136
MD5 8c36cd1e6a3e842e89b478f1e1d2a4e5
BLAKE2b-256 a1f19a82b4a3dd770d062e71e99c9691b4c305da3236ec12ffbd2d7aef1c8dae

See more details on using hashes here.

File details

Details for the file mx8-1.0.6-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.6-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 691b60c81b5eb8d19ff1b3a01ef475053ba57e54a69e0b71b795f4440b844aed
MD5 6936928276edcb8450cbd2e765270bf4
BLAKE2b-256 e1e53a26d87f2b476e832df131ffc31fe33bed904756602211e2dc4136d61dab

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