enhance rewrite state_dict missing _metadata (#14348)
This commit is contained in:
@@ -1050,7 +1050,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||||||
# Handle the case where some state_dict keys shouldn't be saved
|
# Handle the case where some state_dict keys shouldn't be saved
|
||||||
if self._keys_to_ignore_on_save is not None:
|
if self._keys_to_ignore_on_save is not None:
|
||||||
for ignore_key in self._keys_to_ignore_on_save:
|
for ignore_key in self._keys_to_ignore_on_save:
|
||||||
del state_dict[ignore_key]
|
if ignore_key in state_dict.keys():
|
||||||
|
del state_dict[ignore_key]
|
||||||
|
|
||||||
# If we save using the predefined names, we can load using `from_pretrained`
|
# If we save using the predefined names, we can load using `from_pretrained`
|
||||||
output_model_file = os.path.join(save_directory, WEIGHTS_NAME)
|
output_model_file = os.path.join(save_directory, WEIGHTS_NAME)
|
||||||
|
|||||||
Reference in New Issue
Block a user