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 fix for max time to quit trainer gracefully, without running validation #7731

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nemo/utils/exp_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,18 @@ def state_dict(self) -> Dict[str, Any]:
def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
return

def _check_time_remaining(self, trainer: "pl.Trainer") -> None:
super()._check_time_remaining(trainer)
if trainer.should_stop:
checkpoint_callback: Optional[NeMoModelCheckpoint] = trainer.checkpoint_callback
if checkpoint_callback:
monitor_candidates = checkpoint_callback._monitor_candidates(trainer)
checkpoint_callback._save_last_checkpoint(trainer, monitor_candidates)
# Throw this exception to signal to Lightning to terminate gracefully.
from pytorch_lightning.utilities.exceptions import _TunerExitException

raise _TunerExitException()


def configure_no_restart_validation_training_loop(trainer: pytorch_lightning.Trainer) -> None:
if type(trainer.fit_loop.epoch_loop) != _TrainingEpochLoop:
Expand Down