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

Remove TrainingTypePlugin.on_save and Accelerator.on_save #9023

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed deprecated `GradInformation` module in favor of `pytorch_lightning.utilities.grads` ([#8831](https://github.com/PyTorchLightning/pytorch-lightning/pull/8831/))


- Removed `TrainingTypePlugin.on_save` and `Accelerator.on_save` ([#9023](https://github.com/PyTorchLightning/pytorch-lightning/pull/9023))


- Removed deprecated `connect_precision_plugin` and `connect_training_type_plugin` from `Accelerator` ([#9019](https://github.com/PyTorchLightning/pytorch-lightning/pull/9019))


Expand Down
3 changes: 0 additions & 3 deletions pytorch_lightning/accelerators/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,6 @@ def lightning_module_state_dict(self) -> Dict[str, Union[Any, Tensor]]:
"""
return self.training_type_plugin.lightning_module_state_dict()

def on_save(self, checkpoint: Dict[str, Union[Any, Tensor]]) -> Dict[str, Union[Any, Tensor]]:
return self.training_type_plugin.on_save(checkpoint)

def barrier(self, name: Optional[str] = None) -> None:
self.training_type_plugin.barrier(name=name)

Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/plugins/training_type/ddp_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __transfer_distrib_spawn_state_on_fit_end(self, trainer: "pl.Trainer", resul
last_path = None
if trainer.state.fn == TrainerFn.FITTING and best_model_path is not None and len(best_model_path) > 0:
last_path = re.sub(".ckpt", ".tmp_end.ckpt", best_model_path)
atomic_save(self.on_save(state_dict), last_path)
atomic_save(state_dict, last_path)

# todo, pass complete checkpoint as state dictionary
self.mp_queue.put(best_model_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ def validation_step_end(self, output):
def test_step_end(self, output):
return output

def on_save(self, checkpoint: Dict[str, Union[Any, torch.Tensor]]) -> Dict[str, Union[Any, torch.Tensor]]:
return checkpoint

def process_dataloader(self, dataloader: Union[Iterable, DataLoader]) -> Union[Iterable, DataLoader]:
"""Wraps the dataloader if necessary

Expand Down Expand Up @@ -273,8 +270,6 @@ def save_checkpoint(self, checkpoint: Dict[str, Any], filepath: str) -> None:
checkpoint: dict containing model and trainer state
filepath: write-target file's path
"""
# dump states as a checkpoint dictionary object
checkpoint = self.on_save(checkpoint)
if self.should_rank_save_checkpoint:
return self.checkpoint_io.save_checkpoint(checkpoint, filepath)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ def hpc_save(self, folderpath: str, logger):

model.on_hpc_save(checkpoint)

checkpoint = self.trainer.accelerator.on_save(checkpoint)

# do the actual save
# TODO: fix for anything with multiprocess DP, DDP, DDP2
try:
Expand Down