From 20f4e1a00ac4b252aab15ae4c741134140766b7d Mon Sep 17 00:00:00 2001 From: yiyixuxu Date: Tue, 9 Apr 2024 18:07:52 +0000 Subject: [PATCH 1/2] disable test --- tests/models/test_attention_processor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/models/test_attention_processor.py b/tests/models/test_attention_processor.py index fadee4a9e337..ebcede99844f 100644 --- a/tests/models/test_attention_processor.py +++ b/tests/models/test_attention_processor.py @@ -80,6 +80,8 @@ def test_only_cross_attention(self): class DeprecatedAttentionBlockTests(unittest.TestCase): def test_conversion_when_using_device_map(self): + # To-DO for Sayak: enable this test again and to test `device_map='balanced'` once we have this in accelerate https://github.com/huggingface/accelerate/pull/2641 + pass pipe = DiffusionPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-pipe", safety_checker=None) pre_conversion = pipe( From 7a981b48f8f9bba0c49fd33c67849de55340f7c8 Mon Sep 17 00:00:00 2001 From: yiyixuxu Date: Tue, 9 Apr 2024 18:35:09 +0000 Subject: [PATCH 2/2] update --- tests/models/test_attention_processor.py | 77 ++++++++++++------------ 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/tests/models/test_attention_processor.py b/tests/models/test_attention_processor.py index ebcede99844f..c255cad89a8e 100644 --- a/tests/models/test_attention_processor.py +++ b/tests/models/test_attention_processor.py @@ -1,10 +1,7 @@ -import tempfile import unittest -import numpy as np import torch -from diffusers import DiffusionPipeline from diffusers.models.attention_processor import Attention, AttnAddedKVProcessor @@ -82,40 +79,40 @@ class DeprecatedAttentionBlockTests(unittest.TestCase): def test_conversion_when_using_device_map(self): # To-DO for Sayak: enable this test again and to test `device_map='balanced'` once we have this in accelerate https://github.com/huggingface/accelerate/pull/2641 pass - pipe = DiffusionPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-pipe", safety_checker=None) - - pre_conversion = pipe( - "foo", - num_inference_steps=2, - generator=torch.Generator("cpu").manual_seed(0), - output_type="np", - ).images - - # the initial conversion succeeds - pipe = DiffusionPipeline.from_pretrained( - "hf-internal-testing/tiny-stable-diffusion-pipe", device_map="sequential", safety_checker=None - ) - - conversion = pipe( - "foo", - num_inference_steps=2, - generator=torch.Generator("cpu").manual_seed(0), - output_type="np", - ).images - - with tempfile.TemporaryDirectory() as tmpdir: - # save the converted model - pipe.save_pretrained(tmpdir) - - # can also load the converted weights - pipe = DiffusionPipeline.from_pretrained(tmpdir, device_map="sequential", safety_checker=None) - - after_conversion = pipe( - "foo", - num_inference_steps=2, - generator=torch.Generator("cpu").manual_seed(0), - output_type="np", - ).images - - self.assertTrue(np.allclose(pre_conversion, conversion, atol=1e-5)) - self.assertTrue(np.allclose(conversion, after_conversion, atol=1e-5)) + # pipe = DiffusionPipeline.from_pretrained("hf-internal-testing/tiny-stable-diffusion-pipe", safety_checker=None) + + # pre_conversion = pipe( + # "foo", + # num_inference_steps=2, + # generator=torch.Generator("cpu").manual_seed(0), + # output_type="np", + # ).images + + # # the initial conversion succeeds + # pipe = DiffusionPipeline.from_pretrained( + # "hf-internal-testing/tiny-stable-diffusion-pipe", device_map="sequential", safety_checker=None + # ) + + # conversion = pipe( + # "foo", + # num_inference_steps=2, + # generator=torch.Generator("cpu").manual_seed(0), + # output_type="np", + # ).images + + # with tempfile.TemporaryDirectory() as tmpdir: + # # save the converted model + # pipe.save_pretrained(tmpdir) + + # # can also load the converted weights + # pipe = DiffusionPipeline.from_pretrained(tmpdir, device_map="sequential", safety_checker=None) + + # after_conversion = pipe( + # "foo", + # num_inference_steps=2, + # generator=torch.Generator("cpu").manual_seed(0), + # output_type="np", + # ).images + + # self.assertTrue(np.allclose(pre_conversion, conversion, atol=1e-5)) + # self.assertTrue(np.allclose(conversion, after_conversion, atol=1e-5))