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

Function selective_dequantize

csrc/fp_quantizer/fp_quantize.cpp:100–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 return; \
99 }
100void selective_dequantize(torch::Tensor& val,
101 torch::Tensor& val_q,
102 torch::Tensor& indexes,
103 int group_size,
104 int q_mantisa_bits,
105 int q_exponent_bits)
106{
107 int total_elems = at::numel(val);
108 int num_indexes = indexes.size(0);
109 TORCH_CHECK(group_size > 0, "group_size must be positive");
110 TORCH_CHECK(group_size % 8 == 0, "group_size must be divisible by 8");
111 TORCH_CHECK(total_elems % group_size == 0,
112 "tensor element count must be divisible by group_size");
113 int num_groups = total_elems / group_size;
114 if (num_groups == 0 || num_indexes == 0) { return; }
115
116 DISPATCH_DEQUANTIZE_INDEX(kHalf, __half, 10);
117#ifdef BF16_AVAILABLE
118 DISPATCH_DEQUANTIZE_INDEX(kBFloat16, __nv_bfloat16, 7);
119#endif
120}
121
122at::Tensor get_scales(torch::Tensor& out, int num_groups)
123{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected