Fix state_dict map location when quantized (#37086)

* Update modeling_utils.py

* Update modeling_utils.py
This commit is contained in:
Cyril Vallez
2025-03-28 17:57:16 +01:00
committed by GitHub
parent d6064754ea
commit a86dad56bc

View File

@@ -4897,7 +4897,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
map_location = "cpu" map_location = "cpu"
if low_cpu_mem_usage: if low_cpu_mem_usage:
if shard_file.endswith(".safetensors") and not is_quantized: if shard_file.endswith(".safetensors"):
map_location = "meta" map_location = "meta"
elif ( elif (
device_map is not None device_map is not None