7070 ],
7171)
7272
73+ _PARAM_FLASH_VARLEN_HUB = pytest .param (
74+ AttentionBackendName .FLASH_VARLEN_HUB ,
75+ id = "flash_varlen_hub" ,
76+ marks = [
77+ pytest .mark .skipif (not _CUDA_AVAILABLE , reason = "CUDA is required for flash_varlen_hub backend." ),
78+ pytest .mark .skipif (
79+ not is_kernels_available (),
80+ reason = "`kernels` package is required for flash_varlen_hub backend. Install with `pip install kernels`." ,
81+ ),
82+ ],
83+ )
84+
85+ _PARAM_FLASH_3_VARLEN_HUB = pytest .param (
86+ AttentionBackendName ._FLASH_3_VARLEN_HUB ,
87+ id = "flash_3_varlen_hub" ,
88+ marks = [
89+ pytest .mark .skipif (not _CUDA_AVAILABLE , reason = "CUDA is required for _flash_3_varlen_hub backend." ),
90+ pytest .mark .skipif (
91+ not is_kernels_available (),
92+ reason = "`kernels` package is required for _flash_3_varlen_hub backend. Install with `pip install kernels`." ,
93+ ),
94+ ],
95+ )
96+
7397# All backends under test.
74- _ALL_BACKEND_PARAMS = [_PARAM_NATIVE_CUDNN , _PARAM_FLASH_HUB , _PARAM_FLASH_3_HUB ]
98+ _ALL_BACKEND_PARAMS = [
99+ _PARAM_NATIVE_CUDNN ,
100+ _PARAM_FLASH_HUB ,
101+ _PARAM_FLASH_3_HUB ,
102+ _PARAM_FLASH_VARLEN_HUB ,
103+ _PARAM_FLASH_3_VARLEN_HUB ,
104+ ]
75105
76106# Backends that perform non-deterministic operations and therefore cannot run when
77107# torch.use_deterministic_algorithms(True) is active (e.g. after enable_full_determinism()).
@@ -267,6 +297,8 @@ class AttentionBackendTesterMixin:
267297 Use `pytest -m "not attention"` to skip these tests.
268298 """
269299
300+ unsupported_attn_backends : list [str ] = []
301+
270302 def setup_method (self ):
271303 gc .collect ()
272304 backend_empty_cache (torch_device )
@@ -280,6 +312,8 @@ def teardown_method(self):
280312 def test_set_attention_backend_matches_context_manager (self , backend ):
281313 """set_attention_backend() and the attention_backend() context manager must yield identical outputs."""
282314 _skip_if_backend_requires_nondeterminism (backend )
315+ if backend .value in self .unsupported_attn_backends :
316+ pytest .skip (f"{ backend .value } is not supported for this model." )
283317
284318 init_dict = self .get_init_dict ()
285319 inputs_dict = self .get_dummy_inputs ()
@@ -318,6 +352,8 @@ def test_set_attention_backend_matches_context_manager(self, backend):
318352 def test_output_close_to_native (self , backend , atol = 1e-2 , rtol = 1e-2 ):
319353 """All backends should produce model output numerically close to the native SDPA reference."""
320354 _skip_if_backend_requires_nondeterminism (backend )
355+ if backend .value in self .unsupported_attn_backends :
356+ pytest .skip (f"{ backend .value } is not supported for this model." )
321357
322358 init_dict = self .get_init_dict ()
323359 inputs_dict = self .get_dummy_inputs ()
@@ -378,6 +414,8 @@ def test_compile(self, backend, atol=1e-2, rtol=1e-2):
378414 as opposed to `model.compile`).
379415 """
380416 _skip_if_backend_requires_nondeterminism (backend )
417+ if backend .value in self .unsupported_attn_backends :
418+ pytest .skip (f"{ backend .value } is not supported for this model." )
381419 if getattr (self .model_class , "_repeated_blocks" , None ) is None :
382420 pytest .skip ("Skipping tests as regional compilation is not supported." )
383421
0 commit comments