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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

mx8-1.0.7-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.7-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.7-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mx8-1.0.7-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d9700f2c8b81d5799b92c02da439c8a14825da545053a8a750718382fca0f7a2
MD5 b6f319c5bf60de2c990448bf322e8e98
BLAKE2b-256 34e670dd9d991dddf0a972e0efbb40b29763d32885b7dd116c9705a1ce7ac5d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.7-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 07a765607d9f11cb021dbc49226ba0f0f0ca59afdea891af1678306cc7780701
MD5 4e56a6a4f823b01cf1d9f7569cca67c2
BLAKE2b-256 69e6cf8ae0696ee91ba20c9cfdc8c75a6b0bf8d035e2e8dc750affcfc3b45f0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.7-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 86d858ea9b28d81c62b50c067d0fc82ee43d5ff70a9031bfbaa78e6a47a6add2
MD5 f9af1e09577493ae4fec735bc7b99548
BLAKE2b-256 cb47d069b4a34ddf3473e3d77304306dfdfc26a2f2e07fe217d01ddf8e0dd2a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.7-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 45e6f91733117de0c9144f2b787f6649f7a461fdba47dab9e3342f3fe34ac91c
MD5 92d7f6c54c08c1c17922f9ea3d629f91
BLAKE2b-256 882570a2821b43cb51ac7a8cbcd54e6602d7547822276e8cd1691ea1bb824c8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.7-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 80d280c32dc26ed038747022a69922d10157e5da517b5216ea2e477174b645a6
MD5 e21e7ca43697d97515766ce5e4a20e2d
BLAKE2b-256 0a6d6848067c73eb836a186d8e0bc0cb12662f4b36331fbec819da2fc7cf668a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mx8-1.0.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88a8be19307e131a4ff1dee343710b3c8be62f07bdd7842abd2fa01f24656ef6
MD5 b562cf07da888510703c59e7622019a5
BLAKE2b-256 c09753e0d0e23fb0ad262d277bed1f23fa3bb1e940171f16283bb72c9ef9a9d4

See more details on using hashes here.

File details

Details for the file mx8-1.0.7-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.7-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fde23c0b85e99ea9452c9388d51705346bbe8d2bc7b90d3ff6ac44366fbe6954
MD5 ac696ea819807bce96d3ccce0bb31da0
BLAKE2b-256 45d9230fc44675c9fcd992921bb92cef9179031446c4f3d68886564f22a04e54

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