[Attention] Add trtllm diffusion attention backend with Skip-Softmax (#5283)

Signed-off-by: lishunyang12 <lishunyang03@gmail.com>
Co-authored-by: lishunyang12 <lishunyang03@gmail.com>
This commit is contained in:
SYLARandlishunyang12 authored and GitHub committed 2026-07-27 22:48:11 +08:00
1 parent 4dd1b47f47
commit 7762d664d8
24 files changed
+1512 -52

No files matched your search

+40
View File
@@ -57,6 +57,7 @@ class CudaOmniPlatform(OmniPlatform, CudaPlatformBase):
cls,
selected_backend: str | None,
head_size: int,
allow_trtllm_default: bool = True,
) -> str:
from vllm_omni.diffusion.envs import PACKAGES_CHECKER
@@ -119,6 +120,18 @@ class CudaOmniPlatform(OmniPlatform, CudaPlatformBase):
# not abort startup — just treat FlashInfer as unavailable.
logger.debug("FlashInfer probe failed (%s); treating as unavailable", e)
# TRTLLM_ATTN needs the trtllm-gen kernel specifically, not just any FlashInfer
# wheel. Probe the actual symbol so a released wheel lacking it does not get
# auto-routed to TRTLLM_ATTN and then crash on the first forward.
trtllm_gen_available = False
if flashinfer_available:
try:
from flashinfer.prefill import trtllm_ragged_attention_deepseek # noqa: F401
trtllm_gen_available = True
except Exception as e:
logger.debug("trtllm-gen kernel probe failed (%s); treating as unavailable", e)
if selected_backend is not None:
backend_upper = selected_backend.upper()
if backend_upper in ("FLASH_ATTN_HUB", "FLASH_ATTN_3_HUB"):
@@ -172,10 +185,37 @@ class CudaOmniPlatform(OmniPlatform, CudaPlatformBase):
"SageAttention/sageattention3_blackwell. Falling back to TORCH_SDPA backend."
)
return DiffusionAttentionBackendEnum.TORCH_SDPA.get_path()
if backend_upper == "TRTLLM_ATTN":
trtllm_attn_supported = compute_capability is not None and compute_capability.major == 10
if not trtllm_attn_supported:
raise ValueError(
"TRTLLM_ATTN diffusion attention backend requires a datacenter "
"Blackwell GPU (SM100 / SM103, compute capability 10.x). Select a "
"different --diffusion-attention-backend."
)
if not flashinfer_available:
raise ValueError(
"TRTLLM_ATTN diffusion attention backend requires flashinfer, which is not installed."
)
backend = DiffusionAttentionBackendEnum[backend_upper]
logger.debug("Using diffusion attention backend '%s'", backend_upper)
return backend.get_path()
trtllm_attn_default_ok = (
allow_trtllm_default
and compute_capability is not None
and compute_capability.major == 10
and head_size == 128
and trtllm_gen_available
)
if trtllm_attn_default_ok:
logger.info(
"Defaulting to diffusion attention backend TRTLLM_ATTN (datacenter Blackwell %s, head_dim %d)",
sm_str,
head_size,
)
return DiffusionAttentionBackendEnum.TRTLLM_ATTN.get_path()
if is_blackwell and cudnn_blackwell_ready:
logger.info(
"Defaulting to diffusion attention backend CUDNN_ATTN (Blackwell %s, cuDNN %d)",