Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] DataLoaderConfiguration docstring #3103

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/accelerate/utils/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,34 @@ class TensorInformation:
class DataLoaderConfiguration:
"""
Configuration for dataloader-related items when calling `accelerator.prepare`.

Args:
split_batches (`bool`, defaults to `False`):
Whether or not the accelerator should split the batches yielded by the dataloaders across the devices. If
`True`, the actual batch size used will be the same on any kind of distributed processes, but it must be a
round multiple of `num_processes` you are using. If `False`, actual batch size used will be the one set in
your script multiplied by the number of processes.
dispatch_batches (`bool`, defaults to `None`):
If set to `True`, the dataloader prepared by the Accelerator is only iterated through on the main process
and then the batches are split and broadcast to each process. Will default to `True` for `DataLoader` whose
underlying dataset is an `IterableDataset`, `False` otherwise.
even_batches (`bool`, defaults to `True`):
If set to `True`, in cases where the total batch size across all processes does not exactly divide the
dataset, samples at the start of the dataset will be duplicated so the batch can be divided equally among
all workers.
use_seedable_sampler (`bool`, defaults to `False`):
Whether or not use a fully seedable random sampler ([`data_loader.SeedableRandomSampler`]). Ensures
training results are fully reproducable using a different sampling technique. While seed-to-seed results
may differ, on average the differences are neglible when using multiple different seeds to compare. Should
also be ran with [`~utils.set_seed`] for the best results.
non_blocking (`bool`, defaults to `False`):
If set to `True`, the dataloader prepared by the Accelerator will utilize non-blocking host-to-device
transfers, allowing for better overlap between dataloader communication and computation. Recommended that
the prepared dataloader has `pin_memory` set to `True` to work properly.
use_stateful_dataloader (`bool`, defaults to `False`):
If set to `True`, the dataloader prepared by the Accelerator will be backed by
[torchdata.StatefulDataLoader](https://github.com/pytorch/data/tree/main/torchdata/stateful_dataloader).
This requires `torchdata` version 0.8.0 or higher that supports StatefulDataLoader to be installed.
"""

split_batches: bool = field(
Expand Down
Loading