Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions utils/convert-hf-to-gguf-bitnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def write_tensors(self):
data_torch = data_torch.unsqueeze(0).expand((4, *origin_shape)) >> shift
data_torch = data_torch & 3
data_torch = (data_torch.float() - 1).reshape((origin_shape[0] * 4, *origin_shape[1:]))
data_torch = data_torch / scale_map[name.replace(".weight", "")].float()
data_torch = data_torch * scale_map[name.replace(".weight", "")].float()

# use the first number-like part of the tensor name as the block id
bid = None
Expand Down Expand Up @@ -1102,10 +1102,10 @@ def write_tensors(self):
data_torch = data_torch.unsqueeze(0).expand((4, *origin_shape)) >> shift
data_torch = data_torch & 3
data_torch = (data_torch.float() - 1).reshape((origin_shape[0] * 4, *origin_shape[1:]))
# For F16/F32 output: divide by weight_scale to get full float values
# For F16/F32 output: multiply by weight_scale to get full float values
# For I2_S output: keep as ternary {-1,0,1}, scale is passed separately to quantize_to_i2_s
if self.ftype not in (gguf.GGMLQuantizationType.I2_S, gguf.GGMLQuantizationType.TL1, gguf.GGMLQuantizationType.TL2):
data_torch = data_torch / scale_map[name.replace(".weight", "")].float()
data_torch = data_torch * scale_map[name.replace(".weight", "")].float()
# convert any unsupported data types to float32
elif data_torch.dtype not in (torch.float16, torch.float32):
data_torch = data_torch.to(torch.float32)
Expand Down