@@ -78,7 +78,7 @@ def progress_bar_metrics(self, progress_bar_metrics: Dict) -> None:
78
78
79
79
@property
80
80
def cached_results (self ) -> Union [EpochResultStore , None ]:
81
- return self ._cached_results .get (self .trainer ._running_stage ) # type: ignore
81
+ return self ._cached_results .get (self .trainer ._running_stage )
82
82
83
83
def get_metrics (self , key : str ) -> Dict :
84
84
metrics_holder : MetricsHolder = getattr (self , f"_{ key } " )
@@ -121,8 +121,6 @@ def cache_logged_metrics(self):
121
121
def on_trainer_init (self , logger , flush_logs_every_n_steps : int , log_every_n_steps : int , move_metrics_to_cpu : bool ):
122
122
# logging
123
123
self .configure_logger (logger )
124
- # todo: IDE is complaining, these shall be initialized in the Trainer init at leas as placeholders
125
- # and assign here the desired value
126
124
self .trainer .flush_logs_every_n_steps = flush_logs_every_n_steps
127
125
self .trainer .log_every_n_steps = log_every_n_steps
128
126
self .trainer .move_metrics_to_cpu = move_metrics_to_cpu
@@ -185,9 +183,6 @@ def cache_training_step_metrics(self, opt_closure_result):
185
183
batch_log_metrics = opt_closure_result .training_step_output .log_metrics
186
184
logged_metrics_tmp .update (batch_log_metrics )
187
185
188
- callback_metrics = opt_closure_result .training_step_output .callback_metrics
189
- callback_metrics_tmp .update (callback_metrics )
190
-
191
186
batch_pbar_metrics = opt_closure_result .training_step_output .pbar_on_batch_end
192
187
pbar_metrics_tmp .update (batch_pbar_metrics )
193
188
@@ -210,9 +205,6 @@ def log_metrics(self, metrics, grad_norm_dic, step=None):
210
205
metrics (dict): Metric values
211
206
grad_norm_dic (dict): Gradient norms
212
207
step (int): Step for which metrics should be logged. Default value corresponds to `self.global_step`
213
- log_train_step_metrics (bool): Used to track if `log_metrics` function is being called in during training
214
- steps. In training steps, we will log metrics on step: `total_nb_idx` (for accumulated gradients)
215
- and global_step for the rest.
216
208
"""
217
209
# add gpu memory
218
210
if self .trainer ._device_type == DeviceType .GPU and self .log_gpu_memory :
@@ -339,9 +331,9 @@ def _track_callback_metrics(self, eval_results):
339
331
if self .trainer .state in (TrainerState .TESTING , TrainerState .VALIDATING ):
340
332
self .trainer .logger_connector .evaluation_callback_metrics .update (flat )
341
333
342
- def __process_eval_epoch_end_results_and_log_legacy_update (self , prog_bar_metrics , log_metrics , callback_metrics ):
334
+ def __process_eval_epoch_end_results_and_log_legacy_update (self , prog_bar_metrics , log_metrics ):
343
335
# eval loop returns all metrics
344
- dataloader_result_metrics = {** prog_bar_metrics , ** log_metrics , ** callback_metrics }
336
+ dataloader_result_metrics = {** prog_bar_metrics , ** log_metrics }
345
337
346
338
# add metrics to prog bar
347
339
self .trainer .logger_connector .add_progress_bar_metrics (prog_bar_metrics )
@@ -350,13 +342,6 @@ def __process_eval_epoch_end_results_and_log_legacy_update(self, prog_bar_metric
350
342
if len (log_metrics ) > 0 :
351
343
self .trainer .logger_connector .log_metrics (log_metrics , {})
352
344
353
- # track metrics for callbacks (all prog bar, logged and callback metrics)
354
- callback_metrics .update (log_metrics )
355
- callback_metrics .update (prog_bar_metrics )
356
- self .trainer .logger_connector .callback_metrics .update (callback_metrics )
357
- if self .trainer .state in (TrainerState .TESTING , TrainerState .VALIDATING ):
358
- self .trainer .logger_connector .evaluation_callback_metrics .update (callback_metrics )
359
-
360
345
if len (dataloader_result_metrics ) > 0 :
361
346
self .eval_loop_results .append (dataloader_result_metrics )
362
347
@@ -371,20 +356,16 @@ def __process_eval_epoch_end_results_and_log_legacy(self, eval_results):
371
356
eval_results = [eval_results ]
372
357
373
358
num_loaders : int = self .trainer .evaluation_loop .num_dataloaders
374
- prog_bar_metrics , log_metrics , callback_metrics = {}, {}, {}
359
+ prog_bar_metrics , log_metrics = {}, {}
375
360
376
361
for result_idx , result in enumerate (eval_results ):
377
- _ , prog_bar_metrics , log_metrics , callback_metrics = self .trainer .process_dict_result (result )
362
+ _ , prog_bar_metrics , log_metrics = self .trainer .process_dict_result (result )
378
363
379
364
if num_loaders > 1 :
380
- self .__process_eval_epoch_end_results_and_log_legacy_update (
381
- prog_bar_metrics , log_metrics , callback_metrics
382
- )
365
+ self .__process_eval_epoch_end_results_and_log_legacy_update (prog_bar_metrics , log_metrics )
383
366
384
367
if num_loaders == 1 :
385
- self .__process_eval_epoch_end_results_and_log_legacy_update (
386
- prog_bar_metrics , log_metrics , callback_metrics
387
- )
368
+ self .__process_eval_epoch_end_results_and_log_legacy_update (prog_bar_metrics , log_metrics )
388
369
389
370
def on_train_epoch_end (self ):
390
371
# inform cached logger connector epoch finished
@@ -397,8 +378,6 @@ def log_train_epoch_end_metrics(self, epoch_output, num_optimizers):
397
378
398
379
model = self .trainer .lightning_module
399
380
400
- epoch_callback_metrics = {}
401
-
402
381
# ------------------------
403
382
# determine if using a result obj
404
383
# ------------------------
@@ -426,10 +405,9 @@ def log_train_epoch_end_metrics(self, epoch_output, num_optimizers):
426
405
427
406
# TODO: deprecate 1.0
428
407
else :
429
- out = self .__run_legacy_training_epoch_end (
430
- num_optimizers , epoch_output , model , is_result_obj , epoch_callback_metrics
408
+ epoch_log_metrics , epoch_progress_bar_metrics = self .__run_legacy_training_epoch_end (
409
+ num_optimizers , epoch_output , model , is_result_obj
431
410
)
432
- epoch_log_metrics , epoch_progress_bar_metrics , epoch_callback_metrics = out
433
411
434
412
# it will perform reduction over epoch and return log metrics
435
413
cached_epoch_log_metrics = self .cached_results .get_epoch_log_metrics ()
@@ -447,9 +425,6 @@ def log_train_epoch_end_metrics(self, epoch_output, num_optimizers):
447
425
self .log_metrics (epoch_log_metrics , {})
448
426
self ._callback_metrics .update (epoch_log_metrics )
449
427
450
- # add metrics to callbacks
451
- self ._callback_metrics .update (epoch_callback_metrics )
452
-
453
428
# add metrics to progress_bar and callbacks
454
429
if len (epoch_progress_bar_metrics ) > 0 :
455
430
self .add_progress_bar_metrics (epoch_progress_bar_metrics )
@@ -481,9 +456,7 @@ def training_epoch_end(self, model, epoch_output, num_optimizers):
481
456
# capture logging
482
457
self .trainer .logger_connector .cache_logged_metrics ()
483
458
484
- def __run_legacy_training_epoch_end (
485
- self , num_optimizers , epoch_output , model , is_result_obj , epoch_callback_metrics
486
- ):
459
+ def __run_legacy_training_epoch_end (self , num_optimizers , epoch_output , model , is_result_obj ):
487
460
488
461
epoch_log_metrics = {}
489
462
epoch_progress_bar_metrics = {}
@@ -514,15 +487,14 @@ def __run_legacy_training_epoch_end(
514
487
_processed_outputs = self .trainer .process_dict_result (epoch_output )
515
488
epoch_progress_bar_metrics = _processed_outputs [1 ]
516
489
epoch_log_metrics = _processed_outputs [2 ]
517
- epoch_callback_metrics = _processed_outputs [3 ]
518
490
519
491
# --------------------------
520
492
# Structured Result (auto epoch end)
521
493
# --------------------------
522
494
elif is_result_obj :
523
495
epoch_log_metrics , epoch_progress_bar_metrics = self .__auto_reduce_results_on_epoch_end (epoch_output )
524
496
525
- return epoch_log_metrics , epoch_progress_bar_metrics , epoch_callback_metrics
497
+ return epoch_log_metrics , epoch_progress_bar_metrics
526
498
527
499
def __auto_reduce_results_on_epoch_end (self , epoch_output ):
528
500
epoch_log_metrics = {}
0 commit comments