Lhotse: add prefetch_factor option to LhotseDataLoadingConfig#15665
Open
XuesongYang wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Open
Lhotse: add prefetch_factor option to LhotseDataLoadingConfig#15665XuesongYang wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
XuesongYang wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Conversation
Add configurable prefetch_factor for PyTorch DataLoader, allowing users to increase the per-worker prefetch buffer depth to absorb I/O latency spikes from network filesystems. Applies to both single-config and multi-config dataloader paths. When unset (None), PyTorch's default of 2 is used, preserving existing behavior. Usage: model.train_ds.prefetch_factor=4 Signed-off-by: Xuesong Yang <1646669+XuesongYang@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new prefetch_factor knob to NeMo’s Lhotse-backed dataloader configuration so users can tune PyTorch DataLoader per-worker prefetch depth to better tolerate I/O latency spikes (e.g., on network filesystems), while keeping existing behavior when unset.
Changes:
- Introduced
prefetch_factor: int | None = NoneinLhotseDataLoadingConfig. - Passed
prefetch_factorthrough totorch.utils.data.DataLoaderwhennum_workers > 0in both single-config and multi-config dataloader creation paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+508
to
+509
| if shared_opts.num_workers > 0 and shared_opts.get("prefetch_factor") is not None: | ||
| dloader_kwargs["prefetch_factor"] = shared_opts.prefetch_factor |
| pin_memory=config.pin_memory, | ||
| ) | ||
| if config.num_workers > 0 and config.get("prefetch_factor") is not None: | ||
| dloader_kwargs["prefetch_factor"] = config.prefetch_factor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add configurable
prefetch_factorfor PyTorch DataLoader, allowing users to increase the per-worker prefetch buffer depth to absorb I/O latency spikes from network filesystems. Applies to both single-config and multi-config dataloader paths.When unset (None), PyTorch's default of 2 is used, preserving existing behavior.
Usage:
model.train_ds.prefetch_factor=4