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 and worker pools
  • weight table 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,
    CachedDataset,
    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},
            )


dataset = CachedDataset.from_cache_sources(
    Images(),
    Path("cache"),
    reader_config=ReaderConfig(seed=42, prefetch_size=64, num_workers=4, shuffle=True),
    writer_config=WriterConfig(
        prefetch_size=64,
        num_threads=4,
        shard_compression=ShardCompression(algo="none", ratio=1.0),
    ),
)

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

CachedDataset.from_cache_sources creates missing caches, reuses valid existing caches, and returns a ready-to-iterate dataset. The cache directory argument is always a base cache directory; Rust writes each source under base_cache_dir / name_hash.

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)

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).

Metadata-Aware Weights

Weights are not a loose list that can drift out of alignment. DatasetRT exposes them as a Polars table with sample identity and metadata:

weights = dataset.weight_table()

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

dataset.set_weight_table(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

dataset = CachedDataset.from_cache_sources(
    [TrainImages(), SyntheticImages(), HardNegatives()],
    Path("cache"),
    reader_config=ReaderConfig(seed=123),
    writer_config=WriterConfig(prefetch_size=128, num_threads=8),
)

If one source fails during a multi-source write, DatasetRT cleans up caches created earlier in that call. A loaded dataset means every cache was validated from its manifest.

Storage Layout

cache/
    train_images_<hash>/
        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.

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
  • ShardCompression(algo="none", ratio=1.0)

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 weight 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.1.3.tar.gz (70.2 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.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (924.3 kB view details)

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

dataset_rt-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (880.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

dataset_rt-0.1.3-cp310-abi3-macosx_11_0_arm64.whl (900.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

dataset_rt-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl (936.2 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: dataset_rt-0.1.3.tar.gz
  • Upload date:
  • Size: 70.2 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.1.3.tar.gz
Algorithm Hash digest
SHA256 27ac09fe20f2f8953cd9e3cc9de95a5eac4a52668858fb368cb0745f49f193db
MD5 76bfac9bbc69a19c242fbf666fbf5114
BLAKE2b-256 3300a0e2afe5b6abcae736f6f14abdbf04fca4b7ae2a504f100939a810f5cbe1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dataset_rt-0.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 924.3 kB
  • 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.1.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28b0277aab9979fa0ce94f572952f56d526908a676355f08637848ee385360b7
MD5 5493c0b5d5bda832a498e09ca753b09c
BLAKE2b-256 7195524ba47fed375bba4bb16a7313e3cb4d24efa7f8284d8016b9b85ec06969

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dataset_rt-0.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 880.0 kB
  • 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.1.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f1cd9fee2909d9c6fa96102cdfdc969fb4163a4c039fa57d5079e1e8bc320cb6
MD5 54bc3d68c870c101d1fa29cb1181522a
BLAKE2b-256 f116504c46aa3463d47326f703865a8f6688140751fefc66749505df27b8c509

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dataset_rt-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 900.1 kB
  • 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.1.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8dab7bd2dad03c9a432610b9261079a6b6fc4d0ad59518d91d317ab6328181ea
MD5 c777398d9a26ea0f199314ab300e70c8
BLAKE2b-256 ce3723c607950ecf769e659329048d80eac0ed477824419c2c9f422e1f07a6bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dataset_rt-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 936.2 kB
  • 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.1.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eaa840d47f871c7bf3f8dad58299542b34df3e4220f4b92536f807aa86b21132
MD5 b7394301f0c3ea0afe580d48863e26f1
BLAKE2b-256 cd0c4c06a8c624ee9d607c4e06c14416f903de7abc743a2d41b9f10f926791e1

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

0.2.4

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

This release

0.1.3 This release

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