From 13d36e89fe6a9aaae7bca48552a2eae9bbee80a2 Mon Sep 17 00:00:00 2001 From: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:24:57 +0100 Subject: [PATCH] Fix device_map check for ggml files (#37003) fix --- src/transformers/modeling_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index f9b3faf480..1f7aabc6bc 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -4329,7 +4329,11 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix "You cannot combine Quantization and loading a model from a GGUF file, try again by making sure you did not passed a `quantization_config` or that you did not load a quantized model from the Hub." ) - if gguf_file and device_map is not None and "disk" in device_map.values(): + if ( + gguf_file + and device_map is not None + and ((isinstance(device_map, dict) and "disk" in device_map.values()) or "disk" in device_map) + ): raise RuntimeError( "One or more modules is configured to be mapped to disk. Disk offload is not supported for models " "loaded from GGUF files."