From a6fa0c7b06d6bdf0fd8c1558e2141f9d2665365f Mon Sep 17 00:00:00 2001 From: DN6 Date: Mon, 30 Nov 2026 18:06:05 +0530 Subject: [PATCH 1/2] [CI] Fix hub attention backend test failures now that `transformers` installs `kernels` --- tests/models/testing_utils/attention.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/models/testing_utils/attention.py b/tests/models/testing_utils/attention.py index 46dcbdfe330d..fc9037a7db64 100644 --- a/tests/models/testing_utils/attention.py +++ b/tests/models/testing_utils/attention.py @@ -24,6 +24,7 @@ from diffusers.models.attention_dispatch import AttentionBackendName, _AttentionBackendRegistry, attention_backend from diffusers.models.attention_processor import Attention, AttnProcessor from diffusers.utils import is_kernels_available, is_torch_version +from diffusers.utils.constants import DIFFUSERS_TRUST_REMOTE_KERNELS from ...testing_utils import assert_tensors_close, backend_empty_cache, is_attention, is_torch_compile, torch_device from .utils import _maybe_cast_to_bf16 @@ -37,6 +38,7 @@ # --------------------------------------------------------------------------- _CUDA_AVAILABLE = torch.cuda.is_available() +_IS_SM80_OR_NEWER = _CUDA_AVAILABLE and torch.cuda.get_device_capability() >= (8, 0) # Every build variant of `kernels-community/sage-blackwell` declares `archs: ["12.0a"]`, so the # kernel only loads on SM120 (consumer/workstation Blackwell). `a` targets are architecture # specific, so neither SM100 nor SM121 is covered. @@ -62,6 +64,9 @@ id="flash_hub", marks=[ pytest.mark.skipif(not _CUDA_AVAILABLE, reason="CUDA is required for flash_hub backend."), + pytest.mark.skipif( + not _IS_SM80_OR_NEWER, reason="An SM80 or newer GPU is required for the flash_hub backend." + ), pytest.mark.skipif( not is_kernels_available(), reason="`kernels` package is required for flash_hub backend. Install with `pip install kernels`.", @@ -74,6 +79,9 @@ id="flash_3_hub", marks=[ pytest.mark.skipif(not _CUDA_AVAILABLE, reason="CUDA is required for _flash_3_hub backend."), + pytest.mark.skipif( + not _IS_SM80_OR_NEWER, reason="An SM80 or newer GPU is required for the _flash_3_hub backend." + ), pytest.mark.skipif( not is_kernels_available(), reason="`kernels` package is required for _flash_3_hub backend. Install with `pip install kernels`.", @@ -86,6 +94,9 @@ id="flash_varlen_hub", marks=[ pytest.mark.skipif(not _CUDA_AVAILABLE, reason="CUDA is required for flash_varlen_hub backend."), + pytest.mark.skipif( + not _IS_SM80_OR_NEWER, reason="An SM80 or newer GPU is required for the flash_varlen_hub backend." + ), pytest.mark.skipif( not is_kernels_available(), reason="`kernels` package is required for flash_varlen_hub backend. Install with `pip install kernels`.", @@ -98,6 +109,9 @@ id="flash_3_varlen_hub", marks=[ pytest.mark.skipif(not _CUDA_AVAILABLE, reason="CUDA is required for _flash_3_varlen_hub backend."), + pytest.mark.skipif( + not _IS_SM80_OR_NEWER, reason="An SM80 or newer GPU is required for the _flash_3_varlen_hub backend." + ), pytest.mark.skipif( not is_kernels_available(), reason="`kernels` package is required for _flash_3_varlen_hub backend. Install with `pip install kernels`.", @@ -114,6 +128,10 @@ not is_kernels_available(), reason="`kernels` package is required for sage_hub backend. Install with `pip install kernels`.", ), + pytest.mark.skipif( + not DIFFUSERS_TRUST_REMOTE_KERNELS, + reason="`DIFFUSERS_TRUST_REMOTE_KERNELS=true` is required for the sage_hub backend.", + ), ], ) @@ -128,6 +146,10 @@ not is_kernels_available(), reason="`kernels` package is required for sage_blackwell_hub backend. Install with `pip install kernels`.", ), + pytest.mark.skipif( + not DIFFUSERS_TRUST_REMOTE_KERNELS, + reason="`DIFFUSERS_TRUST_REMOTE_KERNELS=true` is required for the sage_blackwell_hub backend.", + ), ], ) From 41f2df8f8b895e02db4fe8c0404fe21e672efbd4 Mon Sep 17 00:00:00 2001 From: DN6 Date: Mon, 30 Nov 2026 18:52:07 +0530 Subject: [PATCH 2/2] [CI] Skip `natten` and CLI `flash_hub` tests when the kernel is unavailable --- .../autoencoders/test_models_ltx2_diffusion_decoder.py | 6 +++++- tests/others/test_cli_commands.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/models/autoencoders/test_models_ltx2_diffusion_decoder.py b/tests/models/autoencoders/test_models_ltx2_diffusion_decoder.py index 65fd2e521cce..949541b90adf 100644 --- a/tests/models/autoencoders/test_models_ltx2_diffusion_decoder.py +++ b/tests/models/autoencoders/test_models_ltx2_diffusion_decoder.py @@ -229,7 +229,11 @@ def test_natten_processor_decodes(self): # One shared instance swaps every attention module: the decoder's attention is homogeneous, with # per-stage differences (the kernel size) living on the module rather than the processor. - model.set_attn_processor(LTX2VideoVaeNeighborhoodNattenProcessor()) + try: + processor = LTX2VideoVaeNeighborhoodNattenProcessor() + except FileNotFoundError as e: + pytest.skip(f"`shi-labs/natten` kernel unavailable in this environment: {e}") + model.set_attn_processor(processor) processors = model.attn_processors assert processors and all( isinstance(processor, LTX2VideoVaeNeighborhoodNattenProcessor) for processor in processors.values() diff --git a/tests/others/test_cli_commands.py b/tests/others/test_cli_commands.py index 1cead947496b..d936cdbcdede 100644 --- a/tests/others/test_cli_commands.py +++ b/tests/others/test_cli_commands.py @@ -247,6 +247,10 @@ def test_compile_arg(self): @require_torch # `--attention-backend` only exposes Hub-hosted kernels, all of which need `kernels>=0.12`. @require_kernels_version_greater_or_equal("0.12") + @pytest.mark.skipif( + torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0), + reason="An SM80 or newer GPU is required for the flash_hub backend.", + ) def test_attention_backend_arg(self): from diffusers.models.attention_dispatch import AttentionBackendName