Remove the deprecated code in `pl.utilities.optimizer` (#16439)

This commit is contained in:
Carlos Mocholí 2023-01-19 17:46:28 +01:00 committed by Luca Antiga
parent 0cf0e90e4a
commit da82d490f3
4 changed files with 2 additions and 46 deletions

View File

@ -319,7 +319,6 @@ utilities
finite_checks
memory
model_summary
optimizer
parsing
rank_zero
seed

View File

@ -79,6 +79,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed the deprecated code in `pl.utilities.device_parser` ([#16412](https://github.com/Lightning-AI/lightning/pull/16412))
- Removed the deprecated code in `pl.utilities.optimizer` ([#16439](https://github.com/Lightning-AI/lightning/pull/16439))
- Removed the deprecated code in `pl.utilities.seed` ([#16422](https://github.com/Lightning-AI/lightning/pull/16422))
- Removed the deprecated code in `pl.utilities.cloud_io` ([#16438](https://github.com/Lightning-AI/lightning/pull/16438))

View File

@ -1,35 +0,0 @@
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Any
from lightning_fabric.utilities.optimizer import _optimizer_to_device as new_optimizer_to_device
from lightning_fabric.utilities.optimizer import _optimizers_to_device as new_optimizers_to_device
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation
def optimizers_to_device(*args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.utilities.optimizer.optimizers_to_device` has been deprecated in v1.8.0 and will be"
" removed in v2.0.0. This function is internal but you can copy over its implementation."
)
return new_optimizers_to_device(*args, **kwargs)
def optimizer_to_device(*args: Any, **kwargs: Any) -> None:
rank_zero_deprecation(
"`pytorch_lightning.utilities.optimizer.optimizer_to_device` has been deprecated in v1.8.0 and will be"
" removed in v2.0.0. This function is internal but you can copy over its implementation."
)
return new_optimizer_to_device(*args, **kwargs)

View File

@ -13,12 +13,10 @@
# limitations under the License.
"""Test deprecated functionality which will be removed in v2.0.0."""
import pytest
import torch
from torch.utils.data import DataLoader
from pytorch_lightning.demos.boring_classes import RandomDataset
from pytorch_lightning.utilities.data import has_iterable_dataset, has_len
from pytorch_lightning.utilities.optimizer import optimizer_to_device, optimizers_to_device
def test_v1_10_deprecated_data_utilities():
@ -27,11 +25,3 @@ def test_v1_10_deprecated_data_utilities():
with pytest.deprecated_call(match="data.has_len` has been deprecated in v1.8.0"):
has_len(DataLoader(RandomDataset(2, 4)))
def test_v1_10_deprecated_optimizer_utilities():
with pytest.deprecated_call(match="optimizer.optimizers_to_device` has been deprecated in v1.8.0"):
optimizers_to_device([torch.optim.Adam(torch.nn.Linear(1, 1).parameters())], "cpu")
with pytest.deprecated_call(match="optimizer.optimizer_to_device` has been deprecated in v1.8.0"):
optimizer_to_device(torch.optim.Adam(torch.nn.Linear(1, 1).parameters()), "cpu")