-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add dataloader_idx
to batch transfer hooks
#6241
Conversation
pytorch_lightning/core/lightning.py
Outdated
def _apply_batch_transfer_handler(self, batch: Any, device: Optional[torch.device] = None, dataloader_idx: int = 0): | ||
def _apply_batch_transfer_handler( | ||
self, batch: Any, device: Optional[torch.device] = None, dataloader_idx: Optional[int] = None | ||
): | ||
batch = self.on_before_batch_transfer(batch, dataloader_idx) | ||
batch = self.transfer_batch_to_device(batch, device) |
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 think we should remove the device
argument from transfer_batch_to_device
since this can easily be accessed using self.device
(device property of LightningModule).
Codecov Report
@@ Coverage Diff @@
## master #6241 +/- ##
======================================
- Coverage 92% 92% -0%
======================================
Files 199 199
Lines 13066 13073 +7
======================================
- Hits 12021 11990 -31
- Misses 1045 1083 +38 |
9470d61
to
dc46a6c
Compare
Hi @SeanNaren some deepspeed/sharded tests are failing here. Mind check the reason for it. Can't figure out what's causing these failures. Thanks :) |
9d0994c
to
04e4ee3
Compare
Hello @rohitgr7! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-05-11 18:26:45 UTC |
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.
is the args
>> kwargs
really needed to be done here as the R title does not mention it, I feel it would be much easier to review split it to two PRs
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.
overall the kwargs
seems much safer than just args
:]
Unlabeled API/design as this does not modify the API, |
cc @awaelchli as accelerator CODEOWNER |
transfer_batch_to_device API is updated. |
In any case, this was previously approved by William so no need for his explicit approval again. Feel free to merge |
dataloader_idx
to batch transfer hooks
What does this PR do?
Fixes #6058
Also updated the internal flow from args to kwargs (OrderedDict) to simplify things a bit and better accessibility and kwargs values are passed as args to the user-specific hooks for BC.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃