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
Correctly convert namedtuples in DDP #44220
Conversation
Closes #44009 Currently if a dataloader returns objects created with a collections.namedtuple, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/) [ghstack-poisoned]
Closes #44009 Currently if a dataloader returns objects created with a `collections.namedtuple` or `typing.NamedTuple`, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/) [ghstack-poisoned]
Pull Request resolved: #44220 Closes #44009 Currently if a dataloader returns objects created with a collections.namedtuple, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 ghstack-source-id: 111478085 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/)
💊 CI failures summary and remediationsAs of commit 939378b (more details on the Dr. CI page): Commit 939378b was recently pushed. Waiting for builds... This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 15 times. |
Not sure who the best reviewer for this change is since |
test/distributed/test_distributed.py
Outdated
@require_backend({"nccl", "gloo"}) | ||
@require_n_gpus_for_nccl_backend(int(os.environ["WORLD_SIZE"]), os.environ["BACKEND"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add some unit test that directly test the scatter
API with a variety of test cases? For example the case for namedtuple(a=1, b=1)
you mentioned in the docs is a good test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this test in test/test_cuda.py
since it doesn't look like there were tests for this API anywhere else.
Closes #44009 Currently if a dataloader returns objects created with a `collections.namedtuple` or `typing.NamedTuple`, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/) [ghstack-poisoned]
Pull Request resolved: #44220 Closes #44009 Currently if a dataloader returns objects created with a collections.namedtuple, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 ghstack-source-id: 112050439 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/)
Closes #44009 Currently if a dataloader returns objects created with a `collections.namedtuple` or `typing.NamedTuple`, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/) [ghstack-poisoned]
Pull Request resolved: #44220 Closes #44009 Currently if a dataloader returns objects created with a collections.namedtuple, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 ghstack-source-id: 112198252 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/)
Codecov Report
@@ Coverage Diff @@
## gh/rohan-varma/164/base #44220 +/- ##
===========================================================
+ Coverage 67.85% 68.50% +0.65%
===========================================================
Files 384 409 +25
Lines 49919 52587 +2668
===========================================================
+ Hits 33873 36026 +2153
- Misses 16046 16561 +515
Continue to review full report at Codecov.
|
@pritamdamania87 Added the tests for scatter, any more thoughts on this diff? Thanks! |
|
||
scatter_out = scatter_gather.scatter(inp, target_gpus) | ||
for x in scatter_out: | ||
self.assertTrue(isinstance(x, type(inp))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also assert that the _fields
attribute is preserved correctly and also the appropriate values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, adding the tests for valued actually uncovered a bug in the implementation that I just fixed.
Closes #44009 Currently if a dataloader returns objects created with a `collections.namedtuple` or `typing.NamedTuple`, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/) [ghstack-poisoned]
Pull Request resolved: #44220 Closes #44009 Currently if a dataloader returns objects created with a collections.namedtuple, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple. Fix this in `scatter_gather.py` to resolve the issue reported in #44009 ghstack-source-id: 113423287 Differential Revision: [D23536752](https://our.internmc.facebook.com/intern/diff/D23536752/)
This pull request has been merged in f8c1ca5. |
Stack from ghstack:
Closes #44009
Currently if a dataloader returns objects created with a
collections.namedtuple
ortyping.NamedTuple
, this will incorrectly be cast to a tuple. As a result, if we have data of these types, there can be runtime errors during the forward pass if the module is expecting a named tuple.Fix this in
scatter_gather.py
to resolve the issue reported in#44009
Differential Revision: D23536752