DataShoal is a small Python library for loading datasets and reading, writing and streaming SafeTensors checkpoints. Use it to sample calibration rows for GPT-QModel or read individual weights from a local file or your Hugging Face or ModelScope cache. PyTorch is optional. By default, load() makes zero network requests.
Documentation wiki · Python API · Native ABI · Quickstart
Features
- Stream and sample. Read JSON, JSONL, CSV, text, Parquet and supported Arrow streams. Filter, transform, batch or sample rows while keeping nested chat messages and token IDs intact.
- Stay offline by default. Reuse completed files from your existing cache. Pass
download=Trueto allow a fetch. DataShoal verifies new artifact downloads before publishing them to the cache. - Keep the install small. LogBar is the only required package. DataShoal handles calibration and artifact transfers without installing NumPy, pandas, PyArrow, HF Datasets or the Hub SDK.
- Read and write Parquet directly. Select just the columns you need. Frequently used codecs compile locally on first use; a Python fallback runs when a compiler is unavailable.
- Read and write SafeTensors. Inspect shards, stream weights, or copy selected rows into a new checkpoint. With PyTorch installed, index several shards and load just the weights or rows your model needs. SafeTensors guide
- Use threads with the GIL disabled. Independent readers can run concurrently on free-threaded CPython. Threads sharing one iterator divide its rows between them.
- Work with model hubs. Download files or snapshots from Hugging Face and ModelScope, upload to Hugging Face using native Xet support, or opt into HF-compatible imports for supported downstream consumers.
Usage
Install from GitHub with Python 3.11 or newer:
python -m pip install git+https://github.com/ModelCloud/DataShoal.git
1. Preview a local dataset
Given a local JSONL file with one record per line, read its first three rows:
from datashoal import load
rows = load("train.jsonl", type="dataset")
print(rows.take(3))
2. Write and read a SafeTensors checkpoint
Save two weights from a Python buffer, then read them back. PyTorch is optional.
from struct import pack, unpack
from datashoal import SafeTensors as st
scale = st.wire.TensorData("F32", (2,), pack("<2f", 1.25, 2.5))
st.save("example.safetensors", {"scale": scale})
with st.load("example.safetensors") as archive:
assert archive.wire.tensors["scale"].shape == (2,)
assert unpack("<2f", archive.read("scale")) == (1.25, 2.5)
For large weights, iterate over archive.chunks("scale"). With PyTorch installed, archive.torch("scale") returns a writable tensor. SafeTensors guide
3. Sample across several shards
Read your training files in a stable order. Filter out blank text, then select up to 128 examples with a repeatable seed. Sampling scans every shard and keeps only the selected rows in memory.
from pathlib import Path
from datashoal import load
shards = sorted(Path("calibration").glob("train-*.jsonl.gz"))
train = load(shards, type="dataset").filter(lambda row: row["text"].strip())
calibration_rows = train.sample(128, seed=42)
4. Fetch once and calibrate offline
Pin a public calibration dataset to a specific revision. Run the first call on a connected machine to populate its cache. Later runs using that cache can omit download permission entirely.
from datashoal import load
repo = "neuralmagic/calibration"
shard = dict(type="dataset", file="llm.parquet",
revision="fb6bc2f8c66543876fb31613f5872b9030220e15")
load(repo, **shard, download=True)
calibration_rows = load(repo, **shard).sample(128, seed=42)
With a loaded GPT-QModel model, pass those rows directly to quantization:
from gptqmodel.quantization import CalibrationConfig
model.quantize(CalibrationConfig(dataset=calibration_rows, batch_size=1))
For checkpoints, load("org/model", type="model") returns a cached snapshot directory. Add file="config.json" to get one file, or provider="modelscope" to select ModelScope. See the wiki for loading options, Hub uploads and HF compatibility.
Parquet benchmarks
Each cell shows elapsed time / peak process memory for the same Python chat records. Lower is better for both. Streaming consumed 1,024 rows at a time.
| Rows | Mode | DataShoal | PyArrow | HF Datasets |
|---|---|---|---|---|
| 10,000 | Collect | 7.55 ms / 92 MiB | 9.24 ms / 257 MiB | 9.29 ms / 187 MiB |
| 10,000 | Stream | 7.66 ms / 75 MiB | 11.72 ms / 119 MiB | 9.83 ms / 203 MiB |
| 100,000 | Collect | 90.97 ms / 433 MiB | 92.91 ms / 1,065 MiB | 88.98 ms / 723 MiB |
| 100,000 | Stream | 70.81 ms / 95 MiB | 117.81 ms / 240 MiB | 72.44 ms / 343 MiB |
DataShoal used the least memory in all four cases. HF Datasets reopened a prepared local cache for collection. The 100,000-row fixture repeats the smaller chat corpus ten times. Each library ran in separate processes on an Apple M5 Ultra. Benchmark methods and reproduction
Parquet projection, numeric reads and writes
Median elapsed time across 51 warm runs on an Apple M5 Ultra. Lower is faster. Each reader returns the full output named in the row, including HF Datasets when reading from a stream.
| Operation | DataShoal | PyArrow | HF Datasets (streaming) | HF Datasets (cached) |
|---|---|---|---|---|
| Read 10,000 chat records as Python rows | 6.88 ms | 7.92 ms | 13.59 ms | 7.21 ms |
| Read only the text column of 10,000 chat records | 2.94 ms | 3.26 ms | 9.15 ms | 3.45 ms |
| Read 250,000 integer IDs as Python rows | 9.00 ms | 10.68 ms | 12.44 ms | 12.07 ms |
| Read 250,000 integer IDs into a NumPy array | 3.89 ms | 0.86 ms | 1.99 ms | 2.03 ms |
| Write 10,000 chat records to uncompressed Parquet | 6.99 ms | 7.50 ms | Not measured | Not measured |
Benchmark details and reproduction
SafeTensors benchmarks
Median elapsed time for one 64 MiB integer tensor on an Apple M5 Ultra. Lower is faster.
| Operation | DataShoal | SafeTensors 0.8.0 (Rust, NumPy interface) |
|---|---|---|
| Read the full tensor into owned bytes | 2.89 ms | 5.16 ms |
| Stream the tensor in owned 1 MiB chunks | 2.34 ms | 7.67 ms |
| Write the tensor to a local file | 5.29 ms | 4.83 ms |
DataShoal publishes writes atomically. Benchmark details and reproduction
Native accelerator benchmarks
Speedup of the current JIT accelerator over the previous release on identical inputs. Each cell is the median ratio of 15 alternating rounds with both builds loaded in one process.
| Entry point | Used by | Small | Medium | Large |
|---|---|---|---|---|
| LZ4 frame decode | Xet downloads | 2.00x | 3.49x | 4.12x |
| Keyed BLAKE3 (64 B / 4 KiB / 64 KiB) | Xet hashing | 1.26x | 1.94x | 3.23x |
| Content-defined chunking | Xet uploads | 1.48x | 1.98x | 2.10x |
| Positional tensor read (1 / 64 / 256 MiB) | SafeTensors | 1.00x | 1.51x | 2.56x |
| Level encoding | Parquet writes | 1.59x | 1.79x | 1.71x |
| Repetition levels | Parquet reads | 1.54x | 1.66x | 1.41x |
| Snappy page decode | Parquet reads | 1.32x | 1.18x | 1.17x |
| Page and footer metadata | Parquet reads | 1.18x | 1.18x | 1.19x |
String, dictionary and record assembly spend their time creating Python objects and stay within 5% of the previous release. Text packing no longer attaches a cached UTF-8 copy to every non-ASCII input string. That copy previously kept 15.3 MiB alive after writing a 15.7 MiB file. Measured on x86-64 with CPython 3.14.4. Reproduce with benchmarks/native.py
Attributions and citations 📚
DataShoal implements the Xet protocol for uploads to and downloads from the Hugging Face Hub. Please credit Hugging Face’s Xet team when citing the protocol.
| Work | Authors / project | Reference |
|---|---|---|
| DataShoal | ModelCloud.ai, @qubitiium, and DataShoal contributors | Project |
| Xet | Hugging Face’s Xet team and contributors | Protocol specification · Reference implementation |
| SafeTensors | SafeTensors contributors | File format · Reference implementation |
Cite DataShoal, Xet and SafeTensors (BibTeX)
@misc{modelcloud_datashoal,
author = {{ModelCloud.ai} and {@qubitiium} and {DataShoal contributors}},
title = {{DataShoal}},
url = {https://github.com/ModelCloud/DataShoal}
}
@misc{huggingface_xet_protocol,
author = {{Hugging Face}},
title = {{Xet Protocol Specification}},
url = {https://huggingface.co/docs/xet/en/index}
}
@misc{safetensors_format,
author = {{SafeTensors contributors}},
title = {{SafeTensors}},
url = {https://github.com/safetensors/safetensors}
}
Metadata
Release files for datashoal 0.1.0
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 |
|---|---|---|---|---|
| datashoal-0.1.0.tar.gz | 81.1 kB | Without provenance | Details for datashoal-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datashoal-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for datashoal-0.1.0-py3-none-any.whl |
Total release size: 171.1 kB
Release files / datashoal-0.1.0.tar.gz
| Download URL | datashoal-0.1.0.tar.gz |
|---|---|
| Size | 81.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
485bf44dfe6363b525fbf503a8a73642896449d40c22ba22dc8d7e75e3fbbf3a
|
|
BLAKE2b-256 checksum How to use checksums |
cc2fad4e0375347b91f108c3b9269ca6582f42af8fdd9888a0d9f46187c7a1b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / datashoal-0.1.0-py3-none-any.whl
| Download URL | datashoal-0.1.0-py3-none-any.whl |
|---|---|
| Size | 90.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28c0af5c250cc947087e0302ab7bc631768ac5d73c0cdd6248cba33feac9cde8
|
|
BLAKE2b-256 checksum How to use checksums |
4fc5452a72f6d02bcd4906a5bbb2b028055fbf39c4f723e21d88faa3eca16dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for datashoal 0.1.0
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.