When streaming is the only option
For datasets larger than your disk — FineWeb, RedPajama, common-crawl-derived sets — streaming=True is mandatory. The returned IterableDataset never materializes; it pulls examples on demand from the underlying Parquet shards.
What changes
- No
len(), nods[i]. Forward-only iteration. mapstill works, but is lazy (transforms on iteration, not pre-baked).filterworks, but the rejection rate matters — if you filter 99%, you waste 99% of your I/O.shuffle(buffer_size=N)uses a reservoir sample of size N, not a global shuffle.
Multi-shard sharding for distributed training
iter_dataset = ds.shard(num_shards=8, index=worker_id) hands different shards to different workers. For DDP, datasets.distributed.split_dataset_by_node(ds, rank=rank, world_size=world_size) gives each rank its own slice, and PyTorch's DataLoader workers then split that rank's shards further.