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
502a10a6
Unverified
Commit
502a10a6
authored
Jan 02, 2024
by
hoshi-hiyouga
Committed by
GitHub
Jan 02, 2024
Browse files
Fix trainer saving safetensors: metadata is None (#28219)
* Update trainer.py * format
parent
cad9f5c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/trainer.py
src/transformers/trainer.py
+3
-1
No files found.
src/transformers/trainer.py
View file @
502a10a6
...
...
@@ -2908,7 +2908,9 @@ class Trainer:
else
:
logger
.
info
(
"Trainer.model is not a `PreTrainedModel`, only saving its state dict."
)
if
self
.
args
.
save_safetensors
:
safetensors
.
torch
.
save_file
(
state_dict
,
os
.
path
.
join
(
output_dir
,
SAFE_WEIGHTS_NAME
))
safetensors
.
torch
.
save_file
(
state_dict
,
os
.
path
.
join
(
output_dir
,
SAFE_WEIGHTS_NAME
),
metadata
=
{
"format"
:
"pt"
}
)
else
:
torch
.
save
(
state_dict
,
os
.
path
.
join
(
output_dir
,
WEIGHTS_NAME
))
else
:
...
...
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