Printing profile on sig kill. (#44)

* added skeleton for terminal logger

* done skeleton terminal writer logic... todo: actual calls to the write classes

* moved lambda to top function

* added logic to support timing

* prettier printing

* prettier printing

* lint

* separated out timing and other stats variables. printing in dict format

* keeping logging history and wiping rest

* updated logic to calculate total times instead of average times

* made stats tracker configurable

* moved stats tracker and profiler to own class file; implemented basic functionality for profiler

* lint removing duplicate function

* update readme; moved around config variables

* profiler prints on sig kill
This commit is contained in:
evonneng authored and GitHub committed 2022-04-29 11:10:34 -07:00
1 parent 47691eb291
commit 86b1011ae1
8 files changed
+46 -24

No files matched your search

+3 -3
View File
@@ -47,7 +47,8 @@ class Trainer:
writer = getattr(mattport.utils.writer, self.config.logging_configs.writer.type)
self.writer = writer(local_rank, world_size, save_dir=self.config.logging_configs.writer.save_dir)
self.stats = StatsTracker(config, self.is_main_thread)
profiler.PROFILER = profiler.Profiler(config, self.is_main_thread)
if not profiler.PROFILER and self.config.logging_configs.enable_profiler:
profiler.PROFILER = profiler.Profiler(config, self.is_main_thread)
self.dry_run = self.config.get("dry_run", False)
@profiler.time_function
@@ -178,7 +179,7 @@ class Trainer:
)
self.stats.update_time(Stats.ITER_TRAIN_TIME, iter_start, time(), step=step)
if step != 0 and step % self.config.steps_per_log == 0:
if step != 0 and step % self.config.logging_configs.steps_per_log == 0:
self.writer.write_scalar_dict(loss_dict, step, group="Loss", prefix="train-")
# TODO: add the learning rates to tensorboard/logging
if step != 0 and self.config.steps_per_save and step % self.config.steps_per_save == 0:
@@ -190,7 +191,6 @@ class Trainer:
self.stats.update_time(Stats.TOTAL_TRAIN_TIME, train_start, time(), step=-1)
self.stats.print_stats(-1)
profiler.PROFILER.print_profile()
@profiler.time_function
def train_iteration(self, batch: dict, step: int):