Skip to content

Commit 68663f8

Browse files
authored
fix test_vanilla_funetuning failure on XPU and A100 (huggingface#11263)
* fix test_vanilla_funetuning failure on XPU and A100 Signed-off-by: Matrix Yao <[email protected]> * change back to 5e-2 Signed-off-by: Matrix Yao <[email protected]> --------- Signed-off-by: Matrix Yao <[email protected]>
1 parent ffda873 commit 68663f8

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

tests/lora/test_lora_layers_sd.py

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
)
3434
from diffusers.utils.import_utils import is_accelerate_available
3535
from diffusers.utils.testing_utils import (
36+
Expectations,
3637
backend_empty_cache,
3738
load_image,
3839
nightly,
@@ -455,11 +456,54 @@ def test_vanilla_funetuning(self):
455456

456457
images = pipe("A pokemon with blue eyes.", output_type="np", generator=generator, num_inference_steps=2).images
457458

458-
images = images[0, -3:, -3:, -1].flatten()
459-
460-
expected = np.array([0.7406, 0.699, 0.5963, 0.7493, 0.7045, 0.6096, 0.6886, 0.6388, 0.583])
459+
image_slice = images[0, -3:, -3:, -1].flatten()
460+
461+
expected_slices = Expectations(
462+
{
463+
("xpu", 3): np.array(
464+
[
465+
0.6544,
466+
0.6127,
467+
0.5397,
468+
0.6845,
469+
0.6047,
470+
0.5469,
471+
0.6349,
472+
0.5906,
473+
0.5382,
474+
]
475+
),
476+
("cuda", 7): np.array(
477+
[
478+
0.7406,
479+
0.699,
480+
0.5963,
481+
0.7493,
482+
0.7045,
483+
0.6096,
484+
0.6886,
485+
0.6388,
486+
0.583,
487+
]
488+
),
489+
("cuda", 8): np.array(
490+
[
491+
0.6542,
492+
0.61253,
493+
0.5396,
494+
0.6843,
495+
0.6044,
496+
0.5468,
497+
0.6349,
498+
0.5905,
499+
0.5381,
500+
]
501+
),
502+
}
503+
)
504+
expected_slice = expected_slices.get_expectation()
461505

462-
max_diff = numpy_cosine_similarity_distance(expected, images)
506+
max_diff = numpy_cosine_similarity_distance(expected_slice, image_slice)
463507
assert max_diff < 1e-4
464508

465509
pipe.unload_lora_weights()

tests/pipelines/test_pipelines_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ def test_components_function(self):
13471347

13481348
@unittest.skipIf(torch_device not in ["cuda", "xpu"], reason="float16 requires CUDA or XPU")
13491349
@require_accelerator
1350-
def test_float16_inference(self, expected_max_diff=6e-2):
1350+
def test_float16_inference(self, expected_max_diff=5e-2):
13511351
components = self.get_dummy_components()
13521352
pipe = self.pipeline_class(**components)
13531353
for component in pipe.components.values():

0 commit comments

Comments
 (0)