Skip to content

Commit af0e6e4

Browse files
authored
gguf: fix dequantization. (#14333)
1 parent 31d400a commit af0e6e4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/diffusers/quantizers/gguf/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def _dequantize_gguf_and_restore_linear(model, modules_to_not_convert=[]):
173173
module.bias is not None,
174174
device=device,
175175
)
176-
new_module.weight = nn.Parameter(dequantize_gguf_tensor(module.weight))
176+
# `dequantize_gguf_tensor` returns fp16 (GGUF scales are half), so cast to the module's
177+
# `compute_dtype` to keep the restored layer consistent with the activations.
178+
new_module.weight = nn.Parameter(dequantize_gguf_tensor(module.weight).to(module.compute_dtype))
177179
if bias is not None:
178180
new_module.bias = bias
179181

0 commit comments

Comments
 (0)