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
8df28bb3
Unverified
Commit
8df28bb3
authored
Jul 10, 2024
by
Marc Sun
Committed by
GitHub
Jul 10, 2024
Browse files
Push sharded checkpoint to hub when `push_to_hub=True` in `TrainingArguments` (#31808)
Save sharded checkpoint in Trainer
parent
da79b180
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
src/transformers/trainer.py
src/transformers/trainer.py
+10
-0
No files found.
src/transformers/trainer.py
View file @
8df28bb3
...
...
@@ -22,6 +22,7 @@ import functools
import
glob
import
importlib.metadata
import
inspect
import
json
import
math
import
os
import
random
...
...
@@ -4215,6 +4216,15 @@ class Trainer:
output_dir
=
self
.
args
.
output_dir
# To avoid a new synchronization of all model weights, we just copy the file from the checkpoint folder
modeling_files
=
[
CONFIG_NAME
,
WEIGHTS_NAME
,
SAFE_WEIGHTS_NAME
]
# Add sharded checkpoints if we have an index
for
index_file
in
[
WEIGHTS_INDEX_NAME
,
SAFE_WEIGHTS_INDEX_NAME
]:
index_path
=
os
.
path
.
join
(
checkpoint_folder
,
index_file
)
if
os
.
path
.
isfile
(
index_path
):
modeling_files
.
append
(
index_file
)
with
open
(
index_path
)
as
f
:
index
=
json
.
loads
(
f
.
read
())
shard_files
=
list
(
set
(
index
[
"weight_map"
].
values
()))
modeling_files
.
extend
(
shard_files
)
if
is_peft_available
():
modeling_files
.
extend
([
ADAPTER_CONFIG_NAME
,
ADAPTER_WEIGHTS_NAME
,
ADAPTER_SAFE_WEIGHTS_NAME
])
for
modeling_file
in
modeling_files
:
...
...
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