Repository navigation
Conversation
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.
What does this PR do?
Accelerator.preparewraps aDataLoaderover anIterableDatasetinDataLoaderDispatcher. When the data holds no complete batch (it is empty, or has fewer samples thanbatch_sizewithdrop_last=True), iterating the prepared loader raises, while the plainDataLoaderyields nothing:On main the last line raises
ValueError: Batch does not contain any data; expected0. Same for an empty dataset with anydrop_last. With two processes it is aTypeErrorfrombroadcast.The first
_fetch_batchescall already reports the end with no data, but__iter__still broadcasts and splits theNonebatch. This returns early instead, asDataLoaderShard.__iter__already does for an empty loader. TheValueErrorcame from #1531, which made this crash readable; a similar early return was part of #4374, closed by its author without review.Tests:
test_iterable_dataset_without_full_batchfails on main (2 failed) and passes with the fix;python -m pytest tests/test_data_loader.py: 29 passed, 13 skipped.torchrun --nproc_per_node 2on CPU (gloo), empty/short/full iterable datasets xsplit_batchesxdrop_last: both ranks yield the expected batch count, no hang.make qualitypasses. Not run: GPU, rest of the suite.The implementation and tests were written with AI assistance.
Use case
I don't have a use case
Who can review?
cc @SunMarc