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

Method forward

deepspeed/inference/quantization/layers.py:64–72  ·  view source on GitHub ↗
(self, input: Tensor)

Source from the content-addressed store, hash-verified

62 self.weight.dequantizer = DeQuantizer(config, pre_quant_layer.weight.dtype)
63
64 def forward(self, input: Tensor) -> Tensor:
65 quantized_weight, quant_scale, quant_min = self.weight.deconcat(self.weight)
66 temp_dequantized_weight = self.weight.dequantizer.dequantize(quantized_weight.view(torch.uint8), quant_scale,
67 quant_min)
68
69 # !!! Do not use torch.functional.linear(input, temp_dequantized_weight, self.bias) here as in zero3 torch.functional.linear is
70 # replaced by LinearFunctionForZeroStage3. Which assume weight is non-temporary.
71 # If weight is temp buffer there will be memory leak.
72 return torch._C._nn.linear(input, temp_dequantized_weight, self.bias)
73
74
75class QuantizedEmbedding(nn.Embedding):

Callers

nothing calls this directly

Calls 1

dequantizeMethod · 0.45

Tested by

no test coverage detected