From 6f00ba21c211bf6b9491482fc379fff9f0f4cdaa Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Wed, 3 Nov 2021 18:51:46 -0600 Subject: [PATCH] Remove deprecated `loaded_optimizer_states_dict` property (#10346) Co-authored-by: Carlos Mocholi --- CHANGELOG.md | 2 +- pytorch_lightning/core/lightning.py | 22 ---------------------- tests/deprecated_api/test_remove_1-6.py | 17 ----------------- 3 files changed, 1 insertion(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20bbde54b6..eb0981fd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed deprecated `TrainerModelHooksMixin.is_function_implemented` and `TrainerModelHooksMixin.has_arg` ([#10322](https://github.com/PyTorchLightning/pytorch-lightning/pull/10322)) -- +- Removed deprecated `LightningModule.loaded_optimizer_states_dict` property ([#10346](https://github.com/PyTorchLightning/pytorch-lightning/pull/10346)) - diff --git a/pytorch_lightning/core/lightning.py b/pytorch_lightning/core/lightning.py index 675b2e8a91..2f359f00ab 100644 --- a/pytorch_lightning/core/lightning.py +++ b/pytorch_lightning/core/lightning.py @@ -82,7 +82,6 @@ class LightningModule( "model_size", "automatic_optimization", "truncated_bptt_steps", - "loaded_optimizer_states_dict", ] + DeviceDtypeModuleMixin.__jit_unused_properties__ + HyperparametersMixin.__jit_unused_properties__ @@ -119,9 +118,6 @@ class LightningModule( self._register_sharded_tensor_state_dict_hooks_if_available() - # deprecated, will be removed in 1.6 - self._loaded_optimizer_states_dict = {} - @overload def optimizers(self, use_pl_optimizer: Literal[True] = True) -> Union[LightningOptimizer, List[LightningOptimizer]]: ... @@ -225,24 +221,6 @@ class LightningModule( """The index of the current process within a single node.""" return self.trainer.local_rank if self.trainer else 0 - @property - def loaded_optimizer_states_dict(self) -> dict: - warning_cache.deprecation( - "The `LightningModule.loaded_optimizer_states_dict` property is deprecated in v1.4" - " and will be removed in v1.6.", - stacklevel=6, - ) - return self._loaded_optimizer_states_dict - - @loaded_optimizer_states_dict.setter - def loaded_optimizer_states_dict(self, val: dict) -> None: - warning_cache.deprecation( - "The `LightningModule.loaded_optimizer_states_dict` property is deprecated in v1.4" - " and will be removed in v1.6.", - stacklevel=6, - ) - self._loaded_optimizer_states_dict = val - @property def on_gpu(self): """Returns ``True`` if this model is currently located on a GPU. diff --git a/tests/deprecated_api/test_remove_1-6.py b/tests/deprecated_api/test_remove_1-6.py index 9faf80435d..a0a1c93ee7 100644 --- a/tests/deprecated_api/test_remove_1-6.py +++ b/tests/deprecated_api/test_remove_1-6.py @@ -273,23 +273,6 @@ def test_v1_6_0_ddp_plugin_task_idx(): _ = plugin.task_idx -def test_v1_6_0_lightning_module_loaded_optimizer_states_dict(): - from pytorch_lightning.core.lightning import warning_cache - - model = BoringModel() - _ = model.loaded_optimizer_states_dict - assert any( - "The `LightningModule.loaded_optimizer_states_dict` property is deprecated in v1.4" in w for w in warning_cache - ) - warning_cache.clear() - - model.loaded_optimizer_states_dict = {} - assert any( - "The `LightningModule.loaded_optimizer_states_dict` property is deprecated in v1.4" in w for w in warning_cache - ) - warning_cache.clear() - - def test_v1_6_0_deprecated_model_summary_mode(tmpdir): model = BoringModel() with pytest.deprecated_call(match="Argument `mode` in `ModelSummary` is deprecated in v1.4"):