Stop DataLoaderShard taking a device mesh it never reads - #4252
Open
vineethsaivs wants to merge 1 commit into
Open
Stop DataLoaderShard taking a device mesh it never reads#4252vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
DataLoaderDispatcher stores torch_device_mesh and builds its tp, dp and fsdp submeshes from it. DataLoaderShard takes the same argument, documents none of it in a docstring that covers every other parameter, and never reads it. prepare_data_loader only hands the mesh to the dispatcher, so nothing in accelerate is affected. Anyone constructing DataLoaderShard directly with a mesh gets silence instead of either an effect or an error. Drop the parameter. It now lands in **kwargs and DataLoader rejects it, which is the same loud failure any other unknown argument gets. Test: test_dataloader_shard_does_not_take_a_device_mesh, which also pins that the dispatcher still accepts one. It fails on main with "TypeError not raised".
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 breaks
DataLoaderShard(dataset, torch_device_mesh=mesh)accepts the mesh and ignores it.Its sibling does not:
DataLoaderShard.__init__takes the same argument, never stores it, and never reads it. Its docstring documents every other parameter and not this one.Scope
prepare_data_loaderonly hands the mesh to the dispatcher, so nothing inside accelerate is affected. The trap is for anyone building aDataLoaderSharddirectly, which is a public, exported class: they get silence rather than either an effect or an error.What changed
Drop the parameter. It now falls into
**kwargs, whereDataLoaderrejects it, so an unknown argument fails the same loud way any other one does.Tests
test_dataloader_shard_does_not_take_a_device_meshasserts the shard rejects it and that the dispatcher still accepts one.On main:
ruff0.13.1, the pin insetup.py, is clean on both files.Related
Same class of thing as #4251, which removes a
split_batchesargumentAccelerator.__init__never reads. Separate file and separate call path, so they are separate PRs, but happy to fold them together if you would rather review one.