Skip to main content

DatasetRT

DatasetRT is a correctness-first dataset cache for ML training loops.

It gives you a deterministic, immutable cache on disk, backed by a Rust runtime and exposed through a small Python API. You keep your model code in PyTorch, JAX, TensorFlow, NumPy, or plain Python; DatasetRT handles cache integrity, metadata, sampling weights, and repeatable iteration without becoming another framework.

Authorship

Created by Vadym Stupakov vadim.stupakov@gmail.com.

Why ML Users Need This

Dataset bugs are expensive. A silent shuffle change, corrupt shard, mismatched metadata row, or weight vector applied to the wrong sample can waste training runs and make experiments impossible to reproduce.

DatasetRT is built around one rule:

If it affects correctness, Rust owns it.

Rust owns:

  • immutable cache publication
  • manifest and checksum validation
  • metadata schema validation
  • shard offsets and index generation
  • deterministic weighted sampling
  • iterator state
  • bounded reader/writer prefetch over one reused Rust worker pool
  • samples metadata validation

Python stays thin and ergonomic. It describes your source data and receives bytes plus metadata back.

Quickstart

from pathlib import Path

import polars as pl

from dataset_rt import (
    CacheInput,
    CacheSourcesDatasetError,
    CacheSourcesDatasetSuccess,
    DatasetRuntime,
    ReaderConfig,
    ShardCompression,
    WriterConfig,
)


class Images:
    name = "train_images"

    def __iter__(self):
        for sample_id, image_bytes, label in load_my_images():
            yield CacheInput(
                data=image_bytes,
                metadata={"sample_id": sample_id, "label": label},
            )


runtime = DatasetRuntime(num_workers=4)
result = runtime.from_cache_sources(
    Images(),
    Path("cache"),
    reader_config=ReaderConfig(
        seed=42,
        prefetch_size=64,
        shuffle=True,
        validate_cache=False,
    ),
    writer_config=WriterConfig(
        prefetch_size=64,
        shard_compression=ShardCompression(algo="none", ratio=1.0),
        show_progress=True,
        validate_cache=False,
    ),
)

match result:
    case CacheSourcesDatasetSuccess(dataset, results):
        pass
    case CacheSourcesDatasetError(results, message):
        raise RuntimeError(message)

for sample in dataset:
    image = decode_image(sample.data)  # domain decoding stays in Python
    label = sample.metadata["label"]

DatasetRuntime creates exactly the requested number of Rust worker threads once and reuses them for cache loading, reading, and writing. runtime.from_cache_sources creates missing caches, reuses existing cache directories, and returns a result containing the loaded dataset plus per-source write outcomes. The cache directory argument is always a base cache directory; Rust writes each source under base_cache_dir / name. Cache writing shows committed samples/s and MB/s for the active source and source-count ETA for multi-source writes by default; pass WriterConfig(show_progress=False) for quiet jobs. Existing cache checksum validation is opt-in with validate_cache=True; by default DatasetRT avoids hashing every payload shard during restart.

PyTorch

When PyTorch is installed, turn the same DatasetRT object into a sized IterableDataset:

torch_dataset = dataset.to_torch_iterable_dataset()
loader = torch.utils.data.DataLoader(torch_dataset, batch_size=None, num_workers=0)

for sample in loader:
    image = decode_image(sample.data)
    label = sample.metadata["label"]

The adapter does not decode payloads or add a Torch dependency to DatasetRT. It yields CachedSample values and reports len(torch_dataset). Keep PyTorch DataLoader(num_workers=0); use DatasetRuntime(num_workers=N) for parallel cache reads.

Samples Metadata

Weights are not a loose list that can drift out of alignment. DatasetRT exposes dataset-level samples metadata as a Polars table with stable identity columns, stored metadata, and editable weights:

metadata = dataset.samples_metadata()

rare = metadata.with_columns(
    pl.when(pl.col("label") == "rare_class")
    .then(5.0)
    .otherwise(1.0)
    .alias("weight")
)

dataset.set_samples_metadata(rare)

The table contains:

cache_id | sample_id | <metadata columns...> | weight

Rust validates that every physical (cache_id, sample_id) appears exactly once and that every weight is positive and finite.

Multiple Sources

large_runtime = DatasetRuntime(num_workers=8)
result = large_runtime.from_cache_sources(
    [TrainImages(), SyntheticImages(), HardNegatives()],
    Path("cache"),
    reader_config=ReaderConfig(seed=123),
    writer_config=WriterConfig(prefetch_size=128, show_progress=False),
)

If one source fails during a multi-source write, DatasetRT reports that source as CacheWriteError and keeps going. CacheSourcesDatasetSuccess.results tells you which sources were loaded and which were missing or malformed. A loaded dataset means every successful cache was validated from its manifest.

Storage Layout

cache/
    train_images/
        manifest.json
        metadata.arrow
        index.bin
        shards/
            000000.bin
            000001.bin

Metadata is stored separately from payload bytes. This keeps sampling, filtering, auditing, and weight editing independent of domain payload decoding. Each shard record also embeds the same metadata redundantly so raw record inspection and visualization can show sample context without joining back through Arrow.

What DatasetRT Does Not Do

DatasetRT does not decode JPEGs, PNGs, tensors, or framework-specific objects in the Rust core.

The core returns payload bytes. Your Python code or optional adapters can decode those bytes into tensors, arrays, images, token sequences, or any other domain object.

DatasetRT v0.1 also intentionally supports only:

  • bytes-like payloads: bytes, bytearray, memoryview
  • primitive metadata: bool, int, float, str
  • shard compression: ShardCompression(algo="none", ratio=1.0) or ShardCompression(algo="lz4", ratio=...)

LZ4 compression is applied per payload record so random access stays direct. The common Rust zstd crate uses C bindings, so zstd compression is not enabled for the first stable version.

Documentation

Artifact Builds

Distribution artifacts are built locally with just build-all. Linux wheels use Zig cross-compilation; macOS arm64 and x86_64 wheels build on the local host. GitHub Actions stays checks-only.

Wheels use Python's stable ABI (cp310-abi3) and support Python 3.10 through 3.13.

Status

DatasetRT is at foundational v0.1 architecture. The core cache lifecycle, immutable storage, metadata, deterministic weighted sampling, Rust-owned reader/writer prefetching, and Polars samples metadata table are in place.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataset_rt-0.2.4.tar.gz (99.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

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

dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

dataset_rt-0.2.4-cp310-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

dataset_rt-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file dataset_rt-0.2.4.tar.gz.

File metadata

  • Download URL: dataset_rt-0.2.4.tar.gz
  • Upload date:
  • Size: 99.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataset_rt-0.2.4.tar.gz
Algorithm Hash digest
SHA256 79e6fc26373d116dda1c193a430becd449114b2f465f3acd91aa581b7e83e145
MD5 416450693fcfa7a549a10ddb138196c8
BLAKE2b-256 d9390d7e1d7cbb2c3884a3d3ec5522cf0f8d43ba09b069936fe32ad73ee1080c

See more details on using hashes here.

File details

Details for the file dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 567b058db2fae255228516e1cf169fa45e162e6f7374d54ab47ca3e8838fa1f5
MD5 eb719e2528b95717e860a6b95861e897
BLAKE2b-256 d50cfb34a0639401dbd6acd271d51ecc43b6a3d8dc3f5e2d3d9813a9862cca70

See more details on using hashes here.

File details

Details for the file dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataset_rt-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e24770165d56262d5841efe81d1bc1d5dd0a7b76c9df33e7cb76fb041286335a
MD5 6985a25d322602fe32a5253ffcebc4ce
BLAKE2b-256 0aaeb2ce41a5ae5c9368c2ff2601a75eeb7e23a1813fb0400d7a107164234740

See more details on using hashes here.

File details

Details for the file dataset_rt-0.2.4-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: dataset_rt-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataset_rt-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ef45a694c4aa9e4bb3dc2a1e1c514e77ebf86fb5c1c078e6e9882b07bf4cdff
MD5 cc5d7c0eed478336831c2f7df49157d7
BLAKE2b-256 6e2b2a31fc8487df13a006889ea84e5d66b124c8658119676f6a63f592d981b4

See more details on using hashes here.

File details

Details for the file dataset_rt-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: dataset_rt-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dataset_rt-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6eab159be27ad901907259ade444a51d8e2019de652b6b1261119cd11becb6ae
MD5 80a237c3425208c5dad7f66d56ce787c
BLAKE2b-256 08cd79a437a2f3de6a1ff4f10e6fc51a6951ec1032e416fc09fd5a405341e975

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

5 files

0.2.6

5 files

0.2.5

5 files

This release

0.2.4 This release

5 files

0.2.3

5 files

0.2.2

5 files

0.2.0

5 files

0.1.12

5 files

0.1.11

3 files

0.1.9

5 files

0.1.8

5 files

0.1.7

5 files

0.1.6

5 files

0.1.5

5 files

0.1.4

2 files

0.1.3

5 files

0.1.2

2 files

0.1.1

2 files

0.1.0

4 files

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