MCPcopy Index your code
hub / github.com/microsoft/BitNet / weight_quant

Method weight_quant

utils/generate-dummy-bitnet-model.py:804–809  ·  view source on GitHub ↗
(self, weight)

Source from the content-addressed store, hash-verified

802 self.gguf_writer.add_rope_scaling_factor(1.0)
803
804 def weight_quant(self, weight):
805 dtype = weight.dtype
806 weight = weight.float()
807 s = 1 / weight.abs().mean().clamp(min=1e-5)
808 result = (weight * s).round().clamp(-1, 1) / s
809 return result.type(dtype)
810
811 def transform_to_tl1(self, x: np.ndarray):
812 scale = np.max(np.abs(x))

Callers 1

modify_tensorsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected