Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
a0042379
Unverified
Commit
a0042379
authored
Jul 27, 2023
by
Sourab Mangrulkar
Committed by
GitHub
Jul 27, 2023
Browse files
fix deepspeed load best model at end when the model gets sharded (#25057)
parent
1689aea7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
54 deletions
+53
-54
src/transformers/trainer.py
src/transformers/trainer.py
+53
-54
No files found.
src/transformers/trainer.py
View file @
a0042379
...
...
@@ -2093,15 +2093,14 @@ class Trainer:
best_safe_adapter_model_path
=
os
.
path
.
join
(
self
.
state
.
best_model_checkpoint
,
ADAPTER_SAFE_WEIGHTS_NAME
)
model
=
self
.
model_wrapped
if
is_sagemaker_mp_enabled
()
else
self
.
model
if
(
if
self
.
is_deepspeed_enabled
:
deepspeed_load_checkpoint
(
self
.
model_wrapped
,
self
.
state
.
best_model_checkpoint
)
elif
(
os
.
path
.
exists
(
best_model_path
)
or
os
.
path
.
exists
(
best_safe_model_path
)
or
os
.
path
.
exists
(
best_adapter_model_path
)
or
os
.
path
.
exists
(
best_safe_adapter_model_path
)
):
if
self
.
is_deepspeed_enabled
:
deepspeed_load_checkpoint
(
self
.
model_wrapped
,
self
.
state
.
best_model_checkpoint
)
else
:
has_been_loaded
=
True
if
is_sagemaker_mp_enabled
():
if
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
state
.
best_model_checkpoint
,
"user_content.pt"
)):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment