Skip to content
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 transfer_batch_to_device hook to DataModule #3038

Merged
merged 5 commits into from Aug 20, 2020

Conversation

nateraw
Copy link
Contributor

@nateraw nateraw commented Aug 18, 2020

What does this PR do?

If transfer_batch_to_device is defined in datamodule, we'll use it instead of the default logic in trainer.

Fixes # (issue)

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@mergify mergify bot requested a review from a team August 18, 2020 17:23
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why we need to duplicate all data hooks from LightningModule into the DataModules. What prevents us from defining a data-interface and inherit in both classes? #2707

@mergify mergify bot requested a review from a team August 18, 2020 17:35
@codecov
Copy link

codecov bot commented Aug 18, 2020

Codecov Report

Merging #3038 into master will increase coverage by 1%.
The diff coverage is 83%.

@@           Coverage Diff            @@
##           master   #3038     +/-   ##
========================================
+ Coverage      89%     90%     +1%     
========================================
  Files          81      81             
  Lines        7796   10870   +3074     
========================================
+ Hits         6959    9787   +2828     
- Misses        837    1083    +246     

@nateraw
Copy link
Contributor Author

nateraw commented Aug 18, 2020

I still don't understand why we need to duplicate all data hooks from LightningModule into the DataModules. What prevents us from defining a data-interface and inherit in both classes? #2707

@awaelchli I felt the same thing as I submitted this. At this point (right before major release), I don't want to make major refactor to hooks. After 0.9.0 we can knock this out, because you're right...it seems pointless to copy over.

Does that sound reasonable?

@awaelchli
Copy link
Member

I hope we can pick this up immediately after 0.9. I believe we otherwhise risk that these two defintions diverge and at some point we will have bugs because the Trainer does not call the hooks in one class the same way as in the other etc. This of course translates into maintenance effort that should not be.

@nateraw
Copy link
Contributor Author

nateraw commented Aug 18, 2020

Agreed!

@nateraw
Copy link
Contributor Author

nateraw commented Aug 18, 2020

@awaelchli - this test look good? Borrowed logic from you

@awaelchli
Copy link
Member

well, given my previous comment I also have to answer no here 🤣 . Can we not parametrize the original test to use the LightningModule class and the DataModule class as inputs to the test?

@nateraw
Copy link
Contributor Author

nateraw commented Aug 18, 2020

well, given my previous comment I also have to answer no here 🤣 . Can we not parametrize the original test to use the LightningModule class and the DataModule class as inputs to the test?

opted to put it separately in datamodule file because I think it makes more sense to live there.

@williamFalcon
Copy link
Contributor

generally we are decoupling the data from the lightningmodule. but keeping the option to keep the data linked.

the last missing key here is the ability for a datamodule to define how it transfers data in case you have really weird formats

@williamFalcon
Copy link
Contributor

@awaelchli we can do that after 0.9 but we need to think about it carefully as well to make sure we don't break functionality or bleed abstractions over.

Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes of course, don't want to block this. thanks for discussion and considerations 😃 ❤️

@mergify mergify bot requested a review from a team August 18, 2020 21:00
@mergify mergify bot requested a review from a team August 19, 2020 19:34
@nateraw nateraw added the ready PRs ready to be merged label Aug 19, 2020
@williamFalcon williamFalcon merged commit bab89b8 into Lightning-AI:master Aug 20, 2020
@Borda Borda added this to the 0.9.0 milestone Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants