Replace DataLoader sampler once for IPUs#8858
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8858 +/- ##
=======================================
Coverage 93% 93%
=======================================
Files 172 172
Lines 14114 14234 +120
=======================================
+ Hits 13091 13234 +143
+ Misses 1023 1000 -23 |
We don't have special tests, and only one IPU machine is available which is too slow for the full test suite CPU wise
carmocca
commented
Aug 14, 2021
carmocca
commented
Aug 14, 2021
awaelchli
approved these changes
Aug 16, 2021
kragniz
approved these changes
Aug 16, 2021
SeanNaren
approved these changes
Aug 16, 2021
four4fish
pushed a commit
to four4fish/pytorch-lightning
that referenced
this pull request
Aug 16, 2021
12 tasks
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?
Fixes current IPU CI failures.
Shortens IPU CI
Error:
We were getting the following error:
The cause was that we were calling
replace_sampler(which re-creates the dataloader with the correct sampler) first and_convert_to_poptorch_loaderas a second post-process of the dataloaders which also requires recreating the dataloader.However, in the first re-creation, a batch sampler is given which by the internal DataLoader design, sets
batch_size = None.This means that on the second re-creation, we do it it with
batch_size = Noneanddrop_last = Truewhich raises theValueErrorobserved.To fix this, we avoid doing this double re-creation and instead monkey-patch the function so the
poptorch.DataLoaderis used directly. This required splittingreplace_samplerinto two static methods to avoid code duplication.Even though monkey-patching like this is hacky, this solution was chosen because the IPU plugin is highly experimental and subject to change so we did not want to add an abstraction to the
Accelerator/TrainingTypePluginto support this.Finally, some other bug fixes were required to pass the correct
RunningStagearound.Does your PR introduce any breaking changes? If yes, please list them.
AcceleratorAPI:on_reset_{train,val,test,predict}_dataloaderhave been removed as they aren't necessary anymore. We don't process the dataloader twice after this PR.Trainer.request_dataloadernow takes aRunningStageinstead ofstr. Not sure how public is this function.Before submitting
PR review