Skip to content

Commit

Permalink
[EASY] Always log 1st batch when resuming training (#3009)
Browse files Browse the repository at this point in the history
* logging 1st batch regardless

* comments
  • Loading branch information
bigning authored Feb 14, 2024
1 parent f9c485c commit 9e60fa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer/loggers/console_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ def epoch_end(self, state: State, logger: Logger) -> None:
cur_epoch = int(state.timestamp.epoch) # epoch gets incremented right before EPOCH_END
unit = self.log_interval.unit

if unit == TimeUnit.EPOCH and (cur_epoch % int(self.log_interval) == 0 or cur_epoch == 1):
if unit == TimeUnit.EPOCH and (cur_epoch % int(self.log_interval) == 0 or self.last_logged_batch == 0):
self.log_to_console(self.logged_metrics, prefix='Train ', state=state)
self.last_logged_batch = int(state.timestamp.batch)
self.logged_metrics = {} # Clear logged metrics.

def batch_end(self, state: State, logger: Logger) -> None:
cur_batch = int(state.timestamp.batch)
unit = self.log_interval.unit
if unit == TimeUnit.BATCH and (cur_batch % int(self.log_interval) == 0 or cur_batch == 1):
if unit == TimeUnit.BATCH and (cur_batch % int(self.log_interval) == 0 or self.last_logged_batch == 0):
self.log_to_console(self.logged_metrics, prefix='Train ', state=state)
self.last_logged_batch = cur_batch
self.logged_metrics = {} # Clear logged metrics.
Expand Down

0 comments on commit 9e60fa3

Please sign in to comment.