Skip to main content

hf-dataset-slow-disk

A Hugging Face-style Parquet dataset library for HDDs, network filesystems, and other slow storage.

Features

  • Sequential row-group reads with bounded memory
  • Lazy background download and audio decoding
  • Standard Hugging Face Hub Parquet cache
  • Resumable general metadata cache with visible progress logs
  • Deterministic shuffle, epochs, and exact batch resume
  • Sample-mixed concatenation with one shared worker pipeline

Install

pip install hf-dataset-slow-disk

Quick start

from hf_dataset_slow_disk import load_dataset

dataset = load_dataset(
    "capleaf/viVoice",
    split="train",
    batch_size=8,
    num_workers=2,
).shuffle(seed=42)

dataset.set_epoch(0)

try:
    for batch in dataset:
        train_step(batch)
finally:
    dataset.close()

Workers start lazily on the first get() or when dataset iteration begins. Defaults are one worker, an eight-batch decoded buffer, and a two-file Parquet buffer.

An optional process-pickleable collate_fn(batch) runs on decoded column-oriented batches inside each background worker. It must preserve column names, order, and row count, allowing CPU preprocessing to overlap model execution.

Core API

from hf_dataset_slow_disk import (
    Audio,
    ConcatDataset,
    Dataset,
    DatasetDict,
    concatenate_datasets,
    load_dataset,
)
  • load_dataset() loads Hub or local Parquet data.
  • shuffle(seed) and set_epoch(epoch) select deterministic order.
  • set_batch_idx(batch_idx) restores the next training batch.
  • for batch in dataset, get(), and iter_batches() consume batches.
  • iter_rows() performs synchronous sample-by-sample iteration.
  • repeat=N intentionally repeats each chunk N times before shuffle, useful for balancing an underrepresented source before concatenation.
  • concatenate_datasets() mixes compatible sources with their configured weights.
  • cast_column() configures lazy audio decoding.

Documentation

Examples

uv run python examples/basic.py
uv run python examples/benchmark.py
uv run python examples/concat.py

The benchmark and concat examples use batch size 8 and stop after 10 batches.

Disclaimer

This project was developed with the assistance of AI coding tools. Its source code is publicly available at giangndm/hf-dataset-slow-disk. Please review and validate it for your own workloads before production use.

Development

uv sync
uv run pytest -q
uv build

Download files

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

Source Distribution

hf_dataset_slow_disk-0.2.0.tar.gz (86.5 kB view details)

Uploaded Source

Built Distribution

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

hf_dataset_slow_disk-0.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file hf_dataset_slow_disk-0.2.0.tar.gz.

File metadata

File hashes

Hashes for hf_dataset_slow_disk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7bb9dd3e80826aa035f3e0431acf6b3de64d0ce04ae349b7e6ec46c63bf1c2d1
MD5 dc9761a49a134e7ad13ccd8201a5f245
BLAKE2b-256 1e6f4e5ce656f3d3fee3e6397d3a8a6346dfa4d50bc87e75451b721c73a2bc42

See more details on using hashes here.

File details

Details for the file hf_dataset_slow_disk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hf_dataset_slow_disk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ce4ddb8461abd40b4551730587732367d45cc12fd04433e0da8013fcc3b0f1
MD5 6735de967cfa61f70f5ddf6739366097
BLAKE2b-256 dc5b7122d1a08c69d9deba3042db66bdf29ded3185b2c6fd330bbcf0557afa5f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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