From be2c0e7bff1735c5771d007ed5bcc04e9ea86a96 Mon Sep 17 00:00:00 2001 From: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:43:27 +0100 Subject: [PATCH] Fixing _pre_quantization_dtype when torch_dtype is None (#36930) fix --- src/transformers/modeling_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index a710c5071a..ec3b37404d 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -4454,7 +4454,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix # once the weights have been quantized # Note that once you have loaded a quantized model, you can't change its dtype so this will # remain a single source of truth - config._pre_quantization_dtype = torch_dtype + config._pre_quantization_dtype = torch_dtype if torch_dtype is not None else torch.get_default_dtype() # Prepare the full device map if device_map is not None: