MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / bert_layer_quantize

Function bert_layer_quantize

deepspeed/module_inject/module_quantize.py:34–43  ·  view source on GitHub ↗
(layer)

Source from the content-addressed store, hash-verified

32 layer.mlp.dense_4h_to_h.weight.data = quantize_weight(layer.mlp.dense_4h_to_h.weight.data)
33
34 def bert_layer_quantize(layer):
35 layer.attention.self.query.weight.data = quantize_weight(layer.attention.self.query.weight.data)
36 layer.attention.self.key.weight.data = quantize_weight(layer.attention.self.key.weight.data)
37 layer.attention.self.value.weight.data = quantize_weight(layer.attention.self.value.weight.data)
38 layer.attention.output.dense.weight.data = quantize_weight(layer.attention.output.dense.weight.data)
39 if preln:
40 layer.intermediate.dense_act.weight.data = quantize_weight(layer.intermediate.dense_act.weight.data)
41 else:
42 layer.intermediate.dense.weight.data = quantize_weight(layer.intermediate.dense.weight.data)
43 layer.output.dense.weight.data = quantize_weight(layer.output.dense.weight.data)
44
45 def quantize_fn(child):
46 if megatron:

Callers 1

quantize_fnFunction · 0.85

Calls 1

quantize_weightFunction · 0.85

Tested by

no test coverage detected