Unverified Commit fd8136fa authored by Chang Wang's avatar Chang Wang Committed by GitHub
Browse files

improve rewrite state_dict missing _metadata (#14276)

parent d29baf69
......@@ -1049,7 +1049,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
# Handle the case where some state_dict keys shouldn't be saved
if self._keys_to_ignore_on_save is not None:
state_dict = {k: v for k, v in state_dict.items() if k not in self._keys_to_ignore_on_save}
for ignore_key in self._keys_to_ignore_on_save:
del state_dict[ignore_key]
# If we save using the predefined names, we can load using `from_pretrained`
output_model_file = os.path.join(save_directory, WEIGHTS_NAME)
......
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