Remove deprecated `loaded_optimizer_states_dict` property (#10346)
Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
This commit is contained in:
parent
ba23d91320
commit
6f00ba21c2
|
@ -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))
|
||||
|
||||
|
||||
-
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"):
|
||||
|
|
Loading…
Reference in New Issue