From 61685dc0008987820232880f6cb7bc34793f0d11 Mon Sep 17 00:00:00 2001 From: Olatunji Ruwase Date: Sun, 2 Mar 2025 20:07:02 -0500 Subject: [PATCH] Use new dlpack api; Formatting fixes Signed-off-by: Olatunji Ruwase --- deepspeed/autotuning/autotuner.py | 4 ++-- deepspeed/inference/engine.py | 2 +- deepspeed/launcher/runner.py | 2 +- deepspeed/runtime/compression/cupy.py | 4 ++-- deepspeed/runtime/engine.py | 2 +- deepspeed/runtime/zero/partition_parameters.py | 3 +-- deepspeed/utils/logging.py | 2 +- op_builder/builder.py | 10 +++++----- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/deepspeed/autotuning/autotuner.py b/deepspeed/autotuning/autotuner.py index a72b3c951e97..419e92bd44ae 100755 --- a/deepspeed/autotuning/autotuner.py +++ b/deepspeed/autotuning/autotuner.py @@ -71,7 +71,7 @@ def __init__(self, args, active_resources): logger.info(f"Created autotuning experiments directory: {self.exps_dir}") except: logger.error( - f"Failed to create {self.exps_dir}, please check `exps_dir` in the autotuning config file is accessible by all the nodes in the job." + f"Failed to create {self.exps_dir}, please check exps_dir in the autotuning config file is accessible by all the nodes in the job." ) exit(-1) @@ -84,7 +84,7 @@ def __init__(self, args, active_resources): logger.info(f"Created autotuning results directory: {self.exps_dir}") except: logger.error( - f"Failed to create {self.results_dir}, please check `results_dir` in the autotuning config file is accessible by all the nodes in the job." + f"Failed to create {self.results_dir}, please check results_dir in the autotuning config file is accessible by all the nodes in the job." ) exit(-1) diff --git a/deepspeed/inference/engine.py b/deepspeed/inference/engine.py index a529d9343228..0a74d19e91f5 100755 --- a/deepspeed/inference/engine.py +++ b/deepspeed/inference/engine.py @@ -600,7 +600,7 @@ def _generate(self, *inputs, **kwargs): tensor_length = input_tensor.shape[-1] if tensor_length > self._config.max_out_tokens: raise RuntimeError( - f"Input with size {tensor_length} exceeds maximum length of {self._config.max_out_tokens}. Please increase `max_tokens` in the DeepSpeed Inference Config." + f"Input with size {tensor_length} exceeds maximum length of {self._config.max_out_tokens}. Please increase max_tokens in the DeepSpeed Inference Config." ) return self.module.generate(*inputs, **kwargs) diff --git a/deepspeed/launcher/runner.py b/deepspeed/launcher/runner.py index 5f926834dda2..bea1e14fa51f 100755 --- a/deepspeed/launcher/runner.py +++ b/deepspeed/launcher/runner.py @@ -491,7 +491,7 @@ def main(args=None): args.master_addr = result.decode('utf-8').split()[0] if not args.master_addr: raise RuntimeError( - f"Unable to detect suitable master address via `hostname -I`, please manually specify one via --master_addr" + "Unable to detect suitable master address via `hostname -I`, please manually specify one via --master_addr" ) logger.info(f"Using IP address of {args.master_addr} for node {first_host}") diff --git a/deepspeed/runtime/compression/cupy.py b/deepspeed/runtime/compression/cupy.py index b959a9c20372..7133ac04ed2b 100644 --- a/deepspeed/runtime/compression/cupy.py +++ b/deepspeed/runtime/compression/cupy.py @@ -14,10 +14,10 @@ def __init__(self): pass def torch2cupy(self, tensor): - return cupy.fromDlpack(to_dlpack(tensor)) + return cupy.from_dlpack(to_dlpack(tensor)) def cupy2torch(self, cupy_tensor): - return from_dlpack(cupy_tensor.toDlpack()) + return from_dlpack(cupy_tensor) def compress_by_chunk(self, cupy_bool_tensor, num_chunks): packed_sign = cupy.packbits(cupy_bool_tensor) diff --git a/deepspeed/runtime/engine.py b/deepspeed/runtime/engine.py index 4d932f8d5046..df6d286494de 100755 --- a/deepspeed/runtime/engine.py +++ b/deepspeed/runtime/engine.py @@ -3790,7 +3790,7 @@ def save_16bit_model(self, save_dir, save_filename="pytorch_model.bin", exclude_ else: # the model will be bogus if not consolidated so don't confuse the user by saving it logger.info( - f"Did not save the model {path} because `stage3_gather_16bit_weights_on_model_save` is False") + f"Did not save the model {path} because stage3_gather_16bit_weights_on_model_save is False") return False else: state_dict = self.module_state_dict(exclude_frozen_parameters=exclude_frozen_parameters) diff --git a/deepspeed/runtime/zero/partition_parameters.py b/deepspeed/runtime/zero/partition_parameters.py index e8cb797b8a5b..db03a4b86134 100755 --- a/deepspeed/runtime/zero/partition_parameters.py +++ b/deepspeed/runtime/zero/partition_parameters.py @@ -944,8 +944,7 @@ def __init__(self, """ if config is not None: config_dict_or_path = config - logger.warning( - f'zero.Init: the `config` argument is deprecated. Please use `config_dict_or_path` instead.') + logger.warning('zero.Init: the `config` argument is deprecated. Please use `config_dict_or_path` instead.') _ds_config = deepspeed.runtime.config.DeepSpeedConfig(config_dict_or_path, mpu) if config_dict_or_path is not None else None if _ds_config is not None: diff --git a/deepspeed/utils/logging.py b/deepspeed/utils/logging.py index 77173f2839ca..ed691e3985e1 100644 --- a/deepspeed/utils/logging.py +++ b/deepspeed/utils/logging.py @@ -158,6 +158,6 @@ def should_log_le(max_log_level_str): max_log_level_str = max_log_level_str.lower() if max_log_level_str not in log_levels: - raise ValueError(f"{max_log_level_str} is not one of the `logging` levels") + raise ValueError(f"{max_log_level_str} is not one of the logging levels") return get_current_level() <= log_levels[max_log_level_str] diff --git a/op_builder/builder.py b/op_builder/builder.py index 41c0a154186f..9b721e110fcc 100644 --- a/op_builder/builder.py +++ b/op_builder/builder.py @@ -412,8 +412,8 @@ def cpu_arch(self): try: cpu_info = get_cpu_info() except Exception as e: - self.warning(f"{self.name} attempted to use `py-cpuinfo` but failed (exception type: {type(e)}, {e}), " - "falling back to `lscpu` to get this information.") + self.warning(f"{self.name} attempted to use py-cpuinfo but failed (exception type: {type(e)}, {e}), " + "falling back to lscpu to get this information.") cpu_info = self._backup_cpuinfo() if cpu_info is None: return "-march=native" @@ -471,8 +471,8 @@ def simd_width(self): try: cpu_info = get_cpu_info() except Exception as e: - self.warning(f"{self.name} attempted to use `py-cpuinfo` but failed (exception type: {type(e)}, {e}), " - "falling back to `lscpu` to get this information.") + self.warning(f"{self.name} attempted to use py-cpuinfo but failed (exception type: {type(e)}, {e}), " + "falling back to lscpu to get this information.") cpu_info = self._backup_cpuinfo() if cpu_info is None: return '-D__SCALAR__' @@ -642,7 +642,7 @@ def compute_capability_args(self, cross_compile_archs=None): if cross_compile_archs_env is not None: if cross_compile_archs is not None: print( - f"{WARNING} env var `TORCH_CUDA_ARCH_LIST={cross_compile_archs_env}` overrides `cross_compile_archs={cross_compile_archs}`" + f"{WARNING} env var TORCH_CUDA_ARCH_LIST={cross_compile_archs_env} overrides cross_compile_archs={cross_compile_archs}" ) cross_compile_archs = cross_compile_archs_env.replace(' ', ';') else: