[diffusion] perf: pipeline MiniMax-H3's Ulysses exchange against cuDNN SDPA on Blackwell (#43373)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mick
2026-10-10 12:58:30 +08:00
committed by GitHub
co-authored by Mick Qian Claude Opus 5.5
parent 1814ece57f
commit ccae3b3639
2 changed files with 15 additions and 5 deletions
@@ -682,6 +682,14 @@ def _minimax_h3_bind_attention_backend(
)
# FlashAttention on Hopper and cuDNN SDPA on Blackwell give a head group the
# same bytes as those heads inside the full call (checked at H3's shapes)
_PIPELINED_ATTENTION_BACKENDS = (
AttentionBackendEnum.FA,
AttentionBackendEnum.DYNAMIC_CUDNN_SDPA,
)
def _minimax_h3_pipelined_dense_attention(
attention: MiniMaxH3Attention,
q: torch.Tensor,
@@ -693,18 +701,20 @@ def _minimax_h3_pipelined_dense_attention(
max_seqlen: int,
fill=None,
) -> torch.Tensor | None:
"""Dense FA with the Ulysses exchange pipelined over head groups.
"""Dense attention with the Ulysses exchange pipelined over head groups.
Returns None (caller keeps the sequential exchange) unless head-group
pipelining is enabled and the dense FlashAttention path would run.
pipelining is enabled and a dense backend that runs a head group exactly
as it runs those heads in the full call would serve it.
"""
groups = envs.SGLANG_DIFFUSION_ULYSSES_PIPELINE_GROUPS
if groups in (0, 1) or torch.compiler.is_compiling():
return None
if attention._attention_backend_enum is not AttentionBackendEnum.FA:
if attention._attention_backend_enum not in _PIPELINED_ATTENTION_BACKENDS:
return None
impl = attention._attention_impl
if impl._request_skip_softmax_threshold()[0]:
skip_softmax = getattr(impl, "_request_skip_softmax_threshold", None)
if skip_softmax is not None and skip_softmax()[0]:
return None
from sglang.multimodal_gen.runtime.distributed.device_communicators.ipc_a2a_multi import (
ulysses_pipelined_attention,