-
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
Replace _DataModuleWrapper
with __new__
[1/2]
#7289
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7289 +/- ##
======================================
- Coverage 91% 91% -0%
======================================
Files 199 199
Lines 12797 12807 +10
======================================
- Hits 11678 11672 -6
- Misses 1119 1135 +16 |
_DataModuleWrapper
with __new__
_DataModuleWrapper
with __new__
[1/2]
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.
Would it be simpler to have explicit properties and setters on the datamodule which the trainer can set after calling the hooks?
I also am not sure if the current properties are correct for setup and teardown if one re-uses the same module across consecutive calls.
What's expected for this?
trainer.fit(model, dm)
trainer.fit(model, dm)
Should the second call skip calling the datamodule hooks?
This is the case already. But instead of setting them manually by the trainer, it is done automatically using these "hacks".
This is also the case already. It is not if the user does the call manually (e.g. |
Actually why do we need these setters at all? Couldn't we push the responsibility to the datamodule on whether it needs to download data again? Then we can simplify the trainer and avoid all the hook wrappers here This way we have to worry less about state across trainer calls |
If I had designed this from the beginning I would have done one of the 2 following options instead of what we have:
But this is not the current design and I don't think we can safely switch the behaviour. |
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 left some comments. It looks good to me. However, I don't enough about these things for being confident enough to approve.
f473428
to
905a0bf
Compare
Do you think we can add warnings in the trainer if the |
Do you mean if we go with option (1)?:
Do you want to open an RFC or discussion about this? |
What does this PR do?
We now rely on
__new__
to wrap and track theDataHooks
calls.Fixes:
This fixes a bug where the
_DataModuleWrapper
implementation was adding as many wrapped layers as the number of DataModule subclasses.This is not a problem if a wrapped layer does not impact any further wrapper layers which is no longer the case after #7238 (blocked by this PR).
And even without #7238, we should not wrap these hooks multiple times.
To compare the behaviors, see the following minimal examples:
Current master
This PR
Question:
How do I even test this automatically?
Before submitting
PR review