Support HuggingFace kernels package for native diffusion attention backends (#4926)
Signed-off-by: samithuang <285365963@qq.com> Signed-off-by: Samit <285365963@qq.com>
This commit is contained in:
1 parent
4908b85731
commit
b96bc5ac87
9 files changed
+601
No files matched your search
@@ -121,6 +121,31 @@ class CudaOmniPlatform(OmniPlatform, CudaPlatformBase):
|
||||
|
||||
if selected_backend is not None:
|
||||
backend_upper = selected_backend.upper()
|
||||
if backend_upper in ("FLASH_ATTN_HUB", "FLASH_ATTN_3_HUB"):
|
||||
try:
|
||||
importlib.import_module("kernels")
|
||||
logger.info("Using HuggingFace kernels-backed attention backend '%s'", backend_upper)
|
||||
except ImportError:
|
||||
if backend_upper == "FLASH_ATTN_HUB":
|
||||
logger.warning(
|
||||
"HuggingFace `kernels` library is not available. Falling back to local FLASH_ATTN."
|
||||
)
|
||||
backend_upper = "FLASH_ATTN"
|
||||
elif backend_upper == "FLASH_ATTN_3_HUB":
|
||||
logger.warning(
|
||||
"HuggingFace `kernels` library is not available. Falling back to local FLASH_ATTN."
|
||||
)
|
||||
backend_upper = "FLASH_ATTN"
|
||||
|
||||
if backend_upper == "FLASH_ATTN_3_HUB":
|
||||
fa3_hub_supported = compute_capability is not None and compute_capability.major >= 9
|
||||
if not fa3_hub_supported:
|
||||
logger.warning(
|
||||
"FLASH_ATTN_3_HUB requires a Hopper-class GPU with compute capability >= 9.0. "
|
||||
"Falling back to FLASH_ATTN_HUB."
|
||||
)
|
||||
backend_upper = "FLASH_ATTN_HUB"
|
||||
|
||||
if backend_upper == "FLASH_ATTN" and not flash_attn_supported:
|
||||
if not compute_supported:
|
||||
logger.warning(
|
||||
|
||||
Reference in new issue
Block a user