Skip to content

Commit d252cf3

Browse files
committed
Move to test_pipeline_stable_diffusion_3
1 parent edbb562 commit d252cf3

File tree

2 files changed

+33
-41
lines changed

2 files changed

+33
-41
lines changed

tests/pipelines/stable_diffusion_3/test_pipeline_stable_diffusion_3.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,39 @@ def test_fused_qkv_projections(self):
225225
original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2
226226
), "Original outputs should match when fused QKV projections are disabled."
227227

228+
def test_skip_guidance_layers(self):
229+
components = self.get_dummy_components()
230+
pipe = self.pipeline_class(**components)
231+
pipe = pipe.to(torch_device)
232+
pipe.set_progress_bar_config(disable=None)
233+
234+
inputs = self.get_dummy_inputs(torch_device)
235+
236+
output_full = pipe(**inputs)[0]
237+
238+
inputs_with_skip = inputs.copy()
239+
inputs_with_skip["skip_guidance_layers"] = [0]
240+
output_skip = pipe(**inputs_with_skip)[0]
241+
242+
self.assertFalse(
243+
np.allclose(output_full, output_skip, atol=1e-5), "Outputs should differ when layers are skipped"
244+
)
245+
246+
self.assertEqual(output_full.shape, output_skip.shape, "Outputs should have the same shape")
247+
248+
inputs["num_images_per_prompt"] = 2
249+
output_full = pipe(**inputs)[0]
250+
251+
inputs_with_skip = inputs.copy()
252+
inputs_with_skip["skip_guidance_layers"] = [0]
253+
output_skip = pipe(**inputs_with_skip)[0]
254+
255+
self.assertFalse(
256+
np.allclose(output_full, output_skip, atol=1e-5), "Outputs should differ when layers are skipped"
257+
)
258+
259+
self.assertEqual(output_full.shape, output_skip.shape, "Outputs should have the same shape")
260+
228261

229262
@slow
230263
@require_big_gpu_with_torch_cuda

tests/pipelines/test_pipelines_common.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,47 +1718,6 @@ def test_cfg(self):
17181718

17191719
assert out_cfg.shape == out_no_cfg.shape
17201720

1721-
def test_skip_guidance_layers(self):
1722-
sig = inspect.signature(self.pipeline_class.__call__)
1723-
1724-
if "skip_guidance_layers" not in sig.parameters:
1725-
return
1726-
1727-
components = self.get_dummy_components()
1728-
pipe = self.pipeline_class(**components)
1729-
pipe = pipe.to(torch_device)
1730-
pipe.set_progress_bar_config(disable=None)
1731-
1732-
inputs = self.get_dummy_inputs(torch_device)
1733-
1734-
output_full = pipe(**inputs)[0]
1735-
1736-
inputs_with_skip = inputs.copy()
1737-
inputs_with_skip["skip_guidance_layers"] = [0]
1738-
output_skip = pipe(**inputs_with_skip)[0]
1739-
1740-
self.assertFalse(
1741-
np.allclose(output_full, output_skip, atol=1e-5), "Outputs should differ when layers are skipped"
1742-
)
1743-
1744-
self.assertEqual(output_full.shape, output_skip.shape, "Outputs should have the same shape")
1745-
1746-
if "num_images_per_prompt" not in sig.parameters:
1747-
return
1748-
1749-
inputs["num_images_per_prompt"] = 2
1750-
output_full = pipe(**inputs)[0]
1751-
1752-
inputs_with_skip = inputs.copy()
1753-
inputs_with_skip["skip_guidance_layers"] = [0]
1754-
output_skip = pipe(**inputs_with_skip)[0]
1755-
1756-
self.assertFalse(
1757-
np.allclose(output_full, output_skip, atol=1e-5), "Outputs should differ when layers are skipped"
1758-
)
1759-
1760-
self.assertEqual(output_full.shape, output_skip.shape, "Outputs should have the same shape")
1761-
17621721
def test_callback_inputs(self):
17631722
sig = inspect.signature(self.pipeline_class.__call__)
17641723
has_callback_tensor_inputs = "callback_on_step_end_tensor_inputs" in sig.parameters

0 commit comments

Comments
 (0)