litdata 0.2.73__tar.gz → 0.2.75__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {litdata-0.2.73/src/litdata.egg-info → litdata-0.2.75}/PKG-INFO +83 -89
- {litdata-0.2.73 → litdata-0.2.75}/README.md +81 -88
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/__about__.py +1 -1
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/__init__.py +2 -1
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/data_processor.py +73 -9
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/functions.py +31 -4
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/async_prefetch.py +29 -1
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/cache.py +9 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/client.py +126 -15
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/config.py +18 -2
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/dataset.py +70 -6
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/dataset_update.py +6 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/downloader.py +162 -30
- litdata-0.2.75/src/litdata/streaming/framed_zstd.py +402 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/fs_provider.py +2 -2
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/item_loader.py +682 -47
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/reader.py +16 -3
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/serializers.py +576 -18
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/shuffle.py +53 -3
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/writer.py +282 -40
- litdata-0.2.75/src/litdata/types.py +655 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/broadcast.py +1 -1
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/dataset_utilities.py +19 -6
- litdata-0.2.75/src/litdata/utilities/hf_dataset.py +571 -0
- litdata-0.2.75/src/litdata/utilities/hf_fs.py +172 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/parquet.py +15 -12
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/shuffle.py +26 -0
- {litdata-0.2.73 → litdata-0.2.75/src/litdata.egg-info}/PKG-INFO +83 -89
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/SOURCES.txt +2 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/requires.txt +1 -0
- litdata-0.2.73/src/litdata/types.py +0 -230
- litdata-0.2.73/src/litdata/utilities/hf_dataset.py +0 -91
- {litdata-0.2.73 → litdata-0.2.75}/CONTRIBUTING.md +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/LICENSE +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/MANIFEST.in +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/requirements.txt +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/setup.cfg +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/setup.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/__main__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/commands.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/handler/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/handler/cache.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/handler/optimize.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/cli/parser.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/constants.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/debugger.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/exceptions.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/helpers.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/imports.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/complete.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/media_folder.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/readers.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/processing/utilities.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/raw/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/raw/dataset.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/raw/indexer.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/raw/types.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/requirements.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/collate.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/combined.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/compression.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/dataloader.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/elastic.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/parallel.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/posix_fast.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/resolver.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/sampler.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/streaming/timing.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/__init__.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/_pytree.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/base.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/breakpoint.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/encryption.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/env.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/format.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/keys_index.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/packing.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/subsample.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/torch_utils.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata/utilities/train_test_split.py +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/dependency_links.txt +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/entry_points.txt +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/not-zip-safe +0 -0
- {litdata-0.2.73 → litdata-0.2.75}/src/litdata.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: litdata
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.75
|
|
4
4
|
Summary: The Deep Learning framework to train, deploy, and ship AI products Lightning fast.
|
|
5
5
|
Home-page: https://github.com/Lightning-AI/litdata
|
|
6
6
|
Download-URL: https://github.com/Lightning-AI/litdata
|
|
@@ -41,6 +41,7 @@ Provides-Extra: extras
|
|
|
41
41
|
Requires-Dist: fsspec; extra == "extras"
|
|
42
42
|
Requires-Dist: google-cloud-storage; extra == "extras"
|
|
43
43
|
Requires-Dist: lightning-sdk==2026.2.6; extra == "extras"
|
|
44
|
+
Requires-Dist: orjson; extra == "extras"
|
|
44
45
|
Requires-Dist: pillow; extra == "extras"
|
|
45
46
|
Requires-Dist: polars; extra == "extras"
|
|
46
47
|
Requires-Dist: pyarrow<25.0.0; extra == "extras"
|
|
@@ -111,6 +112,7 @@ Dynamic: summary
|
|
|
111
112
|
<a href="#speed-up-model-training">Optimize data</a> •
|
|
112
113
|
<a href="#transform-datasets">Transform data</a> •
|
|
113
114
|
<a href="#modality">Modality</a> •
|
|
115
|
+
<a href="#huggingface-datasets">Hugging Face Datasets</a> •
|
|
114
116
|
<a href="#key-features">Features</a> •
|
|
115
117
|
<a href="#stream-raw">Stream raw files</a> •
|
|
116
118
|
<a href="#resolve-paths">Paths & cloud URLs</a> •
|
|
@@ -487,6 +489,75 @@ Examples (path on disk → optimize → batch): [examples/modality](examples/mod
|
|
|
487
489
|
|
|
488
490
|
----
|
|
489
491
|
|
|
492
|
+
# Hugging Face Datasets 🤗 <a id="huggingface-datasets"></a><a id="stream-hf"></a>
|
|
493
|
+
|
|
494
|
+
Train on the Hub datasets you already use. Drop in a Hugging Face dataset with one call — then optimize once onto Lightning Cloud storage when you want faster training I/O than Hub parquet or Hugging Face `datasets` streaming.
|
|
495
|
+
|
|
496
|
+
<details>
|
|
497
|
+
<summary>How to get the dataset URL</summary>
|
|
498
|
+
|
|
499
|
+
https://github.com/user-attachments/assets/3ba9e2ef-bf6b-41fc-a578-e4b4113a0e72
|
|
500
|
+
|
|
501
|
+
</details>
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
pip install 'litdata[extras]' huggingface_hub
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
Gated datasets: set `HF_TOKEN`.
|
|
508
|
+
|
|
509
|
+
**Load from the Hub**
|
|
510
|
+
|
|
511
|
+
```python
|
|
512
|
+
import litdata as ld
|
|
513
|
+
|
|
514
|
+
dataset = ld.StreamingDataset("hf://datasets/HuggingFaceH4/ultrachat_200k/data/train_sft-*.parquet")
|
|
515
|
+
print("Sample", dataset[0])
|
|
516
|
+
|
|
517
|
+
dataloader = ld.StreamingDataLoader(
|
|
518
|
+
dataset, batch_size=4, num_workers=4, multiprocessing_context="spawn"
|
|
519
|
+
)
|
|
520
|
+
for sample in dataloader:
|
|
521
|
+
pass
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**Optimize once for faster training**
|
|
525
|
+
|
|
526
|
+
```python
|
|
527
|
+
import litdata as ld
|
|
528
|
+
|
|
529
|
+
ld.optimize_hf("stanfordnlp/imdb", output_dir="imdb-opt", split="train")
|
|
530
|
+
dataset = ld.StreamingDataset("imdb-opt", shuffle=True, drop_last=True)
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
`optimize_hf` converts a Hub dataset into LitData chunks. Later calls reuse `output_dir` if it is already optimized. Pass `revision=`, `config=`, `chunk_size=`, or `fn=` when you need them.
|
|
534
|
+
|
|
535
|
+
### Faster than Hub parquet and `datasets` streaming
|
|
536
|
+
|
|
537
|
+
`StreamingDataset("hf://...")` loads Hub parquet as-is. Run `optimize_hf` once when you want higher training throughput. Both beat Hugging Face `datasets` streaming (`load_dataset(..., streaming=True)`) on every split below. Optimized chunks are **not** always fastest: **12/15** prefer `optimize_hf`; parquet stays ahead on [OpenThoughts](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k), [food101](https://huggingface.co/datasets/ethz/food101), and [cifar100](https://huggingface.co/datasets/uoft-cs/cifar100). Minipile, food101, and superb ks were re-measured with current defaults; the other twelve rows are unchanged.
|
|
538
|
+
|
|
539
|
+
Sequential one-epoch read after a 200-row warmup. Reproduce: `scripts/bench/bench_hf_hub_suite.py`.
|
|
540
|
+
|
|
541
|
+
| Dataset | `optimize_hf` rows/s | parquet (`hf://`) rows/s | HF streaming rows/s |
|
|
542
|
+
| --- | ---: | ---: | ---: |
|
|
543
|
+
| [HuggingFaceH4/ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) / train_sft | **47,285** | 31,209 | 6,752 |
|
|
544
|
+
| [open-thoughts/OpenThoughts-114k](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) / train | 6,508 | **12,292** | 1,492 |
|
|
545
|
+
| [abisee/cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail) / train / 3.0.0 | **57,944** | 44,286 | 13,874 |
|
|
546
|
+
| [teknium/OpenHermes-2.5](https://huggingface.co/datasets/teknium/OpenHermes-2.5) / train | **108,420** | 74,502 | 8,280 |
|
|
547
|
+
| [roneneldan/TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories) / train | **164,825** | 141,235 | 58,331 |
|
|
548
|
+
| [fancyzhx/amazon_polarity](https://huggingface.co/datasets/fancyzhx/amazon_polarity) / train | **214,217** | 162,448 | 14,613 |
|
|
549
|
+
| [Yelp/yelp_review_full](https://huggingface.co/datasets/Yelp/yelp_review_full) / train | **123,670** | 88,400 | 58,621 |
|
|
550
|
+
| [EdinburghNLP/xsum](https://huggingface.co/datasets/EdinburghNLP/xsum) / train | **55,941** | 37,684 | 15,377 |
|
|
551
|
+
| [Anthropic/hh-rlhf](https://huggingface.co/datasets/Anthropic/hh-rlhf) / train | **92,741** | 46,573 | 18,263 |
|
|
552
|
+
| [JeanKaddour/minipile](https://huggingface.co/datasets/JeanKaddour/minipile) / train | **81,871** | 50,160 | 3,928 |
|
|
553
|
+
| [ethz/food101](https://huggingface.co/datasets/ethz/food101) / train | 1,989 | **4,782** | 384 |
|
|
554
|
+
| [zh-plus/tiny-imagenet](https://huggingface.co/datasets/zh-plus/tiny-imagenet) / train | **57,855** | 43,535 | 6,491 |
|
|
555
|
+
| [uoft-cs/cifar10](https://huggingface.co/datasets/uoft-cs/cifar10) / train | **31,671** | 20,657 | 8,843 |
|
|
556
|
+
| [uoft-cs/cifar100](https://huggingface.co/datasets/uoft-cs/cifar100) / train | 22,448 | **24,332** | 7,553 |
|
|
557
|
+
| [s3prl/superb](https://huggingface.co/datasets/s3prl/superb) / train / ks | **7,101** | 6,775 | 314 |
|
|
558
|
+
|
|
559
|
+
Your own parquet on disk or S3 → [Stream parquet datasets](#stream-parquet).
|
|
560
|
+
|
|
490
561
|
# Key Features
|
|
491
562
|
|
|
492
563
|
## Features for optimizing and streaming datasets for model training
|
|
@@ -932,89 +1003,6 @@ for sample in dataloader:
|
|
|
932
1003
|
|
|
933
1004
|
</details>
|
|
934
1005
|
|
|
935
|
-
<details>
|
|
936
|
-
<summary> ✅ Stream Hugging Face 🤗 datasets <a id="stream-hf" href="#stream-hf">🔗</a> </summary>
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
To use your favorite Hugging Face dataset with LitData, simply pass its URL to `StreamingDataset`.
|
|
941
|
-
|
|
942
|
-
<details>
|
|
943
|
-
<summary>How to get HF dataset URI?</summary>
|
|
944
|
-
|
|
945
|
-
https://github.com/user-attachments/assets/3ba9e2ef-bf6b-41fc-a578-e4b4113a0e72
|
|
946
|
-
|
|
947
|
-
</details>
|
|
948
|
-
|
|
949
|
-
**Prerequisites:**
|
|
950
|
-
|
|
951
|
-
```sh
|
|
952
|
-
pip install 'litdata[extras]' huggingface_hub
|
|
953
|
-
|
|
954
|
-
# Optional: faster downloads on high-bandwidth networks
|
|
955
|
-
pip install hf_transfer
|
|
956
|
-
export HF_HUB_ENABLE_HF_TRANSFER=1
|
|
957
|
-
```
|
|
958
|
-
|
|
959
|
-
**Supported for HF:** datasets stored as **Parquet** only. Gated datasets: set `HF_TOKEN`.
|
|
960
|
-
|
|
961
|
-
**Stream Hugging Face dataset** (auto-index + auto `ParquetLoader`):
|
|
962
|
-
|
|
963
|
-
```python
|
|
964
|
-
import litdata as ld
|
|
965
|
-
|
|
966
|
-
hf_dataset_uri = "hf://datasets/leonardPKU/clevr_cogen_a_train/data"
|
|
967
|
-
|
|
968
|
-
dataset = ld.StreamingDataset(hf_dataset_uri) # indexes on first use; caches index.json locally
|
|
969
|
-
print("Sample", dataset[0]) # dict of columns
|
|
970
|
-
|
|
971
|
-
# With workers on Linux, use spawn (same as other ParquetLoader usage)
|
|
972
|
-
dataloader = ld.StreamingDataLoader(
|
|
973
|
-
dataset, batch_size=4, num_workers=4, multiprocessing_context="spawn"
|
|
974
|
-
)
|
|
975
|
-
for sample in dataloader:
|
|
976
|
-
pass
|
|
977
|
-
```
|
|
978
|
-
|
|
979
|
-
Unlike local/S3 parquet ([stream parquet](#stream-parquet)), `hf://` **automatically** indexes (if needed) and selects `ParquetLoader`.
|
|
980
|
-
|
|
981
|
-
### Indexing the HF dataset (optional, faster cold start)
|
|
982
|
-
|
|
983
|
-
```python
|
|
984
|
-
import litdata as ld
|
|
985
|
-
|
|
986
|
-
# Returns the local cache directory that contains index.json
|
|
987
|
-
cache_dir = ld.index_hf_dataset("hf://datasets/leonardPKU/clevr_cogen_a_train/data")
|
|
988
|
-
```
|
|
989
|
-
|
|
990
|
-
Or control the index path explicitly:
|
|
991
|
-
|
|
992
|
-
```python
|
|
993
|
-
import litdata as ld
|
|
994
|
-
from litdata.streaming.item_loader import ParquetLoader
|
|
995
|
-
|
|
996
|
-
uri = "hf://datasets/open-thoughts/OpenThoughts-114k/data"
|
|
997
|
-
ld.index_parquet_dataset(uri, "hf-index-dir") # writes index under hf-index-dir
|
|
998
|
-
|
|
999
|
-
dataset = ld.StreamingDataset(uri, item_loader=ParquetLoader(), index_path="hf-index-dir")
|
|
1000
|
-
for batch in ld.StreamingDataLoader(dataset, batch_size=4, multiprocessing_context="spawn"):
|
|
1001
|
-
pass
|
|
1002
|
-
```
|
|
1003
|
-
|
|
1004
|
-
See also [Stream parquet datasets](#stream-parquet) for `ParquetLoader` knobs, wildcards, and stream-vs-optimize.
|
|
1005
|
-
|
|
1006
|
-
### LitData `Optimize` v/s `Parquet`
|
|
1007
|
-
<!-- TODO: Update benchmark -->
|
|
1008
|
-
Below is the benchmark for the `Imagenet dataset (155 GB)`, demonstrating that **`optimizing the dataset using LitData is faster and results in smaller output size compared to raw Parquet files`**.
|
|
1009
|
-
|
|
1010
|
-
| **Operation** | **Size (GB)** | **Time (seconds)** | **Throughput (images/sec)** |
|
|
1011
|
-
|-----------------------------------|---------------|---------------------|-----------------------------|
|
|
1012
|
-
| LitData Optimize Dataset | 45 | 283.17 | 4000-4700 |
|
|
1013
|
-
| Parquet Optimize Dataset | 51 | 465.96 | 3600-3900 |
|
|
1014
|
-
| Index Parquet Dataset (overhead) | N/A | 6 | N/A |
|
|
1015
|
-
|
|
1016
|
-
</details>
|
|
1017
|
-
|
|
1018
1006
|
<details>
|
|
1019
1007
|
<summary> ✅ Streams on multi-GPU, multi-node <a id="multi-gpu" href="#multi-gpu">🔗</a> </summary>
|
|
1020
1008
|
|
|
@@ -1058,9 +1046,9 @@ Shuffling is **deterministic** and designed for distributed training:
|
|
|
1058
1046
|
|
|
1059
1047
|
The permutation depends on `seed`, the epoch, and chunk metadata — the same settings always yield the same order (required for resumable `state_dict`).
|
|
1060
1048
|
|
|
1061
|
-
**Object storage (`s3://`, `gs://`, …)** globally permutes chunks (`FullShuffle`). Random chunk order is cheap once files are already copied into the local cache.
|
|
1049
|
+
**Object storage (`s3://`, `gs://`, …)** globally permutes chunks (`FullShuffle`). Random chunk order is cheap once files are already copied into the local cache. Items *inside* a chunk are shuffled as aligned ``batch_decode`` windows. Pass ``item_shuffle_window=256`` (default / ``"auto"``) so blocks are shuffled, then the items inside each block — training still reuses the decode cache. ``item_shuffle_window=0`` (or ``"full"``) restores a full in-chunk permutation. ``LITDATA_ITEM_SHUFFLE_WINDOW`` applies only when the argument is omitted.
|
|
1062
1050
|
|
|
1063
|
-
**POSIX-fast** (automatic for any local path) mmaps chunks in place. **Vast / NFS / Lustre / GPFS** (and `LITDATA_POSIX_FAST=1`) use `WindowShuffle`: each worker gets **whole chunks** in a sequential stripe, then shuffles
|
|
1051
|
+
**POSIX-fast** (automatic for any local path) mmaps chunks in place. **Vast / NFS / Lustre / GPFS** (and `LITDATA_POSIX_FAST=1`) use `WindowShuffle`: each worker gets **whole chunks** in a sequential stripe, then shuffles chunk order inside a sliding window (default **16**, `LITDATA_POSIX_SHUFFLE_WINDOW`). In-chunk items still use ``item_shuffle_window``. Local disks (ext4/xfs) keep global `FullShuffle`. Object URLs stay on `FullShuffle`. `LITDATA_POSIX_FAST=0` disables in-place mmap.
|
|
1064
1052
|
|
|
1065
1053
|
```python
|
|
1066
1054
|
from litdata import StreamingDataset, StreamingDataLoader
|
|
@@ -1070,6 +1058,7 @@ train = StreamingDataset(
|
|
|
1070
1058
|
shuffle=True,
|
|
1071
1059
|
drop_last=True, # keep every rank/worker at the same length (default True under DDP)
|
|
1072
1060
|
seed=42, # default is 42; keep stable when resuming
|
|
1061
|
+
item_shuffle_window=256, # 0 / "full" = permute every item in the chunk
|
|
1073
1062
|
)
|
|
1074
1063
|
loader = StreamingDataLoader(train, batch_size=64, num_workers=8)
|
|
1075
1064
|
|
|
@@ -1872,7 +1861,7 @@ The `overwrite` mode will delete the existing data and start from fresh.
|
|
|
1872
1861
|
<summary> ✅ Stream parquet datasets <a id="stream-parquet" href="#stream-parquet">🔗</a> </summary>
|
|
1873
1862
|
|
|
1874
1863
|
|
|
1875
|
-
Stream existing Parquet files with LitData **without** converting them to LitData chunks — or convert them when you need LitData’s optimized binary format. Hugging Face
|
|
1864
|
+
Stream existing Parquet files with LitData **without** converting them to LitData chunks — or convert them when you need LitData’s optimized binary format. Hugging Face Hub datasets are covered in [Hugging Face Datasets](#huggingface-datasets).
|
|
1876
1865
|
|
|
1877
1866
|
### Stream vs optimize vs map
|
|
1878
1867
|
|
|
@@ -1917,7 +1906,7 @@ ld.index_parquet_dataset(
|
|
|
1917
1906
|
- Lists **top-level** `.parquet` files only (not recursive subfolders).
|
|
1918
1907
|
- All files must share the same schema.
|
|
1919
1908
|
- Supported for indexing today: local, `s3://`, `gs://`, `hf://` (not `r2://` / `azure://` yet).
|
|
1920
|
-
- For
|
|
1909
|
+
- For Hub datasets, use `StreamingDataset("hf://...")` — see [Hugging Face Datasets](#huggingface-datasets).
|
|
1921
1910
|
|
|
1922
1911
|
### Stream with `ParquetLoader`
|
|
1923
1912
|
|
|
@@ -2011,6 +2000,8 @@ Using [zstd](https://github.com/facebook/zstd), you can achieve high compression
|
|
|
2011
2000
|
| -------- | -------- |
|
|
2012
2001
|
| 2.8kb | 646b |
|
|
2013
2002
|
|
|
2003
|
+
`compression="zstd"` (default `compression_level="batch"`, `compression_batch_size=256`) keeps a `.bin` with an uncompressed directory plus zstd frames of 256 items — the same window as Arrow IPC record batches and aligned decode. `compression_level="chunk"` wraps each pytree chunk as one whole-file `.zstd.bin`. `compression_level="sample"` zstd-compresses each item between the pytree offsets. Numeric zstd levels are `compression="zstd:4"`, not `compression_level`. Nested JSON / Hub Arrow IPC still uses Arrow’s own per-batch zstd when you pass `"zstd"`.
|
|
2004
|
+
|
|
2014
2005
|
|
|
2015
2006
|
</details>
|
|
2016
2007
|
|
|
@@ -2254,6 +2245,7 @@ export LITDATA_ASYNC_DOWNLOAD_CONCURRENCY=4
|
|
|
2254
2245
|
| Variable | Default | Purpose |
|
|
2255
2246
|
|----------|---------|---------|
|
|
2256
2247
|
| `LITDATA_CACHE_DIR` | `~/.lightning/chunks` | Default chunk cache directory |
|
|
2248
|
+
| `LITDATA_ITEM_SHUFFLE_WINDOW` | `256` | In-chunk shuffle block size when `item_shuffle_window` is omitted (`0` = full permute) |
|
|
2257
2249
|
| `LITDATA_ASYNC_CHUNK_PREFETCH` | on for remote | `0`/`1` force async chunk download overlap |
|
|
2258
2250
|
| `LITDATA_ASYNC_MIN_PRE_DOWNLOAD` | `4` | Floor for `max_pre_download` when async is on (`0` = no floor) |
|
|
2259
2251
|
| `LITDATA_ASYNC_DOWNLOAD_CONCURRENCY` | `8` | Max in-flight chunk GETs per gather |
|
|
@@ -2688,7 +2680,9 @@ Full knob list for `litdata.optimize` (see Quick start for the minimal recipe).
|
|
|
2688
2680
|
| `chunk_bytes` | `None` | Max bytes per chunk (e.g. `"64MB"`; see [FAQ](#faq-chunk-shuffle) for larger samples) |
|
|
2689
2681
|
| `chunk_size` | `None` | Max items (or tokens with `TokensLoader`) per chunk |
|
|
2690
2682
|
| `align_chunking` | `False` | Match single-worker chunk boundaries (needs `chunk_size`; uneven load) |
|
|
2691
|
-
| `compression` | `None` | `"zstd"`
|
|
2683
|
+
| `compression` | `None` | `"zstd"` or `"zstd:N"` (numeric level). Pair with `compression_level` for pytree wrap |
|
|
2684
|
+
| `compression_level` | `"batch"` (zstd) | `"batch"` framed `.bin`; `"chunk"` whole-file `.zstd.bin`; `"sample"` per-item zstd |
|
|
2685
|
+
| `compression_batch_size` | `256` | Items per frame when `compression_level="batch"` (matches Arrow IPC / decode windows) |
|
|
2692
2686
|
| `encryption` | `None` | `FernetEncryption` / `RSAEncryption` / custom ([encrypt](#encrypt-decrypt)) |
|
|
2693
2687
|
| `num_workers` | CPU count | Local workers |
|
|
2694
2688
|
| `fast_dev_run` | `False` | Smoke a subset of inputs |
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
<a href="#speed-up-model-training">Optimize data</a> •
|
|
47
47
|
<a href="#transform-datasets">Transform data</a> •
|
|
48
48
|
<a href="#modality">Modality</a> •
|
|
49
|
+
<a href="#huggingface-datasets">Hugging Face Datasets</a> •
|
|
49
50
|
<a href="#key-features">Features</a> •
|
|
50
51
|
<a href="#stream-raw">Stream raw files</a> •
|
|
51
52
|
<a href="#resolve-paths">Paths & cloud URLs</a> •
|
|
@@ -422,6 +423,75 @@ Examples (path on disk → optimize → batch): [examples/modality](examples/mod
|
|
|
422
423
|
|
|
423
424
|
----
|
|
424
425
|
|
|
426
|
+
# Hugging Face Datasets 🤗 <a id="huggingface-datasets"></a><a id="stream-hf"></a>
|
|
427
|
+
|
|
428
|
+
Train on the Hub datasets you already use. Drop in a Hugging Face dataset with one call — then optimize once onto Lightning Cloud storage when you want faster training I/O than Hub parquet or Hugging Face `datasets` streaming.
|
|
429
|
+
|
|
430
|
+
<details>
|
|
431
|
+
<summary>How to get the dataset URL</summary>
|
|
432
|
+
|
|
433
|
+
https://github.com/user-attachments/assets/3ba9e2ef-bf6b-41fc-a578-e4b4113a0e72
|
|
434
|
+
|
|
435
|
+
</details>
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
pip install 'litdata[extras]' huggingface_hub
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
Gated datasets: set `HF_TOKEN`.
|
|
442
|
+
|
|
443
|
+
**Load from the Hub**
|
|
444
|
+
|
|
445
|
+
```python
|
|
446
|
+
import litdata as ld
|
|
447
|
+
|
|
448
|
+
dataset = ld.StreamingDataset("hf://datasets/HuggingFaceH4/ultrachat_200k/data/train_sft-*.parquet")
|
|
449
|
+
print("Sample", dataset[0])
|
|
450
|
+
|
|
451
|
+
dataloader = ld.StreamingDataLoader(
|
|
452
|
+
dataset, batch_size=4, num_workers=4, multiprocessing_context="spawn"
|
|
453
|
+
)
|
|
454
|
+
for sample in dataloader:
|
|
455
|
+
pass
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Optimize once for faster training**
|
|
459
|
+
|
|
460
|
+
```python
|
|
461
|
+
import litdata as ld
|
|
462
|
+
|
|
463
|
+
ld.optimize_hf("stanfordnlp/imdb", output_dir="imdb-opt", split="train")
|
|
464
|
+
dataset = ld.StreamingDataset("imdb-opt", shuffle=True, drop_last=True)
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
`optimize_hf` converts a Hub dataset into LitData chunks. Later calls reuse `output_dir` if it is already optimized. Pass `revision=`, `config=`, `chunk_size=`, or `fn=` when you need them.
|
|
468
|
+
|
|
469
|
+
### Faster than Hub parquet and `datasets` streaming
|
|
470
|
+
|
|
471
|
+
`StreamingDataset("hf://...")` loads Hub parquet as-is. Run `optimize_hf` once when you want higher training throughput. Both beat Hugging Face `datasets` streaming (`load_dataset(..., streaming=True)`) on every split below. Optimized chunks are **not** always fastest: **12/15** prefer `optimize_hf`; parquet stays ahead on [OpenThoughts](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k), [food101](https://huggingface.co/datasets/ethz/food101), and [cifar100](https://huggingface.co/datasets/uoft-cs/cifar100). Minipile, food101, and superb ks were re-measured with current defaults; the other twelve rows are unchanged.
|
|
472
|
+
|
|
473
|
+
Sequential one-epoch read after a 200-row warmup. Reproduce: `scripts/bench/bench_hf_hub_suite.py`.
|
|
474
|
+
|
|
475
|
+
| Dataset | `optimize_hf` rows/s | parquet (`hf://`) rows/s | HF streaming rows/s |
|
|
476
|
+
| --- | ---: | ---: | ---: |
|
|
477
|
+
| [HuggingFaceH4/ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) / train_sft | **47,285** | 31,209 | 6,752 |
|
|
478
|
+
| [open-thoughts/OpenThoughts-114k](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k) / train | 6,508 | **12,292** | 1,492 |
|
|
479
|
+
| [abisee/cnn_dailymail](https://huggingface.co/datasets/abisee/cnn_dailymail) / train / 3.0.0 | **57,944** | 44,286 | 13,874 |
|
|
480
|
+
| [teknium/OpenHermes-2.5](https://huggingface.co/datasets/teknium/OpenHermes-2.5) / train | **108,420** | 74,502 | 8,280 |
|
|
481
|
+
| [roneneldan/TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories) / train | **164,825** | 141,235 | 58,331 |
|
|
482
|
+
| [fancyzhx/amazon_polarity](https://huggingface.co/datasets/fancyzhx/amazon_polarity) / train | **214,217** | 162,448 | 14,613 |
|
|
483
|
+
| [Yelp/yelp_review_full](https://huggingface.co/datasets/Yelp/yelp_review_full) / train | **123,670** | 88,400 | 58,621 |
|
|
484
|
+
| [EdinburghNLP/xsum](https://huggingface.co/datasets/EdinburghNLP/xsum) / train | **55,941** | 37,684 | 15,377 |
|
|
485
|
+
| [Anthropic/hh-rlhf](https://huggingface.co/datasets/Anthropic/hh-rlhf) / train | **92,741** | 46,573 | 18,263 |
|
|
486
|
+
| [JeanKaddour/minipile](https://huggingface.co/datasets/JeanKaddour/minipile) / train | **81,871** | 50,160 | 3,928 |
|
|
487
|
+
| [ethz/food101](https://huggingface.co/datasets/ethz/food101) / train | 1,989 | **4,782** | 384 |
|
|
488
|
+
| [zh-plus/tiny-imagenet](https://huggingface.co/datasets/zh-plus/tiny-imagenet) / train | **57,855** | 43,535 | 6,491 |
|
|
489
|
+
| [uoft-cs/cifar10](https://huggingface.co/datasets/uoft-cs/cifar10) / train | **31,671** | 20,657 | 8,843 |
|
|
490
|
+
| [uoft-cs/cifar100](https://huggingface.co/datasets/uoft-cs/cifar100) / train | 22,448 | **24,332** | 7,553 |
|
|
491
|
+
| [s3prl/superb](https://huggingface.co/datasets/s3prl/superb) / train / ks | **7,101** | 6,775 | 314 |
|
|
492
|
+
|
|
493
|
+
Your own parquet on disk or S3 → [Stream parquet datasets](#stream-parquet).
|
|
494
|
+
|
|
425
495
|
# Key Features
|
|
426
496
|
|
|
427
497
|
## Features for optimizing and streaming datasets for model training
|
|
@@ -867,89 +937,6 @@ for sample in dataloader:
|
|
|
867
937
|
|
|
868
938
|
</details>
|
|
869
939
|
|
|
870
|
-
<details>
|
|
871
|
-
<summary> ✅ Stream Hugging Face 🤗 datasets <a id="stream-hf" href="#stream-hf">🔗</a> </summary>
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
To use your favorite Hugging Face dataset with LitData, simply pass its URL to `StreamingDataset`.
|
|
876
|
-
|
|
877
|
-
<details>
|
|
878
|
-
<summary>How to get HF dataset URI?</summary>
|
|
879
|
-
|
|
880
|
-
https://github.com/user-attachments/assets/3ba9e2ef-bf6b-41fc-a578-e4b4113a0e72
|
|
881
|
-
|
|
882
|
-
</details>
|
|
883
|
-
|
|
884
|
-
**Prerequisites:**
|
|
885
|
-
|
|
886
|
-
```sh
|
|
887
|
-
pip install 'litdata[extras]' huggingface_hub
|
|
888
|
-
|
|
889
|
-
# Optional: faster downloads on high-bandwidth networks
|
|
890
|
-
pip install hf_transfer
|
|
891
|
-
export HF_HUB_ENABLE_HF_TRANSFER=1
|
|
892
|
-
```
|
|
893
|
-
|
|
894
|
-
**Supported for HF:** datasets stored as **Parquet** only. Gated datasets: set `HF_TOKEN`.
|
|
895
|
-
|
|
896
|
-
**Stream Hugging Face dataset** (auto-index + auto `ParquetLoader`):
|
|
897
|
-
|
|
898
|
-
```python
|
|
899
|
-
import litdata as ld
|
|
900
|
-
|
|
901
|
-
hf_dataset_uri = "hf://datasets/leonardPKU/clevr_cogen_a_train/data"
|
|
902
|
-
|
|
903
|
-
dataset = ld.StreamingDataset(hf_dataset_uri) # indexes on first use; caches index.json locally
|
|
904
|
-
print("Sample", dataset[0]) # dict of columns
|
|
905
|
-
|
|
906
|
-
# With workers on Linux, use spawn (same as other ParquetLoader usage)
|
|
907
|
-
dataloader = ld.StreamingDataLoader(
|
|
908
|
-
dataset, batch_size=4, num_workers=4, multiprocessing_context="spawn"
|
|
909
|
-
)
|
|
910
|
-
for sample in dataloader:
|
|
911
|
-
pass
|
|
912
|
-
```
|
|
913
|
-
|
|
914
|
-
Unlike local/S3 parquet ([stream parquet](#stream-parquet)), `hf://` **automatically** indexes (if needed) and selects `ParquetLoader`.
|
|
915
|
-
|
|
916
|
-
### Indexing the HF dataset (optional, faster cold start)
|
|
917
|
-
|
|
918
|
-
```python
|
|
919
|
-
import litdata as ld
|
|
920
|
-
|
|
921
|
-
# Returns the local cache directory that contains index.json
|
|
922
|
-
cache_dir = ld.index_hf_dataset("hf://datasets/leonardPKU/clevr_cogen_a_train/data")
|
|
923
|
-
```
|
|
924
|
-
|
|
925
|
-
Or control the index path explicitly:
|
|
926
|
-
|
|
927
|
-
```python
|
|
928
|
-
import litdata as ld
|
|
929
|
-
from litdata.streaming.item_loader import ParquetLoader
|
|
930
|
-
|
|
931
|
-
uri = "hf://datasets/open-thoughts/OpenThoughts-114k/data"
|
|
932
|
-
ld.index_parquet_dataset(uri, "hf-index-dir") # writes index under hf-index-dir
|
|
933
|
-
|
|
934
|
-
dataset = ld.StreamingDataset(uri, item_loader=ParquetLoader(), index_path="hf-index-dir")
|
|
935
|
-
for batch in ld.StreamingDataLoader(dataset, batch_size=4, multiprocessing_context="spawn"):
|
|
936
|
-
pass
|
|
937
|
-
```
|
|
938
|
-
|
|
939
|
-
See also [Stream parquet datasets](#stream-parquet) for `ParquetLoader` knobs, wildcards, and stream-vs-optimize.
|
|
940
|
-
|
|
941
|
-
### LitData `Optimize` v/s `Parquet`
|
|
942
|
-
<!-- TODO: Update benchmark -->
|
|
943
|
-
Below is the benchmark for the `Imagenet dataset (155 GB)`, demonstrating that **`optimizing the dataset using LitData is faster and results in smaller output size compared to raw Parquet files`**.
|
|
944
|
-
|
|
945
|
-
| **Operation** | **Size (GB)** | **Time (seconds)** | **Throughput (images/sec)** |
|
|
946
|
-
|-----------------------------------|---------------|---------------------|-----------------------------|
|
|
947
|
-
| LitData Optimize Dataset | 45 | 283.17 | 4000-4700 |
|
|
948
|
-
| Parquet Optimize Dataset | 51 | 465.96 | 3600-3900 |
|
|
949
|
-
| Index Parquet Dataset (overhead) | N/A | 6 | N/A |
|
|
950
|
-
|
|
951
|
-
</details>
|
|
952
|
-
|
|
953
940
|
<details>
|
|
954
941
|
<summary> ✅ Streams on multi-GPU, multi-node <a id="multi-gpu" href="#multi-gpu">🔗</a> </summary>
|
|
955
942
|
|
|
@@ -993,9 +980,9 @@ Shuffling is **deterministic** and designed for distributed training:
|
|
|
993
980
|
|
|
994
981
|
The permutation depends on `seed`, the epoch, and chunk metadata — the same settings always yield the same order (required for resumable `state_dict`).
|
|
995
982
|
|
|
996
|
-
**Object storage (`s3://`, `gs://`, …)** globally permutes chunks (`FullShuffle`). Random chunk order is cheap once files are already copied into the local cache.
|
|
983
|
+
**Object storage (`s3://`, `gs://`, …)** globally permutes chunks (`FullShuffle`). Random chunk order is cheap once files are already copied into the local cache. Items *inside* a chunk are shuffled as aligned ``batch_decode`` windows. Pass ``item_shuffle_window=256`` (default / ``"auto"``) so blocks are shuffled, then the items inside each block — training still reuses the decode cache. ``item_shuffle_window=0`` (or ``"full"``) restores a full in-chunk permutation. ``LITDATA_ITEM_SHUFFLE_WINDOW`` applies only when the argument is omitted.
|
|
997
984
|
|
|
998
|
-
**POSIX-fast** (automatic for any local path) mmaps chunks in place. **Vast / NFS / Lustre / GPFS** (and `LITDATA_POSIX_FAST=1`) use `WindowShuffle`: each worker gets **whole chunks** in a sequential stripe, then shuffles
|
|
985
|
+
**POSIX-fast** (automatic for any local path) mmaps chunks in place. **Vast / NFS / Lustre / GPFS** (and `LITDATA_POSIX_FAST=1`) use `WindowShuffle`: each worker gets **whole chunks** in a sequential stripe, then shuffles chunk order inside a sliding window (default **16**, `LITDATA_POSIX_SHUFFLE_WINDOW`). In-chunk items still use ``item_shuffle_window``. Local disks (ext4/xfs) keep global `FullShuffle`. Object URLs stay on `FullShuffle`. `LITDATA_POSIX_FAST=0` disables in-place mmap.
|
|
999
986
|
|
|
1000
987
|
```python
|
|
1001
988
|
from litdata import StreamingDataset, StreamingDataLoader
|
|
@@ -1005,6 +992,7 @@ train = StreamingDataset(
|
|
|
1005
992
|
shuffle=True,
|
|
1006
993
|
drop_last=True, # keep every rank/worker at the same length (default True under DDP)
|
|
1007
994
|
seed=42, # default is 42; keep stable when resuming
|
|
995
|
+
item_shuffle_window=256, # 0 / "full" = permute every item in the chunk
|
|
1008
996
|
)
|
|
1009
997
|
loader = StreamingDataLoader(train, batch_size=64, num_workers=8)
|
|
1010
998
|
|
|
@@ -1807,7 +1795,7 @@ The `overwrite` mode will delete the existing data and start from fresh.
|
|
|
1807
1795
|
<summary> ✅ Stream parquet datasets <a id="stream-parquet" href="#stream-parquet">🔗</a> </summary>
|
|
1808
1796
|
|
|
1809
1797
|
|
|
1810
|
-
Stream existing Parquet files with LitData **without** converting them to LitData chunks — or convert them when you need LitData’s optimized binary format. Hugging Face
|
|
1798
|
+
Stream existing Parquet files with LitData **without** converting them to LitData chunks — or convert them when you need LitData’s optimized binary format. Hugging Face Hub datasets are covered in [Hugging Face Datasets](#huggingface-datasets).
|
|
1811
1799
|
|
|
1812
1800
|
### Stream vs optimize vs map
|
|
1813
1801
|
|
|
@@ -1852,7 +1840,7 @@ ld.index_parquet_dataset(
|
|
|
1852
1840
|
- Lists **top-level** `.parquet` files only (not recursive subfolders).
|
|
1853
1841
|
- All files must share the same schema.
|
|
1854
1842
|
- Supported for indexing today: local, `s3://`, `gs://`, `hf://` (not `r2://` / `azure://` yet).
|
|
1855
|
-
- For
|
|
1843
|
+
- For Hub datasets, use `StreamingDataset("hf://...")` — see [Hugging Face Datasets](#huggingface-datasets).
|
|
1856
1844
|
|
|
1857
1845
|
### Stream with `ParquetLoader`
|
|
1858
1846
|
|
|
@@ -1946,6 +1934,8 @@ Using [zstd](https://github.com/facebook/zstd), you can achieve high compression
|
|
|
1946
1934
|
| -------- | -------- |
|
|
1947
1935
|
| 2.8kb | 646b |
|
|
1948
1936
|
|
|
1937
|
+
`compression="zstd"` (default `compression_level="batch"`, `compression_batch_size=256`) keeps a `.bin` with an uncompressed directory plus zstd frames of 256 items — the same window as Arrow IPC record batches and aligned decode. `compression_level="chunk"` wraps each pytree chunk as one whole-file `.zstd.bin`. `compression_level="sample"` zstd-compresses each item between the pytree offsets. Numeric zstd levels are `compression="zstd:4"`, not `compression_level`. Nested JSON / Hub Arrow IPC still uses Arrow’s own per-batch zstd when you pass `"zstd"`.
|
|
1938
|
+
|
|
1949
1939
|
|
|
1950
1940
|
</details>
|
|
1951
1941
|
|
|
@@ -2189,6 +2179,7 @@ export LITDATA_ASYNC_DOWNLOAD_CONCURRENCY=4
|
|
|
2189
2179
|
| Variable | Default | Purpose |
|
|
2190
2180
|
|----------|---------|---------|
|
|
2191
2181
|
| `LITDATA_CACHE_DIR` | `~/.lightning/chunks` | Default chunk cache directory |
|
|
2182
|
+
| `LITDATA_ITEM_SHUFFLE_WINDOW` | `256` | In-chunk shuffle block size when `item_shuffle_window` is omitted (`0` = full permute) |
|
|
2192
2183
|
| `LITDATA_ASYNC_CHUNK_PREFETCH` | on for remote | `0`/`1` force async chunk download overlap |
|
|
2193
2184
|
| `LITDATA_ASYNC_MIN_PRE_DOWNLOAD` | `4` | Floor for `max_pre_download` when async is on (`0` = no floor) |
|
|
2194
2185
|
| `LITDATA_ASYNC_DOWNLOAD_CONCURRENCY` | `8` | Max in-flight chunk GETs per gather |
|
|
@@ -2623,7 +2614,9 @@ Full knob list for `litdata.optimize` (see Quick start for the minimal recipe).
|
|
|
2623
2614
|
| `chunk_bytes` | `None` | Max bytes per chunk (e.g. `"64MB"`; see [FAQ](#faq-chunk-shuffle) for larger samples) |
|
|
2624
2615
|
| `chunk_size` | `None` | Max items (or tokens with `TokensLoader`) per chunk |
|
|
2625
2616
|
| `align_chunking` | `False` | Match single-worker chunk boundaries (needs `chunk_size`; uneven load) |
|
|
2626
|
-
| `compression` | `None` | `"zstd"`
|
|
2617
|
+
| `compression` | `None` | `"zstd"` or `"zstd:N"` (numeric level). Pair with `compression_level` for pytree wrap |
|
|
2618
|
+
| `compression_level` | `"batch"` (zstd) | `"batch"` framed `.bin`; `"chunk"` whole-file `.zstd.bin`; `"sample"` per-item zstd |
|
|
2619
|
+
| `compression_batch_size` | `256` | Items per frame when `compression_level="batch"` (matches Arrow IPC / decode windows) |
|
|
2627
2620
|
| `encryption` | `None` | `FernetEncryption` / `RSAEncryption` / custom ([encrypt](#encrypt-decrypt)) |
|
|
2628
2621
|
| `num_workers` | CPU count | Local workers |
|
|
2629
2622
|
| `fast_dev_run` | `False` | Smoke a subset of inputs |
|
|
@@ -29,7 +29,7 @@ from litdata.streaming.parallel import ParallelStreamingDataset
|
|
|
29
29
|
from litdata.streaming.writer import index_parquet_dataset
|
|
30
30
|
from litdata.types import Audio, File, Graph, Image, Jpeg, JpegArray, Mesh, Nifti, Pdf, Pil, Tensor, Text, Tiff, Video
|
|
31
31
|
from litdata.utilities.breakpoint import breakpoint
|
|
32
|
-
from litdata.utilities.hf_dataset import index_hf_dataset
|
|
32
|
+
from litdata.utilities.hf_dataset import index_hf_dataset, optimize_hf
|
|
33
33
|
from litdata.utilities.keys_index import build_keys_index
|
|
34
34
|
from litdata.utilities.train_test_split import train_test_split
|
|
35
35
|
|
|
@@ -60,6 +60,7 @@ __all__ = [
|
|
|
60
60
|
"is_complete_dataset",
|
|
61
61
|
"index_parquet_dataset",
|
|
62
62
|
"index_hf_dataset",
|
|
63
|
+
"optimize_hf",
|
|
63
64
|
"breakpoint",
|
|
64
65
|
"ChunkWaitTimeoutError",
|
|
65
66
|
"Audio",
|