Fix for scales being in BF16

The main conversion code shouldn't allow this, but apparently some models still end up with quantized 1D tensors, see #383
This commit is contained in:
City
2025-12-17 15:52:16 +01:00
parent 01f8845bf3
commit a57094a3d3
+4
View File
@@ -119,6 +119,10 @@ def gguf_sd_loader(path, handle_prefix="model.diffusion_model.", return_arch=Fal
torch_tensor = torch_tensor.view(*shape)
state_dict[sd_key] = GGMLTensor(torch_tensor, tensor_type=tensor.tensor_type, tensor_shape=shape)
# 1D tensors shouldn't be quantized, this is a fix for BF16
if len(shape) <= 1 and is_quantized(state_dict[sd_key]):
state_dict[sd_key] = dequantize_tensor(state_dict[sd_key], dtype=torch.float32)
# keep track of loaded tensor types
tensor_type_str = getattr(tensor.tensor_type, "name", repr(tensor.tensor_type))
qtype_dict[tensor_type_str] = qtype_dict.get(tensor_type_str, 0) + 1