Skip to content

Commit 7dfd599

Browse files
committed
remove unneeded compile test.
1 parent 81109a5 commit 7dfd599

File tree

6 files changed

+0
-338
lines changed

6 files changed

+0
-338
lines changed

tests/pipelines/controlnet/test_controlnet.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import gc
1717
import tempfile
18-
import traceback
1918
import unittest
2019

2120
import numpy as np
@@ -39,13 +38,9 @@
3938
backend_reset_max_memory_allocated,
4039
backend_reset_peak_memory_stats,
4140
enable_full_determinism,
42-
get_python_version,
43-
is_torch_compile,
4441
load_image,
4542
load_numpy,
46-
require_torch_2,
4743
require_torch_accelerator,
48-
run_test_in_subprocess,
4944
slow,
5045
torch_device,
5146
)
@@ -68,52 +63,6 @@
6863
enable_full_determinism()
6964

7065

71-
# Will be run via run_test_in_subprocess
72-
def _test_stable_diffusion_compile(in_queue, out_queue, timeout):
73-
error = None
74-
try:
75-
_ = in_queue.get(timeout=timeout)
76-
77-
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny")
78-
79-
pipe = StableDiffusionControlNetPipeline.from_pretrained(
80-
"stable-diffusion-v1-5/stable-diffusion-v1-5", safety_checker=None, controlnet=controlnet
81-
)
82-
pipe.to(torch_device)
83-
pipe.set_progress_bar_config(disable=None)
84-
85-
pipe.unet.to(memory_format=torch.channels_last)
86-
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
87-
88-
pipe.controlnet.to(memory_format=torch.channels_last)
89-
pipe.controlnet = torch.compile(pipe.controlnet, mode="reduce-overhead", fullgraph=True)
90-
91-
generator = torch.Generator(device="cpu").manual_seed(0)
92-
prompt = "bird"
93-
image = load_image(
94-
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png"
95-
).resize((512, 512))
96-
97-
output = pipe(prompt, image, num_inference_steps=10, generator=generator, output_type="np")
98-
image = output.images[0]
99-
100-
assert image.shape == (512, 512, 3)
101-
102-
expected_image = load_numpy(
103-
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny_out_full.npy"
104-
)
105-
expected_image = np.resize(expected_image, (512, 512, 3))
106-
107-
assert np.abs(expected_image - image).max() < 1.0
108-
109-
except Exception:
110-
error = f"{traceback.format_exc()}"
111-
112-
results = {"error": error}
113-
out_queue.put(results, timeout=timeout)
114-
out_queue.join()
115-
116-
11766
class ControlNetPipelineFastTests(
11867
IPAdapterTesterMixin,
11968
PipelineLatentTesterMixin,
@@ -1053,15 +1002,6 @@ def test_canny_guess_mode_euler(self):
10531002
expected_slice = np.array([0.1655, 0.1721, 0.1623, 0.1685, 0.1711, 0.1646, 0.1651, 0.1631, 0.1494])
10541003
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
10551004

1056-
@is_torch_compile
1057-
@require_torch_2
1058-
@unittest.skipIf(
1059-
get_python_version == (3, 12),
1060-
reason="Torch Dynamo isn't yet supported for Python 3.12.",
1061-
)
1062-
def test_stable_diffusion_compile(self):
1063-
run_test_in_subprocess(test_case=self, target_func=_test_stable_diffusion_compile, inputs=None)
1064-
10651005
def test_v11_shuffle_global_pool_conditions(self):
10661006
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11e_sd15_shuffle")
10671007

tests/pipelines/controlnet_xs/test_controlnetxs.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# limitations under the License.
1515

1616
import gc
17-
import traceback
1817
import unittest
1918

2019
import numpy as np
@@ -36,13 +35,9 @@
3635
from diffusers.utils.testing_utils import (
3736
backend_empty_cache,
3837
enable_full_determinism,
39-
is_torch_compile,
4038
load_image,
41-
load_numpy,
4239
require_accelerator,
43-
require_torch_2,
4440
require_torch_accelerator,
45-
run_test_in_subprocess,
4641
slow,
4742
torch_device,
4843
)
@@ -78,53 +73,6 @@ def to_np(tensor):
7873
return tensor
7974

8075

81-
# Will be run via run_test_in_subprocess
82-
def _test_stable_diffusion_compile(in_queue, out_queue, timeout):
83-
error = None
84-
try:
85-
_ = in_queue.get(timeout=timeout)
86-
87-
controlnet = ControlNetXSAdapter.from_pretrained(
88-
"UmerHA/Testing-ConrolNetXS-SD2.1-canny", torch_dtype=torch.float16
89-
)
90-
pipe = StableDiffusionControlNetXSPipeline.from_pretrained(
91-
"stabilityai/stable-diffusion-2-1-base",
92-
controlnet=controlnet,
93-
safety_checker=None,
94-
torch_dtype=torch.float16,
95-
)
96-
pipe.to(torch_device)
97-
pipe.set_progress_bar_config(disable=None)
98-
99-
pipe.unet.to(memory_format=torch.channels_last)
100-
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
101-
102-
generator = torch.Generator(device="cpu").manual_seed(0)
103-
prompt = "bird"
104-
image = load_image(
105-
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png"
106-
).resize((512, 512))
107-
108-
output = pipe(prompt, image, num_inference_steps=10, generator=generator, output_type="np")
109-
image = output.images[0]
110-
111-
assert image.shape == (512, 512, 3)
112-
113-
expected_image = load_numpy(
114-
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny_out_full.npy"
115-
)
116-
expected_image = np.resize(expected_image, (512, 512, 3))
117-
118-
assert np.abs(expected_image - image).max() < 1.0
119-
120-
except Exception:
121-
error = f"{traceback.format_exc()}"
122-
123-
results = {"error": error}
124-
out_queue.put(results, timeout=timeout)
125-
out_queue.join()
126-
127-
12876
class ControlNetXSPipelineFastTests(
12977
PipelineLatentTesterMixin,
13078
PipelineKarrasSchedulerTesterMixin,
@@ -402,8 +350,3 @@ def test_depth(self):
402350
original_image = image[-3:, -3:, -1].flatten()
403351
expected_image = np.array([0.4844, 0.4937, 0.4956, 0.4663, 0.5039, 0.5044, 0.4565, 0.4883, 0.4941])
404352
assert np.allclose(original_image, expected_image, atol=1e-04)
405-
406-
@is_torch_compile
407-
@require_torch_2
408-
def test_stable_diffusion_compile(self):
409-
run_test_in_subprocess(test_case=self, target_func=_test_stable_diffusion_compile, inputs=None)

tests/pipelines/stable_diffusion/test_stable_diffusion.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import gc
1818
import tempfile
1919
import time
20-
import traceback
2120
import unittest
2221

2322
import numpy as np
@@ -49,16 +48,12 @@
4948
backend_reset_max_memory_allocated,
5049
backend_reset_peak_memory_stats,
5150
enable_full_determinism,
52-
is_torch_compile,
53-
load_image,
5451
load_numpy,
5552
nightly,
5653
numpy_cosine_similarity_distance,
5754
require_accelerate_version_greater,
58-
require_torch_2,
5955
require_torch_accelerator,
6056
require_torch_multi_accelerator,
61-
run_test_in_subprocess,
6257
skip_mps,
6358
slow,
6459
torch_device,
@@ -81,39 +76,6 @@
8176
enable_full_determinism()
8277

8378

84-
# Will be run via run_test_in_subprocess
85-
def _test_stable_diffusion_compile(in_queue, out_queue, timeout):
86-
error = None
87-
try:
88-
inputs = in_queue.get(timeout=timeout)
89-
torch_device = inputs.pop("torch_device")
90-
seed = inputs.pop("seed")
91-
inputs["generator"] = torch.Generator(device=torch_device).manual_seed(seed)
92-
93-
sd_pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", safety_checker=None)
94-
sd_pipe.scheduler = DDIMScheduler.from_config(sd_pipe.scheduler.config)
95-
sd_pipe = sd_pipe.to(torch_device)
96-
97-
sd_pipe.unet.to(memory_format=torch.channels_last)
98-
sd_pipe.unet = torch.compile(sd_pipe.unet, mode="reduce-overhead", fullgraph=True)
99-
100-
sd_pipe.set_progress_bar_config(disable=None)
101-
102-
image = sd_pipe(**inputs).images
103-
image_slice = image[0, -3:, -3:, -1].flatten()
104-
105-
assert image.shape == (1, 512, 512, 3)
106-
expected_slice = np.array([0.38019, 0.28647, 0.27321, 0.40377, 0.38290, 0.35446, 0.39218, 0.38165, 0.42239])
107-
108-
assert np.abs(image_slice - expected_slice).max() < 5e-3
109-
except Exception:
110-
error = f"{traceback.format_exc()}"
111-
112-
results = {"error": error}
113-
out_queue.put(results, timeout=timeout)
114-
out_queue.join()
115-
116-
11779
class StableDiffusionPipelineFastTests(
11880
IPAdapterTesterMixin,
11981
PipelineLatentTesterMixin,
@@ -1224,40 +1186,6 @@ def test_stable_diffusion_textual_inversion_with_sequential_cpu_offload(self):
12241186
max_diff = np.abs(expected_image - image).max()
12251187
assert max_diff < 8e-1
12261188

1227-
@is_torch_compile
1228-
@require_torch_2
1229-
def test_stable_diffusion_compile(self):
1230-
seed = 0
1231-
inputs = self.get_inputs(torch_device, seed=seed)
1232-
# Can't pickle a Generator object
1233-
del inputs["generator"]
1234-
inputs["torch_device"] = torch_device
1235-
inputs["seed"] = seed
1236-
run_test_in_subprocess(test_case=self, target_func=_test_stable_diffusion_compile, inputs=inputs)
1237-
1238-
def test_stable_diffusion_lcm(self):
1239-
unet = UNet2DConditionModel.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", subfolder="unet")
1240-
sd_pipe = StableDiffusionPipeline.from_pretrained("Lykon/dreamshaper-7", unet=unet).to(torch_device)
1241-
sd_pipe.scheduler = LCMScheduler.from_config(sd_pipe.scheduler.config)
1242-
sd_pipe.set_progress_bar_config(disable=None)
1243-
1244-
inputs = self.get_inputs(torch_device)
1245-
inputs["num_inference_steps"] = 6
1246-
inputs["output_type"] = "pil"
1247-
1248-
image = sd_pipe(**inputs).images[0]
1249-
1250-
expected_image = load_image(
1251-
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/lcm_full/stable_diffusion_lcm.png"
1252-
)
1253-
1254-
image = sd_pipe.image_processor.pil_to_numpy(image)
1255-
expected_image = sd_pipe.image_processor.pil_to_numpy(expected_image)
1256-
1257-
max_diff = numpy_cosine_similarity_distance(image.flatten(), expected_image.flatten())
1258-
1259-
assert max_diff < 1e-2
1260-
12611189

12621190
@slow
12631191
@require_torch_accelerator

tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import gc
1717
import random
18-
import traceback
1918
import unittest
2019

2120
import numpy as np
@@ -41,13 +40,10 @@
4140
backend_reset_peak_memory_stats,
4241
enable_full_determinism,
4342
floats_tensor,
44-
is_torch_compile,
4543
load_image,
4644
load_numpy,
4745
nightly,
48-
require_torch_2,
4946
require_torch_accelerator,
50-
run_test_in_subprocess,
5147
skip_mps,
5248
slow,
5349
torch_device,
@@ -70,38 +66,6 @@
7066
enable_full_determinism()
7167

7268

73-
# Will be run via run_test_in_subprocess
74-
def _test_img2img_compile(in_queue, out_queue, timeout):
75-
error = None
76-
try:
77-
inputs = in_queue.get(timeout=timeout)
78-
torch_device = inputs.pop("torch_device")
79-
seed = inputs.pop("seed")
80-
inputs["generator"] = torch.Generator(device=torch_device).manual_seed(seed)
81-
82-
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", safety_checker=None)
83-
pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
84-
pipe.unet.set_default_attn_processor()
85-
pipe.to(torch_device)
86-
pipe.set_progress_bar_config(disable=None)
87-
pipe.unet.to(memory_format=torch.channels_last)
88-
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
89-
90-
image = pipe(**inputs).images
91-
image_slice = image[0, -3:, -3:, -1].flatten()
92-
93-
assert image.shape == (1, 512, 768, 3)
94-
expected_slice = np.array([0.0606, 0.0570, 0.0805, 0.0579, 0.0628, 0.0623, 0.0843, 0.1115, 0.0806])
95-
96-
assert np.abs(expected_slice - image_slice).max() < 1e-3
97-
except Exception:
98-
error = f"{traceback.format_exc()}"
99-
100-
results = {"error": error}
101-
out_queue.put(results, timeout=timeout)
102-
out_queue.join()
103-
104-
10569
class StableDiffusionImg2ImgPipelineFastTests(
10670
IPAdapterTesterMixin,
10771
PipelineLatentTesterMixin,
@@ -654,17 +618,6 @@ def test_img2img_safety_checker_works(self):
654618
assert out.nsfw_content_detected[0], f"Safety checker should work for prompt: {inputs['prompt']}"
655619
assert np.abs(out.images[0]).sum() < 1e-5 # should be all zeros
656620

657-
@is_torch_compile
658-
@require_torch_2
659-
def test_img2img_compile(self):
660-
seed = 0
661-
inputs = self.get_inputs(torch_device, seed=seed)
662-
# Can't pickle a Generator object
663-
del inputs["generator"]
664-
inputs["torch_device"] = torch_device
665-
inputs["seed"] = seed
666-
run_test_in_subprocess(test_case=self, target_func=_test_img2img_compile, inputs=inputs)
667-
668621

669622
@nightly
670623
@require_torch_accelerator

0 commit comments

Comments
 (0)