-
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
TrainerState
refactor [5/5]
#7173
Conversation
Hello @carmocca! Thanks for updating this PR.
Comment last updated at 2021-05-04 10:05:34 UTC |
Codecov Report
@@ Coverage Diff @@
## master #7173 +/- ##
======================================
Coverage 91% 91%
======================================
Files 200 200
Lines 12916 12922 +6
======================================
+ Hits 11764 11792 +28
+ Misses 1152 1130 -22 |
TrainerState
refactorTrainerState
refactor [3/n]
TrainerState
refactor [3/n]TrainerState
refactor [4/n]
TrainerState
refactor [4/n]TrainerState
refactor [5/n]
TrainerState
refactor [5/n]TrainerState
refactor [5/5]
TrainerState
refactor [5/5]TrainerState
refactor [5/5]
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.
Great refactor! I think this will make #7315 easier by providing a central dataclass we can build on top of.
How'd you find all the references to trainer.state or trainer.running_stage? grep? Deleting the properties and seeing what broke?
Bit of both :) |
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.
just need to clarify the back compatibility, how about usest who were asking trainer.state
?
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.
Really neat !
If users were relying on it, it will break but:
|
What does this PR do?
TrainerState
is now adataclass
which contains theTrainerStatus
,TrainerFn
(previousTrainerState
), andRunningStage
.See the changes to
pytorch-lightning/pytorch_lightning/trainer/states.py
for an overview. All other changes are just fixing the code to work with that.cc: @ananthsub. The
TrainerState
dataclass could be the one used for progress tracking in the future.I'm open to different class names if the proposed ones are confusing.
Fixes
(Reported on Slack)
When
KeyboardInterrupt
is handled in the trainer, we setself.state = TrainerState.INTERRUPTED
, thus losing the reference to the originalTrainerState
({fit,validate,test,predict}
). This means when teardown gets called, we don't know which stage should be set.Fixes #7286
Before submitting
PR review