-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WIP] Add Loop.stop()
#8604
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
[WIP] Add Loop.stop()
#8604
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,11 +68,10 @@ def batch_idx(self) -> int: | |
| @property | ||
| def done(self) -> bool: | ||
| """Returns whether the training should be stopped. | ||
| The criteria are that the number of steps reached the max steps, | ||
| the last batch is reached or the trainer signals to stop (e.g. by early stopping). | ||
| The criteria are that the number of steps reached the max steps, or the last batch is reached | ||
| """ | ||
| max_steps_reached = self.max_steps is not None and self.global_step >= self.max_steps | ||
| return max_steps_reached or self.trainer.should_stop or self._num_training_batches_reached(self.is_last_batch) | ||
| return max_steps_reached or self._num_training_batches_reached(self.is_last_batch) | ||
|
|
||
| def connect( | ||
| self, | ||
|
|
@@ -368,9 +367,6 @@ def _should_check_val_fx(self, batch_idx: int, is_last_batch: bool) -> bool: | |
| if is_last_batch and is_infinite_dataset: | ||
| return True | ||
|
|
||
| if self.trainer.should_stop: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as discussed, we might actually want to get rid of this completely.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me ! |
||
| return True | ||
|
|
||
| # TODO(@awaelchli): let training/eval loop handle logic around limit_*_batches and val_check_batch | ||
| is_val_check_batch = is_last_batch | ||
| if isinstance(self.trainer.limit_train_batches, int) and is_infinite_dataset: | ||
|
|
||
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.
Should we move accelerator reduction within should_stop from the loops ?
Uh oh!
There was an error while loading. Please reload this page.
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.
Possibly, It would clean the callbacks using it.
Thoughts? @justusschock @awaelchli