MCPcopy Create free account
hub / github.com/microsoft/BitNet / quant_weight_fp16

Function quant_weight_fp16

gpu/convert_checkpoint.py:29–32  ·  view source on GitHub ↗
(weight)

Source from the content-addressed store, hash-verified

27 return new_weight, new_scale.reshape(1)
28
29 def quant_weight_fp16(weight):
30 s = 1.0 / weight.abs().mean().clamp_(min=1e-5)
31 new_weight = (weight * s).round().clamp(-1, 1) / s
32 return new_weight
33
34 def convert_int8_to_int2(weight):
35 return convert_weight_int8_to_int2(weight)

Callers 1

convert_ts_checkpointFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected