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
renzhc
diffusers_dcu
Commits
da857beb
Unverified
Commit
da857beb
authored
Apr 02, 2025
by
hlky
Committed by
GitHub
Apr 02, 2025
Browse files
Revert `save_model` in ModelMixin save_pretrained and use safe_serialization=False in test (#11196)
parent
52b460fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
src/diffusers/models/modeling_utils.py
src/diffusers/models/modeling_utils.py
+1
-4
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+1
-1
No files found.
src/diffusers/models/modeling_utils.py
View file @
da857beb
...
@@ -714,10 +714,7 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
...
@@ -714,10 +714,7 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
if
safe_serialization
:
if
safe_serialization
:
# At some point we will need to deal better with save_function (used for TPU and other distributed
# At some point we will need to deal better with save_function (used for TPU and other distributed
# joyfulness), but for now this enough.
# joyfulness), but for now this enough.
try
:
safetensors
.
torch
.
save_file
(
shard
,
filepath
,
metadata
=
{
"format"
:
"pt"
})
safetensors
.
torch
.
save_file
(
shard
,
filepath
,
metadata
=
{
"format"
:
"pt"
})
except
RuntimeError
:
safetensors
.
torch
.
save_model
(
model_to_save
,
filepath
,
metadata
=
{
"format"
:
"pt"
})
else
:
else
:
torch
.
save
(
shard
,
filepath
)
torch
.
save
(
shard
,
filepath
)
...
...
tests/pipelines/test_pipelines_common.py
View file @
da857beb
...
@@ -2293,7 +2293,7 @@ class PipelineTesterMixin:
...
@@ -2293,7 +2293,7 @@ class PipelineTesterMixin:
specified_key
=
next
(
iter
(
components
.
keys
()))
specified_key
=
next
(
iter
(
components
.
keys
()))
with
tempfile
.
TemporaryDirectory
(
ignore_cleanup_errors
=
True
)
as
tmpdirname
:
with
tempfile
.
TemporaryDirectory
(
ignore_cleanup_errors
=
True
)
as
tmpdirname
:
pipe
.
save_pretrained
(
tmpdirname
)
pipe
.
save_pretrained
(
tmpdirname
,
safe_serialization
=
False
)
torch_dtype_dict
=
{
specified_key
:
torch
.
bfloat16
,
"default"
:
torch
.
float16
}
torch_dtype_dict
=
{
specified_key
:
torch
.
bfloat16
,
"default"
:
torch
.
float16
}
loaded_pipe
=
self
.
pipeline_class
.
from_pretrained
(
tmpdirname
,
torch_dtype
=
torch_dtype_dict
)
loaded_pipe
=
self
.
pipeline_class
.
from_pretrained
(
tmpdirname
,
torch_dtype
=
torch_dtype_dict
)
...
...
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