From be5c1066cb10105914f178aad2264c4c0320d243 Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Wed, 21 Oct 2026 04:37:22 +0000 Subject: [PATCH] skip bf16 precision test on T4. --- .../test_stable_diffusion_xl_img2img.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py b/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py index 15c271950764..a45ca36fc557 100644 --- a/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py +++ b/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py @@ -44,6 +44,7 @@ backend_empty_cache, floats_tensor, load_image, + require_accelerator, slow, torch_device, ) @@ -184,6 +185,15 @@ def get_dummy_inputs(self): class TestStableDiffusionXLImg2ImgPipeline(StableDiffusionXLImg2ImgPipelineTesterConfig, PipelineTesterMixin): + # Re-declares the base method's decorators, which overriding would otherwise drop. + @pytest.mark.skipif(torch_device not in ["cuda", "xpu"], reason="half-precision inference requires CUDA or XPU") + @require_accelerator + @pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16], ids=str) + def test_half_precision_inference_no_nan(self, dtype): + if dtype == torch.bfloat16 and torch_device == "cuda" and torch.cuda.get_device_capability() < (8, 0): + pytest.xfail("produces NaNs in bfloat16 on GPUs without native bfloat16 support (e.g. T4)") + super().test_half_precision_inference_no_nan(dtype) + def test_components_function(self): # `requires_aesthetics_score` is a config value, not a component, so it is not part of `pipe.components`. init_components = self.get_dummy_components()