Skip to content

Commit 7078af5

Browse files
DN6sayakpaul
authored andcommitted
[CI] Multiple Slow Test fixes. (#9198)
* update * update * update * update
1 parent 6a0eae8 commit 7078af5

File tree

7 files changed

+23
-82
lines changed

7 files changed

+23
-82
lines changed

tests/lora/test_lora_layers_sd3.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@require_peft_backend
3333
class SD3LoRATests(unittest.TestCase, PeftLoraLoaderMixinTests):
3434
pipeline_class = StableDiffusion3Pipeline
35-
scheduler_cls = FlowMatchEulerDiscreteScheduler()
35+
scheduler_cls = FlowMatchEulerDiscreteScheduler
3636
scheduler_kwargs = {}
3737
uses_flow_matching = True
3838
transformer_kwargs = {
@@ -80,8 +80,7 @@ def test_sd3_lora(self):
8080
Related PR: https://github.com/huggingface/diffusers/pull/8584
8181
"""
8282
components = self.get_dummy_components()
83-
84-
pipe = self.pipeline_class(**components)
83+
pipe = self.pipeline_class(**components[0])
8584
pipe = pipe.to(torch_device)
8685
pipe.set_progress_bar_config(disable=None)
8786

tests/lora/test_lora_layers_sdxl.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -124,71 +124,6 @@ def tearDown(self):
124124
gc.collect()
125125
torch.cuda.empty_cache()
126126

127-
def test_sdxl_0_9_lora_one(self):
128-
generator = torch.Generator().manual_seed(0)
129-
130-
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9")
131-
lora_model_id = "hf-internal-testing/sdxl-0.9-daiton-lora"
132-
lora_filename = "daiton-xl-lora-test.safetensors"
133-
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
134-
pipe.enable_model_cpu_offload()
135-
136-
images = pipe(
137-
"masterpiece, best quality, mountain", output_type="np", generator=generator, num_inference_steps=2
138-
).images
139-
140-
images = images[0, -3:, -3:, -1].flatten()
141-
expected = np.array([0.3838, 0.3482, 0.3588, 0.3162, 0.319, 0.3369, 0.338, 0.3366, 0.3213])
142-
143-
max_diff = numpy_cosine_similarity_distance(expected, images)
144-
assert max_diff < 1e-3
145-
pipe.unload_lora_weights()
146-
release_memory(pipe)
147-
148-
def test_sdxl_0_9_lora_two(self):
149-
generator = torch.Generator().manual_seed(0)
150-
151-
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9")
152-
lora_model_id = "hf-internal-testing/sdxl-0.9-costumes-lora"
153-
lora_filename = "saijo.safetensors"
154-
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
155-
pipe.enable_model_cpu_offload()
156-
157-
images = pipe(
158-
"masterpiece, best quality, mountain", output_type="np", generator=generator, num_inference_steps=2
159-
).images
160-
161-
images = images[0, -3:, -3:, -1].flatten()
162-
expected = np.array([0.3137, 0.3269, 0.3355, 0.255, 0.2577, 0.2563, 0.2679, 0.2758, 0.2626])
163-
164-
max_diff = numpy_cosine_similarity_distance(expected, images)
165-
assert max_diff < 1e-3
166-
167-
pipe.unload_lora_weights()
168-
release_memory(pipe)
169-
170-
def test_sdxl_0_9_lora_three(self):
171-
generator = torch.Generator().manual_seed(0)
172-
173-
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9")
174-
lora_model_id = "hf-internal-testing/sdxl-0.9-kamepan-lora"
175-
lora_filename = "kame_sdxl_v2-000020-16rank.safetensors"
176-
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
177-
pipe.enable_model_cpu_offload()
178-
179-
images = pipe(
180-
"masterpiece, best quality, mountain", output_type="np", generator=generator, num_inference_steps=2
181-
).images
182-
183-
images = images[0, -3:, -3:, -1].flatten()
184-
expected = np.array([0.4015, 0.3761, 0.3616, 0.3745, 0.3462, 0.3337, 0.3564, 0.3649, 0.3468])
185-
186-
max_diff = numpy_cosine_similarity_distance(expected, images)
187-
assert max_diff < 5e-3
188-
189-
pipe.unload_lora_weights()
190-
release_memory(pipe)
191-
192127
def test_sdxl_1_0_lora(self):
193128
generator = torch.Generator("cpu").manual_seed(0)
194129

tests/models/transformers/test_models_transformer_aura_flow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
enable_full_determinism()
2727

2828

29-
class SD3TransformerTests(ModelTesterMixin, unittest.TestCase):
29+
class AuraFlowTransformerTests(ModelTesterMixin, unittest.TestCase):
3030
model_class = AuraFlowTransformer2DModel
3131
main_input_name = "hidden_states"
3232
# We override the items here because the transformer under consideration is small.
@@ -73,3 +73,7 @@ def prepare_init_args_and_inputs_for_common(self):
7373
}
7474
inputs_dict = self.dummy_input
7575
return init_dict, inputs_dict
76+
77+
@unittest.skip("AuraFlowTransformer2DModel uses its own dedicated attention processor. This test does not apply")
78+
def test_set_attn_processor_for_determinism(self):
79+
pass

tests/models/transformers/test_models_transformer_sd3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ def prepare_init_args_and_inputs_for_common(self):
7676
}
7777
inputs_dict = self.dummy_input
7878
return init_dict, inputs_dict
79+
80+
@unittest.skip("SD3Transformer2DModel uses a dedicated attention processor. This test doesn't apply")
81+
def test_set_attn_processor_for_determinism(self):
82+
pass

tests/pipelines/aura_flow/test_pipeline_aura_flow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,7 @@ def test_fused_qkv_projections(self):
163163
assert np.allclose(
164164
original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2
165165
), "Original outputs should match when fused QKV projections are disabled."
166+
167+
@unittest.skip("xformers attention processor does not exist for AuraFlow")
168+
def test_xformers_attention_forwardGenerator_pass(self):
169+
pass

tests/pipelines/lumina/test_lumina_nextdit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def test_lumina_prompt_embeds(self):
119119
max_diff = np.abs(output_with_prompt - output_with_embeds).max()
120120
assert max_diff < 1e-4
121121

122+
@unittest.skip("xformers attention processor does not exist for Lumina")
123+
def test_xformers_attention_forwardGenerator_pass(self):
124+
pass
125+
122126

123127
@slow
124128
@require_torch_gpu

tests/pipelines/text_to_video_synthesis/test_text_to_video.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
import torch
2121
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
2222

23-
from diffusers import (
24-
AutoencoderKL,
25-
DDIMScheduler,
26-
TextToVideoSDPipeline,
27-
UNet3DConditionModel,
28-
)
23+
from diffusers import AutoencoderKL, DDIMScheduler, TextToVideoSDPipeline, UNet3DConditionModel
2924
from diffusers.utils import is_xformers_available
3025
from diffusers.utils.testing_utils import (
3126
enable_full_determinism,
@@ -64,7 +59,7 @@ class TextToVideoSDPipelineFastTests(PipelineTesterMixin, SDFunctionTesterMixin,
6459
def get_dummy_components(self):
6560
torch.manual_seed(0)
6661
unet = UNet3DConditionModel(
67-
block_out_channels=(4, 8),
62+
block_out_channels=(8, 8),
6863
layers_per_block=1,
6964
sample_size=32,
7065
in_channels=4,
@@ -134,10 +129,7 @@ def get_dummy_inputs(self, device, seed=0):
134129
return inputs
135130

136131
def test_dict_tuple_outputs_equivalent(self):
137-
expected_slice = None
138-
if torch_device == "cpu":
139-
expected_slice = np.array([0.4903, 0.5649, 0.5504, 0.5179, 0.4821, 0.5466, 0.4131, 0.5052, 0.5077])
140-
return super().test_dict_tuple_outputs_equivalent(expected_slice=expected_slice)
132+
return super().test_dict_tuple_outputs_equivalent()
141133

142134
def test_text_to_video_default_case(self):
143135
device = "cpu" # ensure determinism for the device-dependent torch.Generator
@@ -151,9 +143,8 @@ def test_text_to_video_default_case(self):
151143
frames = sd_pipe(**inputs).frames
152144

153145
image_slice = frames[0][0][-3:, -3:, -1]
154-
155146
assert frames[0][0].shape == (32, 32, 3)
156-
expected_slice = np.array([0.7537, 0.1752, 0.6157, 0.5508, 0.4240, 0.4110, 0.4838, 0.5648, 0.5094])
147+
expected_slice = np.array([0.8093, 0.2751, 0.6976, 0.5927, 0.4616, 0.4336, 0.5094, 0.5683, 0.4796])
157148

158149
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
159150

0 commit comments

Comments
 (0)