Skip to content

Commit e81115b

Browse files
awaelchlirohitgr7
authored andcommitted
Remove deprecated precision plugin checkpoint hooks (#14833)
* Remove deprecated precision plugin checkpoint hooks * chlog
1 parent 1750e93 commit e81115b

File tree

4 files changed

+4
-57
lines changed

4 files changed

+4
-57
lines changed

src/pytorch_lightning/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
199199

200200
- Removed the deprecated way to set the distributed backend via the environment variable `PL_TORCH_DISTRIBUTED_BACKEND`, in favor of setting the `process_group_backend` in the strategy constructor ([#14693](https://github.com/Lightning-AI/lightning/pull/14693))
201201

202+
202203
- Removed the deprecated device attributes `Trainer.{devices,gpus,num_gpus,ipus,tpu_cores}` in favor of the accelerator-agnostic `Trainer.num_devices` ([#14829](https://github.com/Lightning-AI/lightning/pull/14829))
203204

204205

206+
- Removed the deprecated precision plugin checkpoint hooks `PrecisionPlugin.on_load_checkpoint` and `PrecisionPlugin.on_save_checkpoint` ([#14833](https://github.com/Lightning-AI/lightning/pull/14833))
207+
208+
205209
- Removed the deprecated `Trainer.root_gpu` attribute in favor of `Trainer.strategy.root_device` ([#14829](https://github.com/Lightning-AI/lightning/pull/14829))
206210

207211

src/pytorch_lightning/plugins/precision/precision_plugin.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,3 @@ def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
269269
state_dict: the precision plugin state returned by ``state_dict``.
270270
"""
271271
pass
272-
273-
def on_save_checkpoint(self, checkpoint: Dict[str, Any]) -> None:
274-
"""``PrecisionPlugin.on_save_checkpoint`` was deprecated in v1.6 and will be removed in v1.8.
275-
276-
Use ``state_dict`` instead.
277-
"""
278-
279-
def on_load_checkpoint(self, checkpoint: Dict[str, Any]) -> None:
280-
"""``PrecisionPlugin.on_load_checkpoint`` was deprecated in v1.6 and will be removed in v1.8.
281-
282-
Use ``load_state_dict`` instead.
283-
"""

src/pytorch_lightning/trainer/configuration_validator.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import pytorch_lightning as pl
1515
from lightning_lite.utilities.warnings import PossibleUserWarning
1616
from pytorch_lightning.accelerators.ipu import IPUAccelerator
17-
from pytorch_lightning.plugins.precision.precision_plugin import PrecisionPlugin
1817
from pytorch_lightning.strategies import DataParallelStrategy
1918
from pytorch_lightning.trainer.states import TrainerFn
2019
from pytorch_lightning.utilities.exceptions import MisconfigurationException
@@ -50,8 +49,6 @@ def verify_loop_configurations(trainer: "pl.Trainer") -> None:
5049
_check_deprecated_callback_hooks(trainer)
5150
# TODO: Delete on_epoch_start/on_epoch_end hooks in v1.8
5251
_check_on_epoch_start_end(model)
53-
# TODO: Delete CheckpointHooks off PrecisionPlugin in v1.8
54-
_check_precision_plugin_checkpoint_hooks(trainer)
5552
# TODO: Delete on_pretrain_routine_start/end hooks in v1.8
5653
_check_on_pretrain_routine(model)
5754
# TODO: Delete CheckpointHooks off LightningDataModule in v1.8
@@ -266,19 +263,6 @@ def _check_deprecated_callback_hooks(trainer: "pl.Trainer") -> None:
266263
)
267264

268265

269-
def _check_precision_plugin_checkpoint_hooks(trainer: "pl.Trainer") -> None:
270-
if is_overridden(method_name="on_save_checkpoint", instance=trainer.precision_plugin, parent=PrecisionPlugin):
271-
rank_zero_deprecation(
272-
"`PrecisionPlugin.on_save_checkpoint` was deprecated in"
273-
" v1.6 and will be removed in v1.8. Use `state_dict` instead."
274-
)
275-
if is_overridden(method_name="on_load_checkpoint", instance=trainer.precision_plugin, parent=PrecisionPlugin):
276-
rank_zero_deprecation(
277-
"`PrecisionPlugin.on_load_checkpoint` was deprecated in"
278-
" v1.6 and will be removed in v1.8. Use `load_state_dict` instead."
279-
)
280-
281-
282266
def _check_datamodule_checkpoint_hooks(trainer: "pl.Trainer") -> None:
283267
if is_overridden(method_name="on_save_checkpoint", instance=trainer.datamodule):
284268
rank_zero_deprecation(

tests/tests_pytorch/deprecated_api/test_remove_1-8.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from pytorch_lightning.callbacks import ModelCheckpoint
2424
from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel
2525
from pytorch_lightning.loggers import CSVLogger, Logger
26-
from pytorch_lightning.plugins.precision.precision_plugin import PrecisionPlugin
2726
from pytorch_lightning.profilers import AdvancedProfiler, SimpleProfiler
2827
from pytorch_lightning.strategies.ipu import LightningIPUModule
2928
from pytorch_lightning.trainer.configuration_validator import _check_datamodule_checkpoint_hooks
@@ -434,34 +433,6 @@ def _get_python_cprofile_total_duration(profile):
434433
np.testing.assert_allclose(recorded_total_duration, expected_total_duration, rtol=0.2)
435434

436435

437-
def test_v1_8_0_precision_plugin_checkpoint_hooks(tmpdir):
438-
class PrecisionPluginSaveHook(PrecisionPlugin):
439-
def on_save_checkpoint(self, checkpoint):
440-
print("override on_save_checkpoint")
441-
442-
class PrecisionPluginLoadHook(PrecisionPlugin):
443-
def on_load_checkpoint(self, checkpoint):
444-
print("override on_load_checkpoint")
445-
446-
model = BoringModel()
447-
448-
precplugin_save = PrecisionPluginSaveHook()
449-
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, plugins=[precplugin_save])
450-
with pytest.deprecated_call(
451-
match="`PrecisionPlugin.on_save_checkpoint` was deprecated in"
452-
" v1.6 and will be removed in v1.8. Use `state_dict` instead."
453-
):
454-
trainer.fit(model)
455-
456-
precplugin_load = PrecisionPluginLoadHook()
457-
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, plugins=[precplugin_load])
458-
with pytest.deprecated_call(
459-
match="`PrecisionPlugin.on_load_checkpoint` was deprecated in"
460-
" v1.6 and will be removed in v1.8. Use `load_state_dict` instead."
461-
):
462-
trainer.fit(model)
463-
464-
465436
def test_v1_8_0_datamodule_checkpointhooks():
466437
class CustomBoringDataModuleSave(BoringDataModule):
467438
def on_save_checkpoint(self, checkpoint):

0 commit comments

Comments
 (0)