DatasetRT — Dataset Caching for Machine Learning
Documentation · PyPI · Issues
DatasetRT is a Python library with a Rust runtime for caching training datasets on disk. Reuse preprocessed samples, filter and rebalance data through Polars, and sample deterministically without rewriting cached payloads.
Install dataset-rt, import dataset_rt, and use DatasetRT with your
existing training framework.
It keeps payloads immutable on disk, keeps sampling state in Rust, and lets your Python training code steer the dataset through one Polars metadata table.
metadata = dataset.get_metadata()
dev_run = metadata.head(100)
dataset.update_metadata(dev_run)
for sample in dataset:
train(sample.data, sample.metadata)
Rows in the active metadata table are the rows DatasetRT samples from. Remove
rows for a fast development run, duplicate rows or update weight for class
balancing and OHEM, add extra columns for training annotations, and let Rust
validate that every row still maps to an immutable cache sample.
Why It Exists
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 for the boring, high-stakes part of ML infrastructure:
- cache expensive preprocessing once and restart quickly
- keep payload bytes immutable while metadata stays editable at runtime
- filter or rebalance samples without rewriting cache files
- sample deterministically from the same cache contents, seed, epoch, and active metadata table
- validate metadata and weights against stable
(cache_id, sample_id)identities - keep reader and writer queues bounded in Rust
The design rule is simple:
If it affects correctness, Rust owns it.
Python remains the ergonomic edge: it describes sources, edits metadata with Polars, and decodes payload bytes into tensors, images, arrays, or domain objects.
The Core Idea
DatasetRT exposes the active dataset as a Polars table:
cache_id | sample_id | <stored metadata columns...> | weight | <extra columns...>
That table is the runtime control plane.
import polars as pl
metadata = dataset.get_metadata()
balanced = (
metadata.join(
metadata.group_by("label").agg(pl.len().alias("class_count")),
on="label",
)
.with_columns((1.0 / pl.col("class_count")).alias("weight"))
.drop("class_count")
)
dataset.update_metadata(balanced)
update_metadata() is runtime-only. It does not rewrite metadata.arrow,
index.bin, shards, or manifests. Future iterators use the updated active table;
already-created iterators keep their snapshot.
With drt.ReaderConfig(shuffle=True), DatasetRT performs deterministic weighted
multinomial sampling with replacement over the active table. With
shuffle=False, it emits active rows in cyclic table order, including
duplicates.
Use dataset.set_epoch_len(n) to make future iterators emit a finite window of
n samples. Ordered reads continue through the active table cyclically across
iterator boundaries, while shuffled reads continue a deterministic multinomial
draw stream. Updating metadata resets the stream and sets the epoch
length to the new table row count. Call set_epoch_len afterward to override it.
Installation
DatasetRT supports Python 3.10 through 3.13.
uv add dataset-rt
Or with pip:
pip install dataset-rt
Quickstart
Define a data source as an iterable that packs each Python record with pickle
or dill and yields CacheInput. Put large dictionaries, arrays, and nested
structures in the packed payload; keep fields used for filtering and weighting
in primitive metadata columns.
This complete example caches a dictionary per sample and unpacks it on read. Save it as
quickstart.py, then run uv run quickstart.py after installing DatasetRT.
Replace the source with your own preprocessing and serialization.
import pickle
from collections.abc import Iterator
from pathlib import Path
from pydantic import TypeAdapter
from typing_extensions import TypedDict
import dataset_rt as drt
class TrainingRecord(TypedDict):
"""Describe the dictionary stored inside each serialized payload."""
text: str
tokens: list[int]
RECORD_ADAPTER = TypeAdapter(TrainingRecord)
class TextSamples:
"""Pack preprocessed records, preserving labels as queryable metadata."""
name = "train_records_v1"
def __iter__(self) -> Iterator[drt.CacheInput]:
"""Stream payload bytes without building an in-memory dataset."""
for text, label in [(" Hello world ", 0), ("Dataset caching", 1)]:
normalized = text.strip().lower()
record = TrainingRecord(
text=normalized, tokens=[ord(char) for char in normalized]
)
yield drt.CacheInput(
data=pickle.dumps(record, protocol=pickle.HIGHEST_PROTOCOL),
metadata={"label": label},
)
runtime = drt.DatasetRuntime(num_workers=4)
result = runtime.from_cache_sources(
TextSamples(),
Path("cache"),
reader_config=drt.ReaderConfig(seed=42, shuffle=True),
)
match result:
case drt.CacheSourcesDatasetSuccess(dataset, results):
pass
case error:
raise RuntimeError(error)
for sample in dataset:
record = RECORD_ADAPTER.validate_python(pickle.loads(sample.data))
print(record["text"], record["tokens"], sample.metadata["label"])
Run it again to reuse cache/train_records_v1 without repeating preprocessing.
Use a new source name or cache root when preprocessing or source contents change;
reuse does not automatically detect those changes. Shuffled reads sample with
replacement, so this example can emit the same record twice.
pickle is included with Python. You can use dill.dumps() and dill.loads()
instead after installing dill when your record types require it. The source
packs the record, DatasetRT stores its bytes, and your read transform unpacks it.
See the serialization guide.
When To Use It
Use DatasetRT when you care about:
- restart speed after expensive preprocessing
- deterministic training-data order
- class balancing, OHEM, or metadata-driven sampling
- safe development subsets without separate cache copies
- cache integrity and bounded native prefetching
It is not trying to be a training framework, image decoder, tensor format, or model-specific data pipeline. It is the cache and sampling layer underneath those pieces.
Documentation
- Documentation home
- Cache training data in Python
- Class balancing with Polars
- PyTorch DataLoader tutorial
- Reader benchmarks
- Compare dataset tools
- Python API
- Runtime guide
- Determinism
- Storage Format
- Architecture
- Serialization Boundary
Status
DatasetRT is production infrastructure for immutable dataset caching. The core cache lifecycle, immutable storage format, runtime metadata table, deterministic weighted sampling, and Rust-owned reader/writer prefetching are in place.
Citation
@software{stupakov_datasetrt_2026,
author = {Stupakov, Vadym},
title = {DatasetRT: A Correctness-First Dataset Cache Runtime},
year = {2026},
url = {https://github.com/Red-Eyed/DatasetRT}
}
Metadata
Release files for dataset-rt 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dataset_rt-0.4.5.tar.gz | 367.0 kB | Without provenance | Details for dataset_rt-0.4.5.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| dataset_rt-0.4.5-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for dataset_rt-0.4.5-cp310-abi3-macosx_11_0_arm64.whl |
| dataset_rt-0.4.5-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for dataset_rt-0.4.5-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 6.7 MB
Release files / dataset_rt-0.4.5.tar.gz
| Download URL | dataset_rt-0.4.5.tar.gz |
|---|---|
| Size | 367.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb2b8fe81e9b69cc0d1a37a03c10c114adb0131cd082b479fab4dd7891a5ca6a
|
|
BLAKE2b-256 checksum How to use checksums |
4ad17a5430efccfe3dd81b1ee8ebb6eb3324d9e9de060c20696da5bd01c10ebe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Release files / dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
79e2e6367f16f90279de96e06aaf1389b9e79243567f13b7812ae159a1d47b32
|
|
BLAKE2b-256 checksum How to use checksums |
d24b8a40c06d82eb828d6952b839510c877e9d8834d4c77815abb45f268648af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Release files / dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | dataset_rt-0.4.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
de631267f1ef751752f35a2cbca8967a4fce18bc8bc2eba8e3d916f454b0c43c
|
|
BLAKE2b-256 checksum How to use checksums |
b3aa07043b40cbaf9b978abceb185d8b42f8c3cd205b3d2af3efffad6ed30a37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Release files / dataset_rt-0.4.5-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | dataset_rt-0.4.5-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
296058b5ca3beac46b73e25a978bf4f8e368bf5e758fa5f709199702efe6995c
|
|
BLAKE2b-256 checksum How to use checksums |
40d78c34f18d1dcc7e0859dd295e5e6e15a851af709c9c1989265c6f416ced64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Release files / dataset_rt-0.4.5-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | dataset_rt-0.4.5-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b6b0239bf927ff9e7fd7c359cfa969b95f21d607ebe12680f5ea6d255a771417
|
|
BLAKE2b-256 checksum How to use checksums |
dd6da23a71ecc5018557611ea5b53a87175f4920b1bd9ed26a15c5bfdf6cabde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Security for dataset-rt 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.