-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Proposed refactor
Deprecate save from LightningLoggerBase:
https://github.com/PyTorchLightning/pytorch-lightning/blob/a8ee5cacb7b31064c8b73372ca944d43f7caadc6/pytorch_lightning/loggers/base.py#L173-L175
Motivation
After #9145 save on the LightningLoggerBase does nothing, and only 2 loggers have implementations for it: CSVLogger and TensorboardLogger.
After #8991 we now consider flushing an internal implementation detail of the loggers, so it follows that save should also be an internal implementation detail of the loggers.
Currently the Trainer calls log_metrics and save together here:
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc0e1da6329c42ec3b7c6fbf91eb059b9124207/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py#L131-L132
Instead, the Trainer can just call log_metrics and the actual saving can be delegated completely to the logger, including buffering & flush frequency.
Pitch
in v1.6:
- Deprecate
savefromLightningLoggerBase - For the following three
savecalls, only call ifsaveis overridden in the Logger:
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc0e1da6329c42ec3b7c6fbf91eb059b9124207/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py#L132
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc0e1da6329c42ec3b7c6fbf91eb059b9124207/pytorch_lightning/trainer/trainer.py#L1241
https://github.com/PyTorchLightning/pytorch-lightning/blob/6bc0e1da6329c42ec3b7c6fbf91eb059b9124207/pytorch_lightning/loops/epoch/training_epoch_loop.py#L508
(Note: the finalsavecall above will be removed in v1.7 following the removal offlush_logs_every_n_steps)
in v1.8:
- For
CSVLoggerandTensorboardLoggertheirlog_metricsandlog_graphimplementations should callsave - Remove
savefromLightningLoggerBase
Additional Context
This was discussed in #9004
cc @justusschock @awaelchli @akihironitta @rohitgr7 @edward-io @Borda @ananthsub @kamil-kaczmarek @Raalsky @Blaizzy @tchaton