Skip to content

Commit edff47c

Browse files
committed
Remove <0.6.0 checks
1 parent 1318cdc commit edff47c

File tree

3 files changed

+1
-26
lines changed

3 files changed

+1
-26
lines changed

src/pytorch_lightning/plugins/precision/deepspeed.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
from pytorch_lightning.utilities import GradClipAlgorithmType
2323
from pytorch_lightning.utilities.enums import PrecisionType
2424
from pytorch_lightning.utilities.exceptions import MisconfigurationException
25-
from pytorch_lightning.utilities.imports import _RequirementAvailable
2625
from pytorch_lightning.utilities.model_helpers import is_overridden
2726
from pytorch_lightning.utilities.warnings import WarningCache
2827

29-
_DEEPSPEED_GREATER_EQUAL_0_6 = _RequirementAvailable("deepspeed>=0.6.0")
3028
if TYPE_CHECKING:
3129
if pl.strategies.deepspeed._DEEPSPEED_AVAILABLE:
3230
import deepspeed
@@ -52,12 +50,6 @@ class DeepSpeedPrecisionPlugin(PrecisionPlugin):
5250
"""
5351

5452
def __init__(self, precision: Union[str, int], amp_type: str, amp_level: Optional[str] = None) -> None:
55-
if precision == PrecisionType.BFLOAT and not _DEEPSPEED_GREATER_EQUAL_0_6:
56-
raise MisconfigurationException(
57-
f"`Trainer(strategy='deepspeed', precision={precision!r})` is not supported"
58-
" with `deepspeed < v0.6`. Please upgrade it using `pip install -U deepspeed`."
59-
)
60-
6153
supported_precision = (PrecisionType.HALF, PrecisionType.FLOAT, PrecisionType.BFLOAT, PrecisionType.MIXED)
6254
if precision not in supported_precision:
6355
raise ValueError(

tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from unittest import mock
15-
1614
import pytest
1715

1816
from pytorch_lightning.plugins.precision.deepspeed import DeepSpeedPrecisionPlugin
19-
from pytorch_lightning.utilities.exceptions import MisconfigurationException
2017

2118

2219
def test_invalid_precision_with_deepspeed_precision():
2320
with pytest.raises(ValueError, match="is not supported. `precision` must be one of"):
2421
DeepSpeedPrecisionPlugin(precision=64, amp_type="native")
25-
26-
27-
@mock.patch("pytorch_lightning.plugins.precision.deepspeed._DEEPSPEED_GREATER_EQUAL_0_6", False)
28-
def test_incompatible_bfloat16_raises_error_with_deepspeed_version():
29-
with pytest.raises(MisconfigurationException, match="is not supported with `deepspeed < v0.6`"):
30-
DeepSpeedPrecisionPlugin(precision="bf16", amp_type="native")

tests/tests_pytorch/strategies/test_deepspeed_strategy.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,19 @@
3030
from pytorch_lightning.callbacks import Callback, LearningRateMonitor, ModelCheckpoint
3131
from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset
3232
from pytorch_lightning.plugins import DeepSpeedPrecisionPlugin
33-
from pytorch_lightning.plugins.precision.deepspeed import _DEEPSPEED_GREATER_EQUAL_0_6
3433
from pytorch_lightning.strategies import DeepSpeedStrategy
3534
from pytorch_lightning.strategies.deepspeed import _DEEPSPEED_AVAILABLE, LightningDeepSpeedModule
3635
from pytorch_lightning.utilities.exceptions import MisconfigurationException
37-
from pytorch_lightning.utilities.imports import _RequirementAvailable
3836
from pytorch_lightning.utilities.meta import init_meta_context
3937
from tests_pytorch.helpers.datamodules import ClassifDataModule
4038
from tests_pytorch.helpers.datasets import RandomIterableDataset
4139
from tests_pytorch.helpers.runif import RunIf
4240

4341
if _DEEPSPEED_AVAILABLE:
4442
import deepspeed
43+
from deepspeed.runtime.zero.stage_1_and_2 import DeepSpeedZeroOptimizer
4544
from deepspeed.utils.zero_to_fp32 import convert_zero_checkpoint_to_fp32_state_dict
4645

47-
_DEEPSPEED_GREATER_EQUAL_0_5_9 = _RequirementAvailable("deepspeed>=0.5.9")
48-
if _DEEPSPEED_GREATER_EQUAL_0_5_9:
49-
from deepspeed.runtime.zero.stage_1_and_2 import DeepSpeedZeroOptimizer
50-
else:
51-
from deepspeed.runtime.zero.stage2 import FP16_DeepSpeedZeroOptimizer as DeepSpeedZeroOptimizer
52-
5346

5447
class ModelParallelBoringModel(BoringModel):
5548
def __init__(self):
@@ -1294,7 +1287,6 @@ def training_step(self, *args, **kwargs):
12941287

12951288

12961289
@RunIf(min_cuda_gpus=2, standalone=True, deepspeed=True)
1297-
@pytest.mark.skipif(not _DEEPSPEED_GREATER_EQUAL_0_6, reason="requires deepspeed >= 0.6")
12981290
def test_deepspeed_with_bfloat16_precision(tmpdir):
12991291
"""Test that deepspeed works with bfloat16 precision."""
13001292
model = BoringModel()

0 commit comments

Comments
 (0)