Repository navigation
[Perf] minimax-h3: Skip attention for the packing's alignment rows in the Ulysses pipeline - #47566
Conversation
… the Ulysses pipeline H3 pads its packed sequence to a multiple of 64 per Ulysses rank, so a 1280x704 request attends cu_seqlens [0, 33002, 33024]. cuDNN SDPA's varlen runs each segment as its own call, so every pipelined head group ran the real rows (FA4 on sm_103, cuDNN on sm_100), a copy into the output, a cuDNN call for the 22 alignment rows and a second copy: with 7 groups per layer that is 28 extra launches and their host work per block. The alignment rows only ever reach their own rows (attention keeps them in their own segment, everything else is row-wise), so the group attention now attends the real rows only, writes them straight into the output when the backend can (FA4), and zeroes the alignment rows. The real rows run the same call as before, so the output is bit-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
/tag-and-rerun-ci |
|
AMD CI jobs started failing after this PR was merged, and the evidence points at this change. test_minimax_h3_dit_contract.py::test_group_attend_skips_only_the_trailing_alignment_rows, added by this PR, is skipped only when CUDA is unavailable; on ROCm it runs, falls back to the FlashAttention path and fails with ModuleNotFoundError: No module named 'flash_attn' (flash_attention_v3.py:239) on the rocm10 and rocm720 lanes. The last passing run was on Failing jobs (2):
If this PR is the cause, a fix or a revert would turn these jobs green again. If it isn't, please say so here so the attribution can be corrected. Posted automatically by amd-bot, the AMD CI monitor. Confidence: HIGH. |
|
@mickqian AMD CI jobs started failing after this PR was merged, and #47971 proposes a fix. Could you review it? test_minimax_h3_dit_contract.py::test_group_attend_skips_only_the_trailing_alignment_rows, added by this PR, is gated only on torch.cuda.is_available(); on ROCm DynamicCudnnSDPAImpl falls back to the FlashAttention path and fails with No module named 'flash_attn' on rocm10, rocm720 and rocm724 in every run since it landed. The last passing run was on Failing jobs (5):
If this PR isn't the cause, please say so here so the attribution can be corrected. Posted automatically by amd-bot, the AMD CI monitor. Confidence: HIGH. |
Reviewed the six upstream minimax_h3.py changes since the last pin (sgl-project#46047, sgl-project#46709, sgl-project#47567, sgl-project#47569, sgl-project#47566 and the BCG output buffers). None touches what h3_comfyui_v1 relies on in its single-GPU eager torch_sdpa profile: DiTBlock.forward is unchanged, _attend still calls fused_inplace_qknorm_rope on the _use_fused_qknorm_rope branch with the same arguments (the new pipelined branch needs Ulysses, which the profile rejects), and _embed still returns (embeddings, t_emb) in eager mode.
…nt rows in the Ulysses pipeline (sgl-project#47566) Co-authored-by: Mick Qian <mickqian@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Motivation
H3 pads its packed sequence to a multiple of 64 per Ulysses rank, so a 1280x704 request attends
cu_seqlens [0, 33002, 33024]. cuDNN SDPA's varlen runs each segment as its own call, so every pipelined head group ran the real rows, a copy into the output, a cuDNN call for the 22 alignment rows and a second copy. With 7 groups per layer that is 28 extra launches and their host work per block.Modifications
test_minimax_h3_dit_contract.py.Accuracy Tests
Bit-identical output: MP4 md5 identical to main in every arm (4/4 on FA4, 4/4 forced-cuDNN).
Speed Tests and Profiling
4x B300 (stand-in for B200), same protocol as the three-waves PR; measured on top of it:
Together with three-waves, the 20-prompt 720p median goes 26.793 -> 26.517 s (-1.03%).
Note: this touches the same H3 pipelined-Ulysses block in
minimax_h3.pyas the ROCm Ulysses-pipeline PR; whichever lands second needs a small rebase.Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #41207111782
Latest PR Test (Extra): ❌ Run #41207111700
Latest PR Test (AMD ROCm 10): ❌ Run #41207111822