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 deprecated model_size from LightningModule #12641

Merged
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 @@ -63,6 +63,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed the deprecated `summarize` method from the `LightningModule` ([#12559](https://github.com/PyTorchLightning/pytorch-lightning/pull/12559))


- Removed the deprecated `model_size` property from the `LightningModule` class ([#12641](https://github.com/PyTorchLightning/pytorch-lightning/pull/12641))


- Removed the deprecated `stochastic_weight_avg` argument from the `Trainer` constructor ([#12535](https://github.com/PyTorchLightning/pytorch-lightning/pull/12535))


Expand Down
5 changes: 0 additions & 5 deletions docs/source/common/lightning_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,6 @@ Set and access example_input_array, which basically represents a single batch.
# generate some images using the example_input_array
gen_images = self.generator(self.example_input_array)

model_size
~~~~~~~~~~

Get the model file size (in megabytes) using ``self.model_size`` inside LightningModule.

truncated_bptt_steps
~~~~~~~~~~~~~~~~~~~~

Expand Down
17 changes: 0 additions & 17 deletions pytorch_lightning/core/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from pytorch_lightning.utilities.cloud_io import get_filesystem
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.memory import get_model_size_mb
from pytorch_lightning.utilities.parsing import collect_init_args
from pytorch_lightning.utilities.rank_zero import rank_zero_debug, rank_zero_deprecation, rank_zero_warn
from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature
Expand Down Expand Up @@ -77,7 +76,6 @@ class LightningModule(
"local_rank",
"logger",
"loggers",
"model_size",
"automatic_optimization",
"truncated_bptt_steps",
"use_amp",
Expand Down Expand Up @@ -1928,21 +1926,6 @@ def to_torchscript(

return torchscript_module

@property
def model_size(self) -> float:
"""Returns the model size in MegaBytes (MB)

Note:
This property will not return correct value for Deepspeed (stage 3) and fully-sharded training.
"""
if not self._running_torchscript: # remove with the deprecation removal
rank_zero_deprecation(
"The `LightningModule.model_size` property was deprecated in v1.5 and will be removed in v1.7."
" Please use the `pytorch_lightning.utilities.memory.get_model_size_mb`.",
stacklevel=5,
)
return get_model_size_mb(self)

@property
def use_amp(self) -> bool:
r"""
Expand Down
8 changes: 0 additions & 8 deletions tests/deprecated_api/test_remove_1-7.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ def test_v1_7_0_moved_get_memory_profile_and_get_gpu_memory_map(tmpdir):
from pytorch_lightning.core.memory import get_gpu_memory_map, get_memory_profile # noqa: F401


def test_v1_7_0_deprecated_model_size():
model = BoringModel()
with pytest.deprecated_call(
match="LightningModule.model_size` property was deprecated in v1.5 and will be removed in v1.7"
):
_ = model.model_size


def test_v1_7_0_datamodule_transform_properties(tmpdir):
dm = MNISTDataModule()
with pytest.deprecated_call(match=r"DataModule property `train_transforms` was deprecated in v1.5"):
Expand Down