From 7b44f0e3447c4371e7573ba03e954dca47311287 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Mon, 11 Jul 2022 11:35:13 +0900 Subject: [PATCH 1/4] Remove max_steps=None --- src/pytorch_lightning/loops/epoch/training_epoch_loop.py | 8 +------- src/pytorch_lightning/loops/fit_loop.py | 8 +------- tests/tests_pytorch/deprecated_api/test_remove_1-7.py | 9 --------- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/pytorch_lightning/loops/epoch/training_epoch_loop.py b/src/pytorch_lightning/loops/epoch/training_epoch_loop.py index 04e9d070a6d8e..e0eb53903f818 100644 --- a/src/pytorch_lightning/loops/epoch/training_epoch_loop.py +++ b/src/pytorch_lightning/loops/epoch/training_epoch_loop.py @@ -48,13 +48,7 @@ class TrainingEpochLoop(loops.Loop[_OUTPUTS_TYPE]): def __init__(self, min_steps: Optional[int] = None, max_steps: int = -1) -> None: super().__init__() - if max_steps is None: - rank_zero_deprecation( - "Setting `max_steps = None` is deprecated in v1.5 and will no longer be supported in v1.7." - " Use `max_steps = -1` instead." - ) - max_steps = -1 - elif max_steps < -1: + if max_steps < -1: raise MisconfigurationException( f"`max_steps` must be a non-negative integer or -1 (infinite steps). You passed in {max_steps}." ) diff --git a/src/pytorch_lightning/loops/fit_loop.py b/src/pytorch_lightning/loops/fit_loop.py index 0771a4a71de9f..282ce4cd67d81 100644 --- a/src/pytorch_lightning/loops/fit_loop.py +++ b/src/pytorch_lightning/loops/fit_loop.py @@ -104,13 +104,7 @@ def max_steps(self) -> int: def max_steps(self, value: int) -> None: """Sets the maximum number of steps (forwards to epoch_loop)""" # TODO(@awaelchli): This setter is required by debugging connector (fast dev run), should be avoided - if value is None: - rank_zero_deprecation( - "Setting `max_steps = None` is deprecated in v1.5 and will no longer be supported in v1.7." - " Use `max_steps = -1` instead." - ) - value = -1 - elif value < -1: + if value < -1: raise MisconfigurationException( f"`max_steps` must be a non-negative integer or -1 (infinite steps). You passed in {value}." ) diff --git a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py index 2ae305d2c06b7..8c1b98cf3c697 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-7.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-7.py @@ -91,15 +91,6 @@ def test_v1_7_0_deprecated_slurm_job_id(): trainer.slurm_job_id -def test_v1_7_0_deprecated_max_steps_none(tmpdir): - with pytest.deprecated_call(match="`max_steps = None` is deprecated in v1.5"): - _ = Trainer(max_steps=None) - - trainer = Trainer() - with pytest.deprecated_call(match="`max_steps = None` is deprecated in v1.5"): - trainer.fit_loop.max_steps = None - - @pytest.mark.parametrize( "cls", [ From a1c7f7d92396476f0e9059ab6d52a04b29f3b0c9 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Mon, 11 Jul 2022 11:49:31 +0900 Subject: [PATCH 2/4] Update changelog --- src/pytorch_lightning/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 8d6fd64a2cb47..53ae78b4d119c 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -252,6 +252,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Removed the deprecated `test_transforms` argument from the `LightningDataModule` constructor ([#12773](https://github.com/PyTorchLightning/pytorch-lightning/pull/12773)) +- Removed deprecated `Trainer(max_steps=None)` ([#13591](https://github.com/Lightning-AI/lightning/pull/13591)) + + - Removed deprecated `dataloader_idx` argument from `on_train_batch_start/end` hooks `Callback` and `LightningModule` ([#12769](https://github.com/PyTorchLightning/pytorch-lightning/pull/12769), [#12977](https://github.com/PyTorchLightning/pytorch-lightning/pull/12977)) From 3145394f87f6a0a122effd6cc46a8233a486b4c1 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Mon, 11 Jul 2022 11:49:43 +0900 Subject: [PATCH 3/4] Update docs --- docs/source-pytorch/common/trainer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source-pytorch/common/trainer.rst b/docs/source-pytorch/common/trainer.rst index 3e3734ceb35e3..d2fd899cf0eff 100644 --- a/docs/source-pytorch/common/trainer.rst +++ b/docs/source-pytorch/common/trainer.rst @@ -954,7 +954,7 @@ Training will stop if max_steps or max_epochs have reached (earliest). .. testcode:: # Default (disabled) - trainer = Trainer(max_steps=None) + trainer = Trainer(max_steps=-1) # Stop after 100 steps trainer = Trainer(max_steps=100) From 6a4bb4fc1e40dd562a636c11d8314d9c13b4ae24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 12 Jul 2022 17:04:25 +0200 Subject: [PATCH 4/4] Unused import --- src/pytorch_lightning/loops/fit_loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/loops/fit_loop.py b/src/pytorch_lightning/loops/fit_loop.py index 282ce4cd67d81..ab63b0e6df3be 100644 --- a/src/pytorch_lightning/loops/fit_loop.py +++ b/src/pytorch_lightning/loops/fit_loop.py @@ -33,7 +33,7 @@ InterBatchParallelDataFetcher, ) from pytorch_lightning.utilities.model_helpers import is_overridden -from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation, rank_zero_warn +from pytorch_lightning.utilities.rank_zero import rank_zero_warn from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature log = logging.getLogger(__name__)