MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / is_compatible

Method is_compatible

op_builder/fp_quantizer.py:26–78  ·  view source on GitHub ↗
(self, verbose=False)

Source from the content-addressed store, hash-verified

24 return f'deepspeed.ops.fp_quantizer.{self.NAME}_op'
25
26 def is_compatible(self, verbose=False):
27 try:
28 import torch
29 except ImportError:
30 if verbose:
31 self.warning("Please install torch if trying to pre-compile inference kernels")
32 return False
33
34 cuda_okay = True
35 if not os.environ.get("DS_IGNORE_CUDA_DETECTION"):
36 if not self.is_rocm_pytorch() and torch.cuda.is_available(): #ignore-cuda
37 sys_cuda_major, _ = installed_cuda_version()
38 torch_cuda_major = int(torch.version.cuda.split('.')[0])
39 cuda_capability = self.cuda_capability_major()
40 if cuda_capability is not None and cuda_capability < 8:
41 if verbose:
42 self.warning("NVIDIA Inference is only supported on Ampere and newer architectures")
43 cuda_okay = False
44 if cuda_capability is not None and cuda_capability >= 8:
45 if torch_cuda_major < 11 or sys_cuda_major < 11:
46 if verbose:
47 self.warning("On Ampere and higher architectures please use CUDA 11+")
48 cuda_okay = False
49
50 try:
51 import triton
52 except ImportError:
53 if verbose:
54 self.warning(
55 "please install triton==2.3.0, 2.3.1 or 3.0.0 if you want to use the FP Quantizer Kernels")
56 return False
57
58 # triton 2.3.{0,1} and 3.0.0 are ok.
59 allowed_versions = ("2.3", "3.0", "3.1", "3.2")
60 if pkg_version:
61 allowed = (pkg_version.parse(v) for v in allowed_versions)
62 installed_triton = pkg_version.parse(triton.__version__)
63 triton_mismatch = all(installed_triton.major != a.major or installed_triton.minor != a.minor
64 for a in allowed)
65 else:
66 installed_triton = triton.__version__
67 major, minor, _ = installed_triton.split(".")
68 allowed = (v.split(".") for v in allowed_versions)
69 triton_mismatch = all(major != v[0] or minor != v[1] for v in allowed)
70
71 if triton_mismatch:
72 if verbose:
73 self.warning(
74 f"FP Quantizer is using an untested triton version ({installed_triton}), only 2.3.{0,1} and 3.0.0 are known to be compatible with these kernels"
75 )
76 return False
77
78 return super().is_compatible(verbose) and cuda_okay
79
80 def filter_ccs(self, ccs):
81 ccs_retained = []

Callers

nothing calls this directly

Calls 6

installed_cuda_versionFunction · 0.85
warningMethod · 0.80
is_rocm_pytorchMethod · 0.80
cuda_capability_majorMethod · 0.80
getMethod · 0.45
is_availableMethod · 0.45

Tested by

no test coverage detected