Repository navigation
[diffusion] perf: move MiniMax-H3's pipelined Ulysses copies off the SMs - #43361
Merged
Merged
Conversation
…ntion over the copy engine MiniMax-H3's Ulysses exchange around dense attention runs on SMs (an NCCL send/recv for q/k/v, SM copies back), between kernels that keep every SM busy. This adds an opt-in copy-engine transport for same-host Ulysses groups of any size and uses it to pipeline the exchange against attention over head groups: group g's q/k/v copies run on the copy engine while group g-1 attends, each group attends on its own stream and sends its output from there, and stream memory operations order copies and kernels without holding an SM. - SGLANG_DIFFUSION_ULYSSES_PIPELINE_GROUPS=<G> pipelines MiniMax-H3's dense FA attention; G must divide the heads per rank. - SGLANG_DIFFUSION_IPC_A2A_MULTI=1 also routes the plain Ulysses all-to-all through the copy engine. - Falls back to the sequential exchange when a rank lacks peer access or stream memory operations (agreed across the group), during graph capture, under torch.compile, and for other attention backends. The result is bit-identical to the sequential exchange; a 2- and 4-rank test checks it byte for byte. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Ulysses exchange Co-Authored-By: Claude Opus 5.5 <[email protected]>
…put as it arrives Co-Authored-By: Claude Opus 5.5 <[email protected]>
…here it fits Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he 2-GPU suite Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
mickqian
requested review from
AgainstEntropy,
HaiShaw and
yichiche
as code owners
October 9, 2026 10:59
mickqian
requested review from
JustinTong0323,
sogalin,
wisclmy0611 and
zijiexia
as code owners
October 9, 2026 10:59
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Merged
4 of 5 tasks
…copies-off-sm # Conflicts: # docs/cookbook/diffusion/MiniMax/MiniMax-H3.mdx # python/sglang/multimodal_gen/runtime/distributed/device_communicators/ipc_a2a_multi.py # python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py # python/sglang/multimodal_gen/test/single_test_file/test_ipc_a2a_multi_gpu.py
5 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #43164 (merged). The branch carries #43164's original commits and a merge of main, so against main the diff is only this change.
Motivation
After #43164 (and #43327 / #43337), a profile of MiniMax-H3's pipelined Ulysses attention shows almost no exposed exchange left: 0.09–0.24 ms per layer. What remains on the SMs is the exchange's own data movement. Per head group and destination, two PyTorch strided copies run:
That is 28 elementwise copy kernels per layer at Ulysses 2 and 56 at Ulysses 4. Measured alone they move 0.8–1.4 TB/s (read plus write), and inside the pipeline they compete with FlashAttention, which wants every SM. Their SM time per layer, from isolated timings at the real shapes:
Modifications
Every copy of the exchange now runs on the copy engine, as a pitched
cuMemcpy2DAsyncissued next to the stream memory operations it already uses. Nothing moves on the SMs, and the result stays bit-identical: it is pure data movement, and attention sees the same values.[2, groups, 3, world, chunk]. Group g's q, k and v from every rank are each one contiguous[S, group_heads, head_dim]tensor, and attention reads them directly.fill(H3's QK-norm), the fill writes q and k into the send buffer, and one 2-row copy takes both to the peer.fill, q, k and v all move straight from their sources, and the pack kernel is gone.fill(head_start, head_count, q_dst, k_dst)now writes only q and k.Accuracy Tests
test_ipc_a2a_multi_gpu.pypasses at 2 and 4 ranks. It compares against the sequential exchange byte for byte, with and without a fill, including the automatic group count and the head count that must decline.Speed Tests and Profiling
Client end-to-end latency, 4×H200, 50 steps, default quality. These runs sit on top of #43164, #43327 and #43337. The arms ran ABBA on one box (without, with, with, without):
The gain is largest at Ulysses 4, which ran 56 copy kernels per layer against 28 at Ulysses 2. It is below the SM time the copies held, because part of that time overlapped attention tails anyway, and the H200s sit at their 700 W cap, so part of the freed time comes back as a lower clock.
Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #37946366275
Latest PR Test (Extra): ❌ Run #37946365882
Latest PR Test (AMD ROCm 10): ❌ Run #37946366140