Unverified Commit c9bae84e authored by Sourab Mangrulkar's avatar Sourab Mangrulkar Committed by GitHub
Browse files

Resolving Attribute error when using the FSDP ram efficient feature (#25820)

fix bug
parent 77713d11
...@@ -3574,11 +3574,11 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix ...@@ -3574,11 +3574,11 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
if param.device == torch.device("meta"): if param.device == torch.device("meta"):
if not (is_quantized): if not (is_quantized):
set_module_tensor_to_device( set_module_tensor_to_device(
model, key, "cpu", torch.empty(*param.size(), dtype=dtype) model_to_load, key, "cpu", torch.empty(*param.size(), dtype=dtype)
) )
else: else:
set_module_quantized_tensor_to_device( set_module_quantized_tensor_to_device(
model, key, "cpu", torch.empty(*param.size(), dtype=dtype) model_to_load, key, "cpu", torch.empty(*param.size(), dtype=dtype)
) )
else: else:
error_msgs += _load_state_dict_into_model(model_to_load, state_dict, start_prefix) error_msgs += _load_state_dict_into_model(model_to_load, state_dict, start_prefix)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment