Skip to content

Commit fcea720

Browse files
authored
remove deprecated model_size from LightningModule (#12641)
1 parent 7dafc2e commit fcea720

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6969
- Removed the deprecated `summarize` method from the `LightningModule` ([#12559](https://github.com/PyTorchLightning/pytorch-lightning/pull/12559))
7070

7171

72+
- Removed the deprecated `model_size` property from the `LightningModule` class ([#12641](https://github.com/PyTorchLightning/pytorch-lightning/pull/12641))
73+
74+
7275
- Removed the deprecated `stochastic_weight_avg` argument from the `Trainer` constructor ([#12535](https://github.com/PyTorchLightning/pytorch-lightning/pull/12535))
7376

7477

docs/source/common/lightning_module.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,11 +1112,6 @@ Set and access example_input_array, which basically represents a single batch.
11121112
# generate some images using the example_input_array
11131113
gen_images = self.generator(self.example_input_array)
11141114
1115-
model_size
1116-
~~~~~~~~~~
1117-
1118-
Get the model file size (in megabytes) using ``self.model_size`` inside LightningModule.
1119-
11201115
truncated_bptt_steps
11211116
~~~~~~~~~~~~~~~~~~~~
11221117

pytorch_lightning/core/lightning.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from pytorch_lightning.utilities.cloud_io import get_filesystem
4646
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp
4747
from pytorch_lightning.utilities.exceptions import MisconfigurationException
48-
from pytorch_lightning.utilities.memory import get_model_size_mb
4948
from pytorch_lightning.utilities.parsing import collect_init_args
5049
from pytorch_lightning.utilities.rank_zero import rank_zero_debug, rank_zero_deprecation, rank_zero_warn
5150
from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature
@@ -77,7 +76,6 @@ class LightningModule(
7776
"local_rank",
7877
"logger",
7978
"loggers",
80-
"model_size",
8179
"automatic_optimization",
8280
"truncated_bptt_steps",
8381
"use_amp",
@@ -1928,21 +1926,6 @@ def to_torchscript(
19281926

19291927
return torchscript_module
19301928

1931-
@property
1932-
def model_size(self) -> float:
1933-
"""Returns the model size in MegaBytes (MB)
1934-
1935-
Note:
1936-
This property will not return correct value for Deepspeed (stage 3) and fully-sharded training.
1937-
"""
1938-
if not self._running_torchscript: # remove with the deprecation removal
1939-
rank_zero_deprecation(
1940-
"The `LightningModule.model_size` property was deprecated in v1.5 and will be removed in v1.7."
1941-
" Please use the `pytorch_lightning.utilities.memory.get_model_size_mb`.",
1942-
stacklevel=5,
1943-
)
1944-
return get_model_size_mb(self)
1945-
19461929
@property
19471930
def use_amp(self) -> bool:
19481931
r"""

tests/deprecated_api/test_remove_1-7.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ def test_v1_7_0_moved_get_memory_profile_and_get_gpu_memory_map(tmpdir):
5757
from pytorch_lightning.core.memory import get_gpu_memory_map, get_memory_profile # noqa: F401
5858

5959

60-
def test_v1_7_0_deprecated_model_size():
61-
model = BoringModel()
62-
with pytest.deprecated_call(
63-
match="LightningModule.model_size` property was deprecated in v1.5 and will be removed in v1.7"
64-
):
65-
_ = model.model_size
66-
67-
6860
def test_v1_7_0_datamodule_transform_properties(tmpdir):
6961
dm = MNISTDataModule()
7062
with pytest.deprecated_call(match=r"DataModule property `val_transforms` was deprecated in v1.5"):

0 commit comments

Comments
 (0)