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
c71c19c5
Unverified
Commit
c71c19c5
authored
Jun 20, 2024
by
YiYi Xu
Committed by
GitHub
Jun 21, 2024
Browse files
a few fix for shard checkpoints (#8656)
fix Co-authored-by:
yiyixuxu
<
yixu310@gmail,com
>
parent
adc31940
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
1 deletion
+5
-1
src/diffusers/models/modeling_utils.py
src/diffusers/models/modeling_utils.py
+1
-1
tests/models/test_modeling_common.py
tests/models/test_modeling_common.py
+2
-0
tests/models/unets/test_models_unet_2d_condition.py
tests/models/unets/test_models_unet_2d_condition.py
+2
-0
No files found.
src/diffusers/models/modeling_utils.py
View file @
c71c19c5
...
...
@@ -819,7 +819,7 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
offload_folder
=
offload_folder
,
offload_state_dict
=
offload_state_dict
,
dtype
=
torch_dtype
,
force_hook
=
force_hook
,
force_hook
s
=
force_hook
,
strict
=
True
,
)
model
.
_undo_temp_convert_self_to_deprecated_attention_blocks
()
...
...
tests/models/test_modeling_common.py
View file @
c71c19c5
...
...
@@ -898,6 +898,7 @@ class ModelTesterMixin:
self
.
assertTrue
(
actual_num_shards
==
expected_num_shards
)
new_model
=
self
.
model_class
.
from_pretrained
(
tmp_dir
)
new_model
=
new_model
.
to
(
torch_device
)
torch
.
manual_seed
(
0
)
new_output
=
new_model
(
**
inputs_dict
)
...
...
@@ -933,6 +934,7 @@ class ModelTesterMixin:
self
.
assertTrue
(
actual_num_shards
==
expected_num_shards
)
new_model
=
self
.
model_class
.
from_pretrained
(
tmp_dir
,
device_map
=
"auto"
)
new_model
=
new_model
.
to
(
torch_device
)
torch
.
manual_seed
(
0
)
new_output
=
new_model
(
**
inputs_dict
)
...
...
tests/models/unets/test_models_unet_2d_condition.py
View file @
c71c19c5
...
...
@@ -1039,6 +1039,7 @@ class UNet2DConditionModelTests(ModelTesterMixin, UNetTesterMixin, unittest.Test
def
test_load_sharded_checkpoint_from_hub
(
self
):
_
,
inputs_dict
=
self
.
prepare_init_args_and_inputs_for_common
()
loaded_model
=
self
.
model_class
.
from_pretrained
(
"hf-internal-testing/unet2d-sharded-dummy"
)
loaded_model
=
loaded_model
.
to
(
torch_device
)
new_output
=
loaded_model
(
**
inputs_dict
)
assert
loaded_model
...
...
@@ -1049,6 +1050,7 @@ class UNet2DConditionModelTests(ModelTesterMixin, UNetTesterMixin, unittest.Test
_
,
inputs_dict
=
self
.
prepare_init_args_and_inputs_for_common
()
ckpt_path
=
snapshot_download
(
"hf-internal-testing/unet2d-sharded-dummy"
)
loaded_model
=
self
.
model_class
.
from_pretrained
(
ckpt_path
,
local_files_only
=
True
)
loaded_model
=
loaded_model
.
to
(
torch_device
)
new_output
=
loaded_model
(
**
inputs_dict
)
assert
loaded_model
...
...
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