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

Class FPQuantizerBuilder

op_builder/fp_quantizer.py:9–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class FPQuantizerBuilder(CUDAOpBuilder):
10 BUILD_VAR = "DS_BUILD_FP_QUANTIZER"
11 NAME = "fp_quantizer"
12 MIN_COMPUTE_CAPABILITY = 8
13
14 def __init__(self, name=None):
15 name = self.NAME if name is None else name
16 super().__init__(name=name)
17
18 def absolute_name(self):
19 return f'deepspeed.ops.fp_quantizer.{self.NAME}_op'
20
21 def sources(self):
22 return [
23 "csrc/fp_quantizer/fp_quantize_impl.cu",
24 "csrc/fp_quantizer/fp_quantize.cpp",
25 ]
26
27 def extra_ldflags(self):
28 if not self.is_rocm_pytorch():
29 return ['-lcurand']
30 else:
31 return []
32
33 def include_paths(self):
34 return ['csrc/fp_quantizer/includes', 'csrc/includes']
35
36 @staticmethod
37 def get_default_quant_dtype():
38 import torch
39 return torch.uint8
40
41 @staticmethod
42 def get_quant_range(q_bits=None):
43 if q_bits == 8:
44 return 480
45 elif q_bits == 6:
46 return 28.
47 elif q_bits == 12:
48 return 510.
49 else:
50 assert (0), \
51 "Please specify the right quantization range for the selected precision!"

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected