Skip to content

Commit b4226bd

Browse files
authored
[Tests] fix config checking tests (huggingface#7247)
* debig * cast tuples to lists. * debug * handle upcast attention * handle downblock types for vae. * remove print. * address Dhruv's comments. * fix: upblock types. * upcast attention * debug * debug * debug * better guarding. * style
1 parent 46fac82 commit b4226bd

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/diffusers/loaders/single_file_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ def create_unet_diffusers_config(original_config, image_size: int):
462462
config = {
463463
"sample_size": image_size // vae_scale_factor,
464464
"in_channels": unet_params["in_channels"],
465-
"down_block_types": tuple(down_block_types),
466-
"block_out_channels": tuple(block_out_channels),
465+
"down_block_types": down_block_types,
466+
"block_out_channels": block_out_channels,
467467
"layers_per_block": unet_params["num_res_blocks"],
468468
"cross_attention_dim": context_dim,
469469
"attention_head_dim": head_dim,
@@ -482,7 +482,7 @@ def create_unet_diffusers_config(original_config, image_size: int):
482482
config["num_class_embeds"] = unet_params["num_classes"]
483483

484484
config["out_channels"] = unet_params["out_channels"]
485-
config["up_block_types"] = tuple(up_block_types)
485+
config["up_block_types"] = up_block_types
486486

487487
return config
488488

@@ -530,9 +530,9 @@ def create_vae_diffusers_config(original_config, image_size, scaling_factor=None
530530
"sample_size": image_size,
531531
"in_channels": vae_params["in_channels"],
532532
"out_channels": vae_params["out_ch"],
533-
"down_block_types": tuple(down_block_types),
534-
"up_block_types": tuple(up_block_types),
535-
"block_out_channels": tuple(block_out_channels),
533+
"down_block_types": down_block_types,
534+
"up_block_types": up_block_types,
535+
"block_out_channels": block_out_channels,
536536
"latent_channels": vae_params["z_channels"],
537537
"layers_per_block": vae_params["num_res_blocks"],
538538
"scaling_factor": scaling_factor,

tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,8 @@ def test_single_file_component_configs(self):
10881088
for param_name, param_value in single_file_pipe.unet.config.items():
10891089
if param_name in PARAMS_TO_IGNORE:
10901090
continue
1091+
if param_name == "upcast_attention" and pipe.unet.config[param_name] is None:
1092+
pipe.unet.config[param_name] = False
10911093
assert (
10921094
pipe.unet.config[param_name] == param_value
10931095
), f"{param_name} is differs between single file loading and pretrained loading"

0 commit comments

Comments
 (0)