Remove the deprecated code in `pl.utilities.xla_device` (#16404)

This commit is contained in:
Carlos Mocholí 2023-01-17 18:18:28 +01:00 committed by Luca Antiga
parent 256199ff7c
commit 003937246a
3 changed files with 2 additions and 86 deletions

View File

@ -66,6 +66,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Removed the deprecated code in `pl.utilities.distributed` ([#16390](https://github.com/Lightning-AI/lightning/pull/16390))
- Removed the deprecated code in `pl.utilities.xla_device` ([#16404](https://github.com/Lightning-AI/lightning/pull/16404))
- Mark the `forward_module` argument as required ([#16386](https://github.com/Lightning-AI/lightning/pull/16386))
* Removed the deprecated `pl_module` argument from the distributed module wrappers
* Removed the deprecated `pytorch_lightning.overrides.base.unwrap_lightning_module` function

View File

@ -1,67 +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 multiprocessing import Queue
from typing import Any, Callable
from pytorch_lightning.utilities import rank_zero_deprecation
def inner_f(queue: Queue, func: Callable, *args: Any, **kwargs: Any) -> None: # pragma: no cover
rank_zero_deprecation(
"`pytorch_lightning.utilities.xla_device.inner_f` has been deprecated in v1.8.0 and will be"
" removed in v2.0.0. This class is internal but you can copy over its implementation."
)
from lightning_fabric.accelerators.tpu import _inner_f
return _inner_f(queue, func, *args, **kwargs)
def pl_multi_process(func: Callable) -> Callable:
rank_zero_deprecation(
"`pytorch_lightning.utilities.xla_device.pl_multi_process` has been deprecated in v1.8.0 and will be"
" removed in v2.0.0. This class is internal but you can copy over its implementation."
)
from lightning_fabric.accelerators.tpu import _multi_process
return _multi_process(func)
class XLADeviceUtils:
def __init__(self) -> None:
rank_zero_deprecation(
"`pytorch_lightning.utilities.xla_device.XLADeviceUtils` has been deprecated in v1.8.0 and will be"
" removed in v2.0.0. This class is internal."
)
@staticmethod
def xla_available() -> bool:
rank_zero_deprecation(
"`pytorch_lightning.utilities.xla_device.XLADeviceUtils.xla_available` has been deprecated in v1.8.0 and"
" will be removed in v2.0.0. This method is internal."
)
from pytorch_lightning.accelerators.tpu import _XLA_AVAILABLE
return bool(_XLA_AVAILABLE)
@staticmethod
def tpu_device_exists() -> bool:
rank_zero_deprecation(
"`pytorch_lightning.utilities.xla_device.XLADeviceUtils.tpu_device_exists` has been deprecated in v1.8.0"
" and will be removed in v2.0.0. Please use `pytorch_lightning.accelerators.TPUAccelerator.is_available()`"
" instead."
)
from pytorch_lightning.accelerators.tpu import TPUAccelerator
return TPUAccelerator.is_available()

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test deprecated functionality which will be removed in v2.0.0."""
from unittest import mock
import numpy
import pytest
@ -45,7 +44,6 @@ from pytorch_lightning.utilities.device_parser import (
)
from pytorch_lightning.utilities.optimizer import optimizer_to_device, optimizers_to_device
from pytorch_lightning.utilities.seed import pl_worker_init_function, reset_seed, seed_everything
from pytorch_lightning.utilities.xla_device import inner_f, pl_multi_process, XLADeviceUtils
def test_v1_10_deprecated_on_colab_kaggle_func():
@ -61,23 +59,6 @@ def test_v1_10_deprecated_device_dtype_module_mixin():
MyModule()
def test_v1_10_deprecated_xla_device_utilities():
with pytest.deprecated_call(match="xla_device.inner_f` has been deprecated in v1.8.0"):
inner_f(mock.Mock(), mock.Mock())
with pytest.deprecated_call(match="xla_device.pl_multi_process` has been deprecated in v1.8.0"):
pl_multi_process(mock.Mock)
with pytest.deprecated_call(match="xla_device.XLADeviceUtils` has been deprecated in v1.8.0"):
XLADeviceUtils()
with pytest.deprecated_call(match="xla_device.XLADeviceUtils.xla_available` has been deprecated in v1.8.0"):
XLADeviceUtils.xla_available()
with pytest.deprecated_call(match="xla_device.XLADeviceUtils.tpu_device_exists` has been deprecated in v1.8.0"):
XLADeviceUtils.tpu_device_exists()
def test_v1_10_deprecated_apply_func_utilities():
with pytest.deprecated_call(match="apply_func.apply_to_collection` has been deprecated in v1.8.0"):
apply_to_collection([], dtype=object, function=(lambda x: x))