MCPcopy
hub / github.com/huggingface/transformers / require_flash_attn

Function require_flash_attn

src/transformers/testing_utils.py:671–687  ·  view source on GitHub ↗

Decorator marking a test that requires Flash Attention. These tests are skipped when Flash Attention isn't installed.

(test_case)

Source from the content-addressed store, hash-verified

669
670
671def require_flash_attn(test_case):
672 """
673 Decorator marking a test that requires Flash Attention.
674
675 These tests are skipped when Flash Attention isn't installed.
676
677 """
678 flash_attn_available = is_flash_attn_2_available()
679 kernels_available = is_kernels_available()
680 try:
681 from kernels import get_kernel
682
683 get_kernel(FLASH_ATTN_KERNEL_FALLBACK["flash_attention_2"])
684 except Exception as _:
685 kernels_available = False
686
687 return unittest.skipUnless(kernels_available | flash_attn_available, "test requires Flash Attention")(test_case)
688
689
690def require_kernels(test_case):

Callers

nothing calls this directly

Calls 3

get_kernelFunction · 0.90
is_kernels_availableFunction · 0.85

Tested by

no test coverage detected