From a5d0aaa847e5ab096c5c67b16270aaabceb5af4c Mon Sep 17 00:00:00 2001 From: Logan Adams <114770087+loadams@users.noreply.github.com> Date: Wed, 10 Apr 2024 08:39:24 -0700 Subject: [PATCH] Cleanup required_torch_version code and references. (#5370) - Move `required_torch_version` check from deepspeed.runtime.utils to deepspeed.utils.torch (newly created). - Remove unused duplicate definition from `tests/unit/util.py`. - Update all references to this function. - Switch checks in `deepspeed/runtime/pipe/p2p.py` to use this function. - Switch checks in `deepspeed/comm/torch.py` to use this function. --------- Co-authored-by: Lev Kurilenko <113481193+lekurile@users.noreply.github.com> --- deepspeed/comm/torch.py | 28 +++---------------- deepspeed/elasticity/utils.py | 2 +- deepspeed/runtime/comm/nccl.py | 2 +- deepspeed/runtime/fp16/fused_optimizer.py | 3 +- deepspeed/runtime/fp16/onebit/adam.py | 2 +- deepspeed/runtime/fp16/onebit/lamb.py | 2 +- deepspeed/runtime/fp16/onebit/zoadam.py | 2 +- deepspeed/runtime/fp16/unfused_optimizer.py | 3 +- deepspeed/runtime/pipe/p2p.py | 8 ++---- deepspeed/runtime/utils.py | 15 ---------- deepspeed/utils/torch.py | 22 +++++++++++++++ tests/unit/alexnet_model.py | 2 +- tests/unit/checkpoint/test_mics_optimizer.py | 2 +- tests/unit/checkpoint/test_moe_checkpoint.py | 2 +- .../checkpoint/test_universal_checkpoint.py | 2 +- tests/unit/checkpoint/test_zero_optimizer.py | 2 +- tests/unit/compression/test_compression.py | 2 +- .../quantization/test_intX_quantization.py | 2 +- .../test_configurable_parallel_mp.py | 2 +- .../test_configurable_parallel_pp.py | 2 +- tests/unit/moe/test_moe.py | 2 +- tests/unit/moe/test_moe_tp.py | 2 +- .../flops_profiler/test_flops_profiler.py | 2 +- .../runtime/compile/test_compile_wrapper.py | 2 +- .../unit/runtime/compile/test_compile_zero.py | 2 +- .../unit/runtime/compile/test_load_config.py | 2 +- .../half_precision/onebit/test_onebit.py | 2 +- .../unit/runtime/half_precision/test_fp16.py | 2 +- tests/unit/runtime/test_ds_initialize.py | 3 +- tests/unit/util.py | 15 ---------- 30 files changed, 56 insertions(+), 85 deletions(-) create mode 100644 deepspeed/utils/torch.py diff --git a/deepspeed/comm/torch.py b/deepspeed/comm/torch.py index d96c63d84e60..35c31f9fe2ec 100644 --- a/deepspeed/comm/torch.py +++ b/deepspeed/comm/torch.py @@ -9,6 +9,7 @@ from .backend import * from .comm import * from ..runtime import compiler +from deepspeed.utils.torch import required_torch_version import os DS_COMM_ALL_GATHER_OFF = False @@ -18,40 +19,19 @@ DS_COMM_REDUCE_OFF = False -def is_torch_ver_eq_2_0(): - TORCH_MAJOR, TORCH_MINOR = map(int, torch.__version__.split('.')[:2]) - if TORCH_MAJOR == 2 and TORCH_MINOR == 0: - return True - return False - - -def is_torch_ver_ge_2_1(): - TORCH_MAJOR, TORCH_MINOR = map(int, torch.__version__.split('.')[:2]) - if TORCH_MAJOR >= 2 and TORCH_MINOR >= 1: - return True - return False - - -def torch_ver_ge_1_13(): - TORCH_MAJOR, TORCH_MINOR = map(int, torch.__version__.split('.')[:2]) - if TORCH_MAJOR >= 1 and TORCH_MINOR >= 13: - return True - return False - - def has_coalescing_manager(): has_c10d = hasattr(torch.distributed, 'distributed_c10d') return has_c10d and hasattr(torch.distributed.distributed_c10d, '_coalescing_manager') def has_all_reduce_coalesced(): - return hasattr(torch.distributed, "all_reduce_coalesced") and torch_ver_ge_1_13() + return hasattr(torch.distributed, "all_reduce_coalesced") and required_torch_version(min_version=1.13) def get_coalescing_manager(group, device, reqs, async_op): - if is_torch_ver_eq_2_0(): + if required_torch_version(min_version=2.0, max_version=2.0): return torch.distributed.distributed_c10d._coalescing_manager(group, device=device, reqs=reqs) - elif is_torch_ver_ge_2_1(): + elif required_torch_version(min_version=2.1): return torch.distributed.distributed_c10d._coalescing_manager(group, device=device, async_ops=async_op) else: return torch.distributed.distributed_c10d._coalescing_manager(group, reqs) diff --git a/deepspeed/elasticity/utils.py b/deepspeed/elasticity/utils.py index 848ea8646449..78ae0352cf6e 100644 --- a/deepspeed/elasticity/utils.py +++ b/deepspeed/elasticity/utils.py @@ -3,7 +3,7 @@ # DeepSpeed Team -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version def is_torch_elastic_compatible(): diff --git a/deepspeed/runtime/comm/nccl.py b/deepspeed/runtime/comm/nccl.py index 231f841ae8b7..a57b7519a295 100644 --- a/deepspeed/runtime/comm/nccl.py +++ b/deepspeed/runtime/comm/nccl.py @@ -9,7 +9,7 @@ import numpy as np from deepspeed.runtime.compression.cupy import CupyBackend -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator diff --git a/deepspeed/runtime/fp16/fused_optimizer.py b/deepspeed/runtime/fp16/fused_optimizer.py index 9ed250252e17..af8050c4646a 100755 --- a/deepspeed/runtime/fp16/fused_optimizer.py +++ b/deepspeed/runtime/fp16/fused_optimizer.py @@ -11,9 +11,10 @@ from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors from deepspeed.runtime.base_optimizer import DeepSpeedOptimizer -from deepspeed.runtime.utils import get_global_norm, get_grad_norm, CheckOverflow, get_weight_norm, required_torch_version, get_norm_with_moe_layers +from deepspeed.runtime.utils import get_global_norm, get_grad_norm, CheckOverflow, get_weight_norm, get_norm_with_moe_layers from deepspeed.runtime.fp16.loss_scaler import INITIAL_LOSS_SCALE, SCALE_WINDOW, MIN_LOSS_SCALE from deepspeed.utils import logger, log_dist +from deepspeed.utils.torch import required_torch_version from deepspeed.checkpoint.constants import OPTIMIZER_STATE_DICT, CLIP_GRAD from deepspeed.accelerator import get_accelerator from deepspeed.moe.utils import is_moe_param_group diff --git a/deepspeed/runtime/fp16/onebit/adam.py b/deepspeed/runtime/fp16/onebit/adam.py index ae3e5f573850..f8a50393ac5d 100644 --- a/deepspeed/runtime/fp16/onebit/adam.py +++ b/deepspeed/runtime/fp16/onebit/adam.py @@ -7,7 +7,7 @@ import torch import numpy as np from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed import comm as dist diff --git a/deepspeed/runtime/fp16/onebit/lamb.py b/deepspeed/runtime/fp16/onebit/lamb.py index 9cd2e0f25648..0f70782fd3ff 100644 --- a/deepspeed/runtime/fp16/onebit/lamb.py +++ b/deepspeed/runtime/fp16/onebit/lamb.py @@ -7,7 +7,7 @@ import torch import numpy as np from deepspeed import comm as dist -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors from deepspeed.accelerator import get_accelerator diff --git a/deepspeed/runtime/fp16/onebit/zoadam.py b/deepspeed/runtime/fp16/onebit/zoadam.py index 9ef671e7e3b7..bd75ccd4f7a0 100644 --- a/deepspeed/runtime/fp16/onebit/zoadam.py +++ b/deepspeed/runtime/fp16/onebit/zoadam.py @@ -7,7 +7,7 @@ import torch import numpy as np from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed import comm as dist diff --git a/deepspeed/runtime/fp16/unfused_optimizer.py b/deepspeed/runtime/fp16/unfused_optimizer.py index a7fd1910d7b2..530355f846e2 100755 --- a/deepspeed/runtime/fp16/unfused_optimizer.py +++ b/deepspeed/runtime/fp16/unfused_optimizer.py @@ -12,9 +12,10 @@ from torch._utils import _flatten_dense_tensors from deepspeed.runtime.base_optimizer import DeepSpeedOptimizer -from deepspeed.runtime.utils import get_global_norm, CheckOverflow, get_weight_norm, required_torch_version +from deepspeed.runtime.utils import get_global_norm, CheckOverflow, get_weight_norm from deepspeed.runtime.fp16.loss_scaler import INITIAL_LOSS_SCALE, SCALE_WINDOW, MIN_LOSS_SCALE from deepspeed.utils import logger +from deepspeed.utils.torch import required_torch_version from deepspeed.checkpoint.constants import OPTIMIZER_STATE_DICT from deepspeed.accelerator import get_accelerator from deepspeed import comm as dist diff --git a/deepspeed/runtime/pipe/p2p.py b/deepspeed/runtime/pipe/p2p.py index 31b9a14bf0f4..2b12a9573c4b 100644 --- a/deepspeed/runtime/pipe/p2p.py +++ b/deepspeed/runtime/pipe/p2p.py @@ -9,9 +9,7 @@ import torch from deepspeed import comm as dist -# To query whether we have send/recv support -from packaging.version import Version -from deepspeed.git_version_info import torch_info +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator _groups = None @@ -21,9 +19,7 @@ def can_send_recv() -> bool: - torch_version = Version(torch_info['version']) - sendrecv_min = Version('1.8') - return torch_version >= sendrecv_min + return required_torch_version(min_version=1.8) #initializes adjacent process groups diff --git a/deepspeed/runtime/utils.py b/deepspeed/runtime/utils.py index 9d561f7271eb..c55f8a0e2995 100755 --- a/deepspeed/runtime/utils.py +++ b/deepspeed/runtime/utils.py @@ -14,7 +14,6 @@ import psutil import gc from math import sqrt -from packaging import version as pkg_version import torch from deepspeed import comm as dist @@ -1036,20 +1035,6 @@ def get_inactive_params(param_list): param.ds_status == ZeroParamStatus.NOT_AVAILABLE)] -def required_torch_version(min_version=None, max_version=None): - assert min_version or max_version, "Must provide a min_version or max_version argument" - - torch_version = pkg_version.parse(torch.__version__) - - if min_version and pkg_version.parse(str(min_version)) > torch_version: - return False - - if max_version and pkg_version.parse(str(max_version)) < torch_version: - return False - - return True - - def get_norm_with_moe_layers(non_expert_norm, mpu, expert_tensors, norm_type=2): """ Compute the global norm with MoE experts diff --git a/deepspeed/utils/torch.py b/deepspeed/utils/torch.py new file mode 100644 index 000000000000..eb22d3561035 --- /dev/null +++ b/deepspeed/utils/torch.py @@ -0,0 +1,22 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 + +# DeepSpeed Team + +from packaging import version as pkg_version + +import torch + + +def required_torch_version(min_version=None, max_version=None): + assert min_version or max_version, "Must provide a min_version or max_version argument" + + torch_version = pkg_version.parse(torch.__version__) + + if min_version and pkg_version.parse(str(min_version)) > torch_version: + return False + + if max_version and pkg_version.parse(str(max_version)) < torch_version: + return False + + return True diff --git a/tests/unit/alexnet_model.py b/tests/unit/alexnet_model.py index cf533063d6ec..25256d376eeb 100644 --- a/tests/unit/alexnet_model.py +++ b/tests/unit/alexnet_model.py @@ -11,7 +11,7 @@ import deepspeed import deepspeed.comm as dist import deepspeed.runtime.utils as ds_utils -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator from deepspeed.runtime.pipe.module import PipelineModule, LayerSpec diff --git a/tests/unit/checkpoint/test_mics_optimizer.py b/tests/unit/checkpoint/test_mics_optimizer.py index 3f853cd5c13a..9e56bf3446fa 100644 --- a/tests/unit/checkpoint/test_mics_optimizer.py +++ b/tests/unit/checkpoint/test_mics_optimizer.py @@ -8,7 +8,7 @@ import deepspeed -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest from unit.simple_model import * from unit.checkpoint.common import * diff --git a/tests/unit/checkpoint/test_moe_checkpoint.py b/tests/unit/checkpoint/test_moe_checkpoint.py index 36efe2a69002..89878b5d8fa9 100644 --- a/tests/unit/checkpoint/test_moe_checkpoint.py +++ b/tests/unit/checkpoint/test_moe_checkpoint.py @@ -4,7 +4,7 @@ # DeepSpeed Team from deepspeed.moe.utils import split_params_into_different_moe_groups_for_optimizer -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest from unit.simple_model import * diff --git a/tests/unit/checkpoint/test_universal_checkpoint.py b/tests/unit/checkpoint/test_universal_checkpoint.py index 7adfe8410b55..e0c4f4745043 100644 --- a/tests/unit/checkpoint/test_universal_checkpoint.py +++ b/tests/unit/checkpoint/test_universal_checkpoint.py @@ -7,7 +7,7 @@ from types import SimpleNamespace from torch.utils._pytree import tree_map -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.checkpoint import UNIVERSAL_CHECKPOINT_INFO from deepspeed.checkpoint.ds_to_universal import main as convert_to_universal diff --git a/tests/unit/checkpoint/test_zero_optimizer.py b/tests/unit/checkpoint/test_zero_optimizer.py index 2312425c8aed..84b4eca6e2ca 100644 --- a/tests/unit/checkpoint/test_zero_optimizer.py +++ b/tests/unit/checkpoint/test_zero_optimizer.py @@ -8,7 +8,7 @@ from deepspeed.ops.op_builder import CPUAdamBuilder from deepspeed.checkpoint.utils import clone_tensors_for_torch_save, get_model_ckpt_name_for_rank from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest, DistributedFixture from unit.simple_model import * diff --git a/tests/unit/compression/test_compression.py b/tests/unit/compression/test_compression.py index c6e5031349cb..1802c09f33b5 100644 --- a/tests/unit/compression/test_compression.py +++ b/tests/unit/compression/test_compression.py @@ -14,7 +14,7 @@ from deepspeed.compression.basic_layer import LinearLayer_Compress, ColumnParallelLinear_Compress, RowParallelLinear_Compress from deepspeed.compression.helper import convert_conv1d_to_linear from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest pytestmark = pytest.mark.skipif(not required_torch_version(min_version=1.5), diff --git a/tests/unit/inference/quantization/test_intX_quantization.py b/tests/unit/inference/quantization/test_intX_quantization.py index fd6a8e5ad2e1..77b51fcd5814 100644 --- a/tests/unit/inference/quantization/test_intX_quantization.py +++ b/tests/unit/inference/quantization/test_intX_quantization.py @@ -11,7 +11,7 @@ from deepspeed.inference.quantization.quantization import _init_group_wise_weight_quantization from deepspeed.inference.quantization.utils import Quantizer, DeQuantizer from deepspeed.inference.quantization.layers import QuantizedLinear -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from transformers.models.opt.modeling_opt import OPTDecoderLayer from transformers import AutoConfig, OPTConfig, AutoModel import pytest diff --git a/tests/unit/model_parallelism/test_configurable_parallel_mp.py b/tests/unit/model_parallelism/test_configurable_parallel_mp.py index 824ecea5f144..cca1ef3584ad 100644 --- a/tests/unit/model_parallelism/test_configurable_parallel_mp.py +++ b/tests/unit/model_parallelism/test_configurable_parallel_mp.py @@ -13,7 +13,7 @@ from deepspeed.accelerator import get_accelerator from unit.common import DistributedTest, DistributedFixture from unit.megatron_model import get_gpt2_model, get_megatron_version -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version pytestmark = pytest.mark.skipif(not required_torch_version(min_version=1.5, max_version=1.13), reason='Megatron-LM package requires Pytorch version >=1.5 and <=1.13') diff --git a/tests/unit/model_parallelism/test_configurable_parallel_pp.py b/tests/unit/model_parallelism/test_configurable_parallel_pp.py index b500b9d857a5..e50fd18577b1 100644 --- a/tests/unit/model_parallelism/test_configurable_parallel_pp.py +++ b/tests/unit/model_parallelism/test_configurable_parallel_pp.py @@ -15,7 +15,7 @@ from unit.megatron_model import MockGPT2ModelPipe as GPT2ModelPipe from deepspeed.utils import RepeatingLoader from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version pytestmark = pytest.mark.skipif(not required_torch_version(min_version=1.5, max_version=1.13), reason='Megatron-LM package requires Pytorch version >=1.5 and <=1.13') diff --git a/tests/unit/moe/test_moe.py b/tests/unit/moe/test_moe.py index 0ec45933ff66..d39f9fe3d651 100644 --- a/tests/unit/moe/test_moe.py +++ b/tests/unit/moe/test_moe.py @@ -13,7 +13,7 @@ from deepspeed import get_accelerator from deepspeed.moe.sharded_moe import top1gating from deepspeed.moe.utils import split_params_into_different_moe_groups_for_optimizer, is_moe_param -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version @pytest.mark.parametrize("zero_stage", [0, 1, 2]) diff --git a/tests/unit/moe/test_moe_tp.py b/tests/unit/moe/test_moe_tp.py index 0069c674690c..eb4668015c01 100644 --- a/tests/unit/moe/test_moe_tp.py +++ b/tests/unit/moe/test_moe_tp.py @@ -7,7 +7,7 @@ import deepspeed import pytest from unit.common import DistributedTest -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.moe.layer import MoE diff --git a/tests/unit/profiling/flops_profiler/test_flops_profiler.py b/tests/unit/profiling/flops_profiler/test_flops_profiler.py index bbcb01b489f4..c72deecf287f 100644 --- a/tests/unit/profiling/flops_profiler/test_flops_profiler.py +++ b/tests/unit/profiling/flops_profiler/test_flops_profiler.py @@ -9,7 +9,7 @@ from deepspeed.profiling.flops_profiler import get_model_profile from unit.simple_model import SimpleModel, random_dataloader from unit.common import DistributedTest -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator if torch.half not in get_accelerator().supported_dtypes(): diff --git a/tests/unit/runtime/compile/test_compile_wrapper.py b/tests/unit/runtime/compile/test_compile_wrapper.py index 0bebeed117b4..d1830534f6ea 100644 --- a/tests/unit/runtime/compile/test_compile_wrapper.py +++ b/tests/unit/runtime/compile/test_compile_wrapper.py @@ -8,7 +8,7 @@ import deepspeed from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest diff --git a/tests/unit/runtime/compile/test_compile_zero.py b/tests/unit/runtime/compile/test_compile_zero.py index 79ab5efd5099..7568c27e3ed2 100644 --- a/tests/unit/runtime/compile/test_compile_zero.py +++ b/tests/unit/runtime/compile/test_compile_zero.py @@ -7,7 +7,7 @@ import torch from deepspeed.runtime.zero.offload_config import OffloadDeviceEnum -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator from unit.runtime.compile.util import compare_loss diff --git a/tests/unit/runtime/compile/test_load_config.py b/tests/unit/runtime/compile/test_load_config.py index f3c53ede91fd..601adae58884 100644 --- a/tests/unit/runtime/compile/test_load_config.py +++ b/tests/unit/runtime/compile/test_load_config.py @@ -9,7 +9,7 @@ from unit.simple_model import SimpleModel import deepspeed from deepspeed.accelerator import get_accelerator -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from unit.common import DistributedTest diff --git a/tests/unit/runtime/half_precision/onebit/test_onebit.py b/tests/unit/runtime/half_precision/onebit/test_onebit.py index 32ee262f3714..1be2d73ef4c0 100644 --- a/tests/unit/runtime/half_precision/onebit/test_onebit.py +++ b/tests/unit/runtime/half_precision/onebit/test_onebit.py @@ -17,7 +17,7 @@ from unit.common import DistributedTest from unit.simple_model import SimpleModel, random_dataloader from unit.alexnet_model import AlexNetPipe, train_cifar -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator PipeTopo = PipeDataParallelTopology diff --git a/tests/unit/runtime/half_precision/test_fp16.py b/tests/unit/runtime/half_precision/test_fp16.py index 9229794b39f8..5b300053d2a8 100644 --- a/tests/unit/runtime/half_precision/test_fp16.py +++ b/tests/unit/runtime/half_precision/test_fp16.py @@ -10,7 +10,7 @@ from deepspeed.ops.adam import FusedAdam from unit.common import DistributedTest from unit.simple_model import SimpleModel, SimpleOptimizer, random_dataloader, SimpleMoEModel, sequence_dataloader -from deepspeed.runtime.utils import required_torch_version +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator from deepspeed.ops.op_builder import CPUAdamBuilder from deepspeed.moe.utils import split_params_into_different_moe_groups_for_optimizer diff --git a/tests/unit/runtime/test_ds_initialize.py b/tests/unit/runtime/test_ds_initialize.py index 1f3cc991eba7..169096a6d4e5 100644 --- a/tests/unit/runtime/test_ds_initialize.py +++ b/tests/unit/runtime/test_ds_initialize.py @@ -17,7 +17,8 @@ from deepspeed.ops.adam import FusedAdam from deepspeed.runtime.lr_schedules import WARMUP_LR, WarmupLR from deepspeed.runtime.config import ADAM_OPTIMIZER -from deepspeed.runtime.utils import see_memory_usage, required_torch_version +from deepspeed.runtime.utils import see_memory_usage +from deepspeed.utils.torch import required_torch_version from deepspeed.accelerator import get_accelerator diff --git a/tests/unit/util.py b/tests/unit/util.py index 5acf580ed3c8..feec326ede6c 100644 --- a/tests/unit/util.py +++ b/tests/unit/util.py @@ -7,7 +7,6 @@ import torch from deepspeed.accelerator import get_accelerator, is_current_accelerator_supported from deepspeed.git_version_info import torch_info -from packaging import version as pkg_version def skip_on_arch(min_arch=7): @@ -62,20 +61,6 @@ def bf16_required_version_check(accelerator_check=True): return False -def required_torch_version(min_version=None, max_version=None): - assert min_version or max_version, "Must provide a min_version or max_version argument" - - torch_version = pkg_version.parse(torch.__version__) - - if min_version and pkg_version.parse(str(min_version)) > torch_version: - return False - - if max_version and pkg_version.parse(str(max_version)) < torch_version: - return False - - return True - - def required_amp_check(): from importlib.util import find_spec if find_spec('apex') is None: