Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,5 @@ def test_kandinsky_controlnet(self):
image = output.images[0]

assert image.shape == (512, 512, 3)

max_diff = numpy_cosine_similarity_distance(expected_image.flatten(), image.flatten())
assert max_diff < 1e-4
assert max_diff < 2e-4
33 changes: 31 additions & 2 deletions tests/pipelines/ledits_pp/test_ledits_pp_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
UNet2DConditionModel,
)
from diffusers.utils.testing_utils import (
Expectations,
backend_empty_cache,
enable_full_determinism,
floats_tensor,
Expand Down Expand Up @@ -244,7 +245,35 @@ def test_ledits_pp_editing(self):

output_slice = reconstruction[150:153, 140:143, -1]
output_slice = output_slice.flatten()
expected_slice = np.array(
[0.9453125, 0.93310547, 0.84521484, 0.94628906, 0.9111328, 0.80859375, 0.93847656, 0.9042969, 0.8144531]
expected_slices = Expectations(
{
("xpu", 3): np.array(
[
0.9511719,
0.94140625,
0.87597656,
0.9472656,
0.9296875,
0.8378906,
0.94433594,
0.91503906,
0.8491211,
]
),
("cuda", 7): np.array(
[
0.9453125,
0.93310547,
0.84521484,
0.94628906,
0.9111328,
0.80859375,
0.93847656,
0.9042969,
0.8144531,
]
),
}
)
expected_slice = expected_slices.get_expectation()
assert np.abs(output_slice - expected_slice).max() < 1e-2
6 changes: 3 additions & 3 deletions tests/pipelines/test_pipelines_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from diffusers.utils.testing_utils import (
CaptureLogger,
backend_empty_cache,
numpy_cosine_similarity_distance,
require_accelerate_version_greater,
require_accelerator,
require_hf_hub_version_greater,
Expand Down Expand Up @@ -1394,9 +1395,8 @@ def test_float16_inference(self, expected_max_diff=5e-2):
fp16_inputs["generator"] = self.get_generator(0)

output_fp16 = pipe_fp16(**fp16_inputs)[0]

max_diff = np.abs(to_np(output) - to_np(output_fp16)).max()
self.assertLess(max_diff, expected_max_diff, "The outputs of the fp16 and fp32 pipelines are too different.")
max_diff = numpy_cosine_similarity_distance(output.flatten(), output_fp16.flatten())
assert max_diff < 2e-4

@unittest.skipIf(torch_device not in ["cuda", "xpu"], reason="float16 requires CUDA or XPU")
@require_accelerator
Expand Down
50 changes: 25 additions & 25 deletions tests/quantization/gguf/test_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,33 +286,33 @@ def test_pipeline_inference(self):
{
("xpu", 3): np.array(
[
0.19335938,
0.3125,
0.3203125,
0.1328125,
0.3046875,
0.296875,
0.11914062,
0.2890625,
0.2890625,
0.16796875,
0.30273438,
0.33203125,
0.14648438,
0.31640625,
0.33007812,
0.16210938,
0.2734375,
0.27734375,
0.109375,
0.27148438,
0.2578125,
0.1015625,
0.2578125,
0.2578125,
0.14453125,
0.26953125,
0.29492188,
0.12890625,
0.3046875,
0.30859375,
0.17773438,
0.33789062,
0.33203125,
0.16796875,
0.34570312,
0.32421875,
0.28710938,
0.30078125,
0.11132812,
0.27734375,
0.27929688,
0.15625,
0.33203125,
0.31445312,
0.31054688,
0.296875,
0.15234375,
0.3203125,
0.29492188,
0.140625,
0.3046875,
0.28515625,
]
),
("cuda", 7): np.array(
Expand Down
Loading