Include safetensors as part of _load_best_model (#30553)

* Include safetensors

* Cleanup
This commit is contained in:
Zach Mueller 2024-04-29 14:47:26 -04:00 committed by GitHub
parent 9df8b301ce
commit a3aabc702e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2611,7 +2611,9 @@ class Trainer:
load_result = model.load_state_dict(state_dict, False)
if not is_sagemaker_mp_enabled() and has_been_loaded:
self._issue_warnings_after_load(load_result)
elif os.path.exists(os.path.join(self.state.best_model_checkpoint, WEIGHTS_INDEX_NAME)):
elif os.path.exists(os.path.join(self.state.best_model_checkpoint, SAFE_WEIGHTS_INDEX_NAME)) or os.path.exists(
os.path.join(self.state.best_model_checkpoint, WEIGHTS_INDEX_NAME)
):
load_result = load_sharded_checkpoint(
model, self.state.best_model_checkpoint, strict=is_sagemaker_mp_enabled()
)