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.8rc1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (18.6 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

mx8-1.0.8rc1-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.8rc1-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.8rc1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.8rc1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5dc964bf4c028e63dd778895fd94c42e55e2549a06255e16da682076edec3993
MD5 f32615a7bf5930449736d04852469c99
BLAKE2b-256 5f728b6d84ad0a15b8abef4dc960fe1df07047966c0ab5f6858605af21c3d3cb

See more details on using hashes here.

File details

Details for the file mx8-1.0.8rc1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.8rc1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5523bf51c2c6f85609a5ff91040548b9a57a11d096c796846d2aa3c43d03c4b0
MD5 64ab06b6ab8ff784c85855287e2d07ac
BLAKE2b-256 86a766f71102b23726b687b74907bfc73cb7ee65cff20739ceb6066cb3cfad84

See more details on using hashes here.

File details

Details for the file mx8-1.0.8rc1-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.8rc1-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3fcdadf41a0517c65c0014bbba7aedc9f023856f84df1785c3d1a28f54c56d41
MD5 6c26ac6aaa4f96e5e9034bece8e6e3a2
BLAKE2b-256 ee64a6e587b70ab227394f8421bc39e52d1c717929f71535cc07db9f35445769

See more details on using hashes here.

File details

Details for the file mx8-1.0.8rc1-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.8rc1-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fd4ee77657fd329fa8461ac9a608c03cee4601ab169dd2cdb38348e52fcd698c
MD5 f14cf7d2f6e2e0c865e358028a7340e8
BLAKE2b-256 5b9601a566ed6fc9ae5701c9813d1ed1fed567c61bcffa39248db89755d94ef7

See more details on using hashes here.

File details

Details for the file mx8-1.0.8rc1-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.8rc1-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6fe3aa3838973c40c67cfa528e80751605db9342a7aa86698dc061c5d76be23b
MD5 f70cd4620a9c7c0f89b0de7a44928969
BLAKE2b-256 40ab92d46b3fcccd9fbe5578b7010661dd7f8b3162eee8d9aa07c83200c896b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.8rc1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58d86d884fb9f05d7adc74b265edb72ae48c0c73ae813938d30978974037c062
MD5 c43fbaee500087c5831a3b4a539bef56
BLAKE2b-256 ba6471a337a48de9139e822ee442d38f1dac29dea2c380b6b98d372ca452b283

See more details on using hashes here.

File details

Details for the file mx8-1.0.8rc1-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.8rc1-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 29cf06d0dac5d5086bc96d2df69f94918eca5c9ff9da3af184cfcdb3db030d79
MD5 60807fa4894908769c7abe2c772da00b
BLAKE2b-256 fd3d0787aebda81a831e664a383f9414c0bb21634a90dc9c2bd089d510b18fac

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