Skip to content

Commit 2405383

Browse files
authored
[tests] remove/speedup some low signal tests (#9285)
* remove 2 shapes from SDFunctionTesterMixin::test_vae_tiling * combine freeu enable/disable test to reduce many inference runs * remove low signal unet test for signature * remove low signal embeddings test * remove low signal progress bar test from PipelineTesterMixin * combine ip-adapter single and multi tests to save many inferences * fix broken tests * Update tests/pipelines/test_pipelines_common.py * Update tests/pipelines/test_pipelines_common.py * add progress bar tests
1 parent f6f16a0 commit 2405383

27 files changed

+341
-165
lines changed

tests/models/test_layers_utils.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ def test_timestep_embeddings(self):
5555
assert grad > prev_grad
5656
prev_grad = grad
5757

58-
def test_timestep_defaults(self):
59-
embedding_dim = 16
60-
timesteps = torch.arange(10)
61-
62-
t1 = get_timestep_embedding(timesteps, embedding_dim)
63-
t2 = get_timestep_embedding(
64-
timesteps, embedding_dim, flip_sin_to_cos=False, downscale_freq_shift=1, max_period=10_000
65-
)
66-
67-
assert torch.allclose(t1.cpu(), t2.cpu(), 1e-3)
68-
6958
def test_timestep_flip_sin_cos(self):
7059
embedding_dim = 16
7160
timesteps = torch.arange(10)

tests/models/test_modeling_common.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,6 @@ def test_weight_overwrite(self):
183183

184184

185185
class UNetTesterMixin:
186-
def test_forward_signature(self):
187-
init_dict, _ = self.prepare_init_args_and_inputs_for_common()
188-
189-
model = self.model_class(**init_dict)
190-
signature = inspect.signature(model.forward)
191-
# signature.parameters is an OrderedDict => so arg_names order is deterministic
192-
arg_names = [*signature.parameters.keys()]
193-
194-
expected_arg_names = ["sample", "timestep"]
195-
self.assertListEqual(arg_names[:2], expected_arg_names)
196-
197186
def test_forward_with_norm_groups(self):
198187
init_dict, inputs_dict = self.prepare_init_args_and_inputs_for_common()
199188

tests/pipelines/animatediff/test_animatediff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_motion_unet_loading(self):
175175
def test_attention_slicing_forward_pass(self):
176176
pass
177177

178-
def test_ip_adapter_single(self):
178+
def test_ip_adapter(self):
179179
expected_pipe_slice = None
180180
if torch_device == "cpu":
181181
expected_pipe_slice = np.array(
@@ -209,7 +209,7 @@ def test_ip_adapter_single(self):
209209
0.5620,
210210
]
211211
)
212-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
212+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
213213

214214
def test_dict_tuple_outputs_equivalent(self):
215215
expected_slice = None

tests/pipelines/animatediff/test_animatediff_controlnet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_motion_unet_loading(self):
193193
def test_attention_slicing_forward_pass(self):
194194
pass
195195

196-
def test_ip_adapter_single(self):
196+
def test_ip_adapter(self):
197197
expected_pipe_slice = None
198198
if torch_device == "cpu":
199199
expected_pipe_slice = np.array(
@@ -218,7 +218,7 @@ def test_ip_adapter_single(self):
218218
0.5155,
219219
]
220220
)
221-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
221+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
222222

223223
def test_dict_tuple_outputs_equivalent(self):
224224
expected_slice = None

tests/pipelines/animatediff/test_animatediff_sparsectrl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_motion_unet_loading(self):
195195
def test_attention_slicing_forward_pass(self):
196196
pass
197197

198-
def test_ip_adapter_single(self):
198+
def test_ip_adapter(self):
199199
expected_pipe_slice = None
200200
if torch_device == "cpu":
201201
expected_pipe_slice = np.array(
@@ -220,7 +220,7 @@ def test_ip_adapter_single(self):
220220
0.5155,
221221
]
222222
)
223-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
223+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
224224

225225
def test_dict_tuple_outputs_equivalent(self):
226226
expected_slice = None

tests/pipelines/animatediff/test_animatediff_video2video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_motion_unet_loading(self):
175175
def test_attention_slicing_forward_pass(self):
176176
pass
177177

178-
def test_ip_adapter_single(self):
178+
def test_ip_adapter(self):
179179
expected_pipe_slice = None
180180

181181
if torch_device == "cpu":
@@ -201,7 +201,7 @@ def test_ip_adapter_single(self):
201201
0.5378,
202202
]
203203
)
204-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
204+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
205205

206206
def test_inference_batch_single_identical(
207207
self,

tests/pipelines/controlnet/test_controlnet.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ def get_dummy_inputs(self, device, seed=0):
220220
def test_attention_slicing_forward_pass(self):
221221
return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3)
222222

223-
def test_ip_adapter_single(self):
223+
def test_ip_adapter(self):
224224
expected_pipe_slice = None
225225
if torch_device == "cpu":
226226
expected_pipe_slice = np.array([0.5234, 0.3333, 0.1745, 0.7605, 0.6224, 0.4637, 0.6989, 0.7526, 0.4665])
227-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
227+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
228228

229229
@unittest.skipIf(
230230
torch_device != "cuda" or not is_xformers_available(),
@@ -460,11 +460,11 @@ def test_xformers_attention_forwardGenerator_pass(self):
460460
def test_inference_batch_single_identical(self):
461461
self._test_inference_batch_single_identical(expected_max_diff=2e-3)
462462

463-
def test_ip_adapter_single(self):
463+
def test_ip_adapter(self):
464464
expected_pipe_slice = None
465465
if torch_device == "cpu":
466466
expected_pipe_slice = np.array([0.2422, 0.3425, 0.4048, 0.5351, 0.3503, 0.2419, 0.4645, 0.4570, 0.3804])
467-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
467+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
468468

469469
def test_save_pretrained_raise_not_implemented_exception(self):
470470
components = self.get_dummy_components()
@@ -679,11 +679,11 @@ def test_xformers_attention_forwardGenerator_pass(self):
679679
def test_inference_batch_single_identical(self):
680680
self._test_inference_batch_single_identical(expected_max_diff=2e-3)
681681

682-
def test_ip_adapter_single(self):
682+
def test_ip_adapter(self):
683683
expected_pipe_slice = None
684684
if torch_device == "cpu":
685685
expected_pipe_slice = np.array([0.5264, 0.3203, 0.1602, 0.8235, 0.6332, 0.4593, 0.7226, 0.7777, 0.4780])
686-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
686+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
687687

688688
def test_save_pretrained_raise_not_implemented_exception(self):
689689
components = self.get_dummy_components()

tests/pipelines/controlnet/test_controlnet_img2img.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ def get_dummy_inputs(self, device, seed=0):
173173
def test_attention_slicing_forward_pass(self):
174174
return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3)
175175

176-
def test_ip_adapter_single(self):
176+
def test_ip_adapter(self):
177177
expected_pipe_slice = None
178178
if torch_device == "cpu":
179179
expected_pipe_slice = np.array([0.7096, 0.5149, 0.3571, 0.5897, 0.4715, 0.4052, 0.6098, 0.6886, 0.4213])
180-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
180+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
181181

182182
@unittest.skipIf(
183183
torch_device != "cuda" or not is_xformers_available(),
@@ -371,11 +371,11 @@ def test_xformers_attention_forwardGenerator_pass(self):
371371
def test_inference_batch_single_identical(self):
372372
self._test_inference_batch_single_identical(expected_max_diff=2e-3)
373373

374-
def test_ip_adapter_single(self):
374+
def test_ip_adapter(self):
375375
expected_pipe_slice = None
376376
if torch_device == "cpu":
377377
expected_pipe_slice = np.array([0.5293, 0.7339, 0.6642, 0.3950, 0.5212, 0.5175, 0.7002, 0.5907, 0.5182])
378-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
378+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
379379

380380
def test_save_pretrained_raise_not_implemented_exception(self):
381381
components = self.get_dummy_components()

tests/pipelines/controlnet/test_controlnet_sdxl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ def get_dummy_inputs(self, device, seed=0):
190190
def test_attention_slicing_forward_pass(self):
191191
return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3)
192192

193-
def test_ip_adapter_single(self, from_ssd1b=False, expected_pipe_slice=None):
193+
def test_ip_adapter(self, from_ssd1b=False, expected_pipe_slice=None):
194194
if not from_ssd1b:
195195
expected_pipe_slice = None
196196
if torch_device == "cpu":
197197
expected_pipe_slice = np.array(
198198
[0.7335, 0.5866, 0.5623, 0.6242, 0.5751, 0.5999, 0.4091, 0.4590, 0.5054]
199199
)
200-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
200+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
201201

202202
@unittest.skipIf(
203203
torch_device != "cuda" or not is_xformers_available(),
@@ -970,12 +970,12 @@ def test_controlnet_sdxl_guess(self):
970970
# make sure that it's equal
971971
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-4
972972

973-
def test_ip_adapter_single(self):
973+
def test_ip_adapter(self):
974974
expected_pipe_slice = None
975975
if torch_device == "cpu":
976976
expected_pipe_slice = np.array([0.7212, 0.5890, 0.5491, 0.6425, 0.5970, 0.6091, 0.4418, 0.4556, 0.5032])
977977

978-
return super().test_ip_adapter_single(from_ssd1b=True, expected_pipe_slice=expected_pipe_slice)
978+
return super().test_ip_adapter(from_ssd1b=True, expected_pipe_slice=expected_pipe_slice)
979979

980980
def test_controlnet_sdxl_lcm(self):
981981
device = "cpu" # ensure determinism for the device-dependent torch.Generator

tests/pipelines/controlnet/test_controlnet_sdxl_img2img.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ def get_dummy_inputs(self, device, seed=0):
175175

176176
return inputs
177177

178-
def test_ip_adapter_single(self):
178+
def test_ip_adapter(self):
179179
expected_pipe_slice = None
180180
if torch_device == "cpu":
181181
expected_pipe_slice = np.array([0.6276, 0.5271, 0.5205, 0.5393, 0.5774, 0.5872, 0.5456, 0.5415, 0.5354])
182182
# TODO: update after slices.p
183-
return super().test_ip_adapter_single(expected_pipe_slice=expected_pipe_slice)
183+
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
184184

185185
def test_stable_diffusion_xl_controlnet_img2img(self):
186186
device = "cpu" # ensure determinism for the device-dependent torch.Generator

0 commit comments

Comments
 (0)