From f5e9e511a0f82bcd6479a4b094901650736c1ef2 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:04:39 +0530 Subject: [PATCH 1/9] check if default attn procs fix it. --- tests/models/autoencoders/test_models_vae.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index 13e9bb1ba569..a1ddd7521428 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -664,6 +664,8 @@ def get_generator(self, seed=0): ) def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): model = self.get_sd_vae_model() + if hasattr(model, "set_default_attn_processor"): + model.set_default_attn_processor() image = self.get_sd_image(seed) generator = self.get_generator(seed) From 8fc05e2e82c3d66315f7a21e3077affe7c3c2680 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:06:59 +0530 Subject: [PATCH 2/9] print --- tests/models/autoencoders/test_models_vae.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index a1ddd7521428..7ff9adb460b6 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -45,6 +45,7 @@ slow, torch_all_close, torch_device, + print_tensor_test, ) from diffusers.utils.torch_utils import randn_tensor @@ -675,6 +676,7 @@ def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): assert sample.shape == image.shape output_slice = sample[-1, -2:, -2:, :2].flatten().float().cpu() + print_tensor_test(output_slice) expected_output_slice = torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice) assert torch_all_close(output_slice, expected_output_slice, atol=3e-3) From 2e987cbdf92ab282acc610c3c11ab22ca33766ed Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:11:30 +0530 Subject: [PATCH 3/9] print --- tests/models/autoencoders/test_models_vae.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index 7ff9adb460b6..18524818fa22 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -665,8 +665,6 @@ def get_generator(self, seed=0): ) def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): model = self.get_sd_vae_model() - if hasattr(model, "set_default_attn_processor"): - model.set_default_attn_processor() image = self.get_sd_image(seed) generator = self.get_generator(seed) @@ -912,6 +910,7 @@ def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): assert sample.shape == image.shape output_slice = sample[-1, -2:, -2:, :2].flatten().float().cpu() + print_tensor_test(output_slice) expected_output_slice = torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice) assert torch_all_close(output_slice, expected_output_slice, atol=5e-3) From fc1a7e1ddee072286e5bbc73ec2f3d36568eebb7 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:31:42 +0530 Subject: [PATCH 4/9] replace --- tests/models/autoencoders/test_models_vae.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index 18524818fa22..1013291a77d8 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -652,12 +652,12 @@ def get_generator(self, seed=0): # fmt: off [ 33, - [-0.1603, 0.9878, -0.0495, -0.0790, -0.2709, 0.8375, -0.2060, -0.0824], + [-0.1556, 0.9848, -0.0410, -0.0642, -0.2685, 0.8381, -0.2004, -0.0700], [-0.2395, 0.0098, 0.0102, -0.0709, -0.2840, -0.0274, -0.0718, -0.1824], ], [ 47, - [-0.2376, 0.1168, 0.1332, -0.4840, -0.2508, -0.0791, -0.0493, -0.4089], + [-0.2376, 0.1200, 0.1337, -0.4830, -0.2504, -0.0759, -0.0486, -0.4077], [0.0350, 0.0847, 0.0467, 0.0344, -0.0842, -0.0547, -0.0633, -0.1131], ], # fmt: on @@ -888,7 +888,7 @@ def get_generator(self, seed=0): # fmt: off [ 33, - [-0.0344, 0.2912, 0.1687, -0.0137, -0.3462, 0.3552, -0.1337, 0.1078], + [-0.0336, 0.3011, 0.1764, 0.0087, -0.3401, 0.3645, -0.1247, 0.1205], [-0.1603, 0.9878, -0.0495, -0.0790, -0.2709, 0.8375, -0.2060, -0.0824], ], [ From 1c3c86dfd2967734e6d0a21a176e7d305099bce5 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:34:55 +0530 Subject: [PATCH 5/9] style./ --- tests/models/autoencoders/test_models_vae.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index 1013291a77d8..56f44e561ac0 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -37,6 +37,7 @@ enable_full_determinism, floats_tensor, load_hf_numpy, + print_tensor_test, require_torch_accelerator, require_torch_accelerator_with_fp16, require_torch_accelerator_with_training, @@ -45,7 +46,6 @@ slow, torch_all_close, torch_device, - print_tensor_test, ) from diffusers.utils.torch_utils import randn_tensor @@ -652,12 +652,12 @@ def get_generator(self, seed=0): # fmt: off [ 33, - [-0.1556, 0.9848, -0.0410, -0.0642, -0.2685, 0.8381, -0.2004, -0.0700], + [-0.1556, 0.9848, -0.0410, -0.0642, -0.2685, 0.8381, -0.2004, -0.0700], [-0.2395, 0.0098, 0.0102, -0.0709, -0.2840, -0.0274, -0.0718, -0.1824], ], [ 47, - [-0.2376, 0.1200, 0.1337, -0.4830, -0.2504, -0.0759, -0.0486, -0.4077], + [-0.2376, 0.1200, 0.1337, -0.4830, -0.2504, -0.0759, -0.0486, -0.4077], [0.0350, 0.0847, 0.0467, 0.0344, -0.0842, -0.0547, -0.0633, -0.1131], ], # fmt: on @@ -888,7 +888,7 @@ def get_generator(self, seed=0): # fmt: off [ 33, - [-0.0336, 0.3011, 0.1764, 0.0087, -0.3401, 0.3645, -0.1247, 0.1205], + [-0.0336, 0.3011, 0.1764, 0.0087, -0.3401, 0.3645, -0.1247, 0.1205], [-0.1603, 0.9878, -0.0495, -0.0790, -0.2709, 0.8375, -0.2060, -0.0824], ], [ From c1f5bd72e87ba255d9c6563e5a5d00046c5a68c1 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:38:00 +0530 Subject: [PATCH 6/9] replace revision with variant. --- tests/models/unets/test_models_unet_2d_condition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/models/unets/test_models_unet_2d_condition.py b/tests/models/unets/test_models_unet_2d_condition.py index f91686925024..47b279e7b230 100644 --- a/tests/models/unets/test_models_unet_2d_condition.py +++ b/tests/models/unets/test_models_unet_2d_condition.py @@ -1210,11 +1210,11 @@ def get_latents(self, seed=0, shape=(4, 4, 64, 64), fp16=False): return image def get_unet_model(self, fp16=False, model_id="CompVis/stable-diffusion-v1-4"): - revision = "fp16" if fp16 else None + variant = "fp16" if fp16 else None torch_dtype = torch.float16 if fp16 else torch.float32 model = UNet2DConditionModel.from_pretrained( - model_id, subfolder="unet", torch_dtype=torch_dtype, revision=revision + model_id, subfolder="unet", torch_dtype=torch_dtype, variant=variant ) model.to(torch_device).eval() From b524fdbad5aa9a63164e510e22ecc9f60e1a30e1 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:40:35 +0530 Subject: [PATCH 7/9] replace with stable-diffusion-v1-5/stable-diffusion-inpainting. --- tests/models/unets/test_models_unet_2d_condition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/models/unets/test_models_unet_2d_condition.py b/tests/models/unets/test_models_unet_2d_condition.py index 47b279e7b230..9ed42c34a7b8 100644 --- a/tests/models/unets/test_models_unet_2d_condition.py +++ b/tests/models/unets/test_models_unet_2d_condition.py @@ -1433,7 +1433,7 @@ def test_compvis_sd_v1_5_fp16(self, seed, timestep, expected_slice): @require_torch_accelerator @skip_mps def test_compvis_sd_inpaint(self, seed, timestep, expected_slice): - model = self.get_unet_model(model_id="botp/stable-diffusion-v1-5-inpainting") + model = self.get_unet_model(model_id="stable-diffusion-v1-5/stable-diffusion-inpainting") latents = self.get_latents(seed, shape=(4, 9, 64, 64)) encoder_hidden_states = self.get_encoder_hidden_states(seed) @@ -1461,7 +1461,7 @@ def test_compvis_sd_inpaint(self, seed, timestep, expected_slice): ) @require_torch_accelerator_with_fp16 def test_compvis_sd_inpaint_fp16(self, seed, timestep, expected_slice): - model = self.get_unet_model(model_id="botp/stable-diffusion-v1-5-inpainting", fp16=True) + model = self.get_unet_model(model_id="stable-diffusion-v1-5/stable-diffusion-inpainting", fp16=True) latents = self.get_latents(seed, shape=(4, 9, 64, 64), fp16=True) encoder_hidden_states = self.get_encoder_hidden_states(seed, fp16=True) From 90e6f7c59ee25786e6e33d38e137b194311686c1 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 07:46:30 +0530 Subject: [PATCH 8/9] replace with stable-diffusion-v1-5/stable-diffusion-v1-5. --- tests/models/unets/test_models_unet_2d_condition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/models/unets/test_models_unet_2d_condition.py b/tests/models/unets/test_models_unet_2d_condition.py index 9ed42c34a7b8..f354950b6075 100644 --- a/tests/models/unets/test_models_unet_2d_condition.py +++ b/tests/models/unets/test_models_unet_2d_condition.py @@ -1376,7 +1376,7 @@ def test_compvis_sd_v1_4_fp16(self, seed, timestep, expected_slice): @require_torch_accelerator @skip_mps def test_compvis_sd_v1_5(self, seed, timestep, expected_slice): - model = self.get_unet_model(model_id="Jiali/stable-diffusion-1.5") + model = self.get_unet_model(model_id="stable-diffusion-v1-5/stable-diffusion-v1-5") latents = self.get_latents(seed) encoder_hidden_states = self.get_encoder_hidden_states(seed) @@ -1404,7 +1404,7 @@ def test_compvis_sd_v1_5(self, seed, timestep, expected_slice): ) @require_torch_accelerator_with_fp16 def test_compvis_sd_v1_5_fp16(self, seed, timestep, expected_slice): - model = self.get_unet_model(model_id="Jiali/stable-diffusion-1.5", fp16=True) + model = self.get_unet_model(model_id="stable-diffusion-v1-5/stable-diffusion-v1-5", fp16=True) latents = self.get_latents(seed, fp16=True) encoder_hidden_states = self.get_encoder_hidden_states(seed, fp16=True) From 4dd832afa2460480528e362e26f5804d7f6dab96 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 20 Sep 2024 13:33:50 +0530 Subject: [PATCH 9/9] fix --- tests/models/autoencoders/test_models_vae.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/models/autoencoders/test_models_vae.py b/tests/models/autoencoders/test_models_vae.py index 56f44e561ac0..cdf441c0990d 100644 --- a/tests/models/autoencoders/test_models_vae.py +++ b/tests/models/autoencoders/test_models_vae.py @@ -37,7 +37,6 @@ enable_full_determinism, floats_tensor, load_hf_numpy, - print_tensor_test, require_torch_accelerator, require_torch_accelerator_with_fp16, require_torch_accelerator_with_training, @@ -674,7 +673,6 @@ def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): assert sample.shape == image.shape output_slice = sample[-1, -2:, -2:, :2].flatten().float().cpu() - print_tensor_test(output_slice) expected_output_slice = torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice) assert torch_all_close(output_slice, expected_output_slice, atol=3e-3) @@ -910,7 +908,6 @@ def test_stable_diffusion(self, seed, expected_slice, expected_slice_mps): assert sample.shape == image.shape output_slice = sample[-1, -2:, -2:, :2].flatten().float().cpu() - print_tensor_test(output_slice) expected_output_slice = torch.tensor(expected_slice_mps if torch_device == "mps" else expected_slice) assert torch_all_close(output_slice, expected_output_slice, atol=5e-3)