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

Method modify_tensors

utils/generate-dummy-bitnet-model.py:852–859  ·  view source on GitHub ↗
(self, data_torch: Tensor, name: str, bid: int | None)

Source from the content-addressed store, hash-verified

850
851
852 def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
853 # quant weight to i2 (in fp16)
854 if name.endswith(("q_proj.weight", "k_proj.weight", "v_proj.weight",
855 "down_proj.weight", "up_proj.weight", "gate_proj.weight",
856 "o_proj.weight")):
857 data_torch = self.weight_quant(data_torch)
858
859 return [(self.map_tensor_name(name), data_torch)]
860
861 def write_tensors(self):
862 max_name_len = max(len(s) for _, s in self.tensor_map.mapping.values()) + len(".weight,")

Callers 1

write_tensorsMethod · 0.95

Calls 2

weight_quantMethod · 0.95
map_tensor_nameMethod · 0.45

Tested by

no test coverage detected