1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

adjust tolerance criteria for test_float16_inference in unit test (#11809)

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
This commit is contained in:
kaixuanliu
2025-06-26 15:49:59 +08:00
committed by GitHub
parent a185e1ab91
commit 27bf7fcd0e
2 changed files with 33 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokeni
from diffusers import AmusedInpaintPipeline, AmusedScheduler, UVit2DModel, VQModel
from diffusers.utils import load_image
from diffusers.utils.testing_utils import (
Expectations,
enable_full_determinism,
require_torch_accelerator,
slow,
@@ -246,5 +247,35 @@ class AmusedInpaintPipelineSlowTests(unittest.TestCase):
image_slice = image[0, -3:, -3:, -1].flatten()
assert image.shape == (1, 512, 512, 3)
expected_slice = np.array([0.0227, 0.0157, 0.0098, 0.0213, 0.0250, 0.0127, 0.0280, 0.0380, 0.0095])
expected_slices = Expectations(
{
("xpu", 3): np.array(
[
0.0274,
0.0211,
0.0154,
0.0257,
0.0299,
0.0170,
0.0326,
0.0420,
0.0150,
]
),
("cuda", 7): np.array(
[
0.0227,
0.0157,
0.0098,
0.0213,
0.0250,
0.0127,
0.0280,
0.0380,
0.0095,
]
),
}
)
expected_slice = expected_slices.get_expectation()
assert np.abs(image_slice - expected_slice).max() < 0.003

View File

@@ -1396,7 +1396,7 @@ class PipelineTesterMixin:
output_fp16 = pipe_fp16(**fp16_inputs)[0]
max_diff = numpy_cosine_similarity_distance(output.flatten(), output_fp16.flatten())
assert max_diff < 2e-4
assert max_diff < 1e-2
@unittest.skipIf(torch_device not in ["cuda", "xpu"], reason="float16 requires CUDA or XPU")
@require_accelerator