Repository navigation
[Fix] [AMD] distributed: Fix custom AR capture for DSA DP dual graphs - #36088
Conversation
56f8edc to
b35ab83
Compare
b35ab83 to
d464e7a
Compare
|
@HaiShaw, could you take a look? Thanks! |
|
This PR adds The new copy-in path is HIP-only and only when DP attention is on and the decode attention backend is |
|
@tanth47 ValueError: /sglang-checkout/test/registered/unit/distributed/test_custom_all_reduce_graph_capture_policy.py: missing |
This comment has been minimized.
This comment has been minimized.
Adapt the capture policy to the current attn_dp_enabled parallel field. Use strict test doubles so removed configuration fields cannot silently pass the policy tests.
|
@hubertlu-tw @HaiShaw Merged current main into the branch; the diff is unchanged ( |
|
/tag-and-rerun-ci |
… reduce-scatter The DSA + DP-attention copy-in policy covered custom all-reduce only. The AITER all-gather and reduce-scatter on the same TP group still registered graph inputs during capture, so DP lanes replaying different decode graphs read the other graph's peer buffers. - parallel_state: all-gather and reduce-scatter capture now follow the communicator's enable_register_for_capturing (plus the existing memory-saver and SGLANG_AITER_CAPTURE_COPY_IN switches). - custom_all_reduce: treat the deprecated "nsa" alias like "dsa"; keep direct registration when the exec config is not published instead of raising (which disabled custom AR for the group); log the copy-in decision once in the policy. - Tests: nsa alias, unpublished config, and the all-gather/reduce-scatter capture helper. Verified on 4x MI355X through GroupCoordinator (TP4, DP2 attention, 1 MiB per rank) with two captured graphs replayed by different DP lanes (ranks 0-1 graph A, ranks 2-3 graph B), expecting AR=10, AG chunk r=r+1, RS=10: - Before, --attention-backend dsa: AR=10, AG other-lane chunks=0, RS=3/7. - Before, --attention-backend nsa: AR=3/7, AG other-lane chunks=0, RS=3/7. - This commit, dsa and nsa: AR=10, AG=[1,2,3,4], RS=10. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Registers a 4-GPU AMD test (stage-c-test-4-gpu-amd) that publishes DSA with DP attention, captures two graphs through the TP GroupCoordinator, and replays a different graph on each DP lane. All-reduce, all-gather and reduce-scatter must still return full results. On 4x MI355X the test fails on b14368b (all-gather and reduce-scatter read the other lane's stale buffers) and passes on this branch. Also notes the copy-in capture choice in the dispatch_custom_allreduce docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @tanth47, great root-cause work. I pushed a fix on top (01509f1), so please pull before you push again: AITER all-gather and reduce-scatter now follow the same copy-in choice as all-reduce. They were still registering graph inputs directly, and on 4x MI355X they returned wrong results when DP lanes replayed different graphs. To finish this up: Re-run the GLM-5.2 TP8/DP4 corruption check and TPOT on the new head. All-gather and reduce-scatter now copy too, so the −0.40% needs updating. |
Keep the PR's test footprint to the existing CPU policy tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kevin-mii
left a comment
There was a problem hiding this comment.
[kevin-mii Review Agent] LGTM.
…A DP attention on HIP On HIP every DSA DP-attention rank now replays the same decode variant (the MLP-sync bound) and one target-verify graph, so the copy-in that sgl-project#36088 forced for DSA + DP attention is no longer needed for correctness there. Keep copy-in when the scheduler skips its all-gather (SGLANG_SCHEDULER_SKIP_ALL_GATHER), where ranks still select variants independently, and on CUDA, where kernel-plugin graph variants select from each rank's own lengths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Motivation
Fixes #36071.
On ROCm, DSA with DP attention allows different DP lanes to replay different
decode graphs concurrently. Custom all-reduce direct graph-input registration
assumes something stronger: every rank in the communicator replays the same
captured graph and custom-AR call ordinal in lockstep.
During capture, each custom-AR call embeds a
RankDataslot. Registration thenfills that slot with peer pointers belonging to the same captured-call ordinal.
At replay there is no runtime graph-id handshake. If TP2 lane pairs select
different graphs, each pair reads graph-local buffers that are inactive on the
other ranks. The resulting all-reduce is incomplete and can turn GLM-5.2 logits
into NaN, followed by repeated token ID 0.
This supersedes the earlier shared-memory-pool address-collision hypothesis.
Instrumentation found no pointer-registration ordering, IPC-handle, offset, or
capture-to-registration drift.
Modifications
capture when DSA DP attention is enabled.
backends.
This retains custom-AR itself. Only its graph input staging changes.
Minimal causal proof
Hardware: 8 x AMD MI350X, ROCm 7.2.4, AITER
c16d44b93a528b2a4bfd6d8d3409116d465872a9.A standalone distributed reproducer captures four same-shape BF16 graphs. Each
graph contributes a distinct constant, making stale peer-buffer selection
numerically observable.
The expected skewed global sum is BF16
2080on every rank. Direct modereturns
206,414,624, and832for the four rank pairs. These areexactly the contributions from each active TP2 pair, proving that the other
graphs' peer buffers were not supplying the current inputs. Copy-in returns
2080on all eight ranks.A stronger release/acquire system-scope barrier did not help (8/8 full-model
requests still corrupt), excluding a simple memory-visibility issue.
Full-model accuracy tests
Model/configuration: GLM-5.2-MXFP4, BF16 KV, TP8/DP4/EP8 with DP attention,
TileLang DSA prefill/decode, full decode graphs.
Extended copy-in soak:
concurrent c8 x 4 OSL64 32/32 clean;
Performance
Three matching rounds with AITER prefill + MTP, c4, 4,096 cached + 1,024
fresh, OSL512:
Observed throughput delta: -0.40%, within run-to-run variance from MTP
acceptance length.
Design scope
The patch is the smallest safe production fix. A zero-copy replacement would
require a new runtime protocol that advertises each rank's active graph slot,
or allocator integration that makes every graph produce directly into one
stable registered address. Static same-ordinal peer registration cannot safely
support independently selected graphs.
Checklist
CI States
Latest PR Test (Base): ✅ Run #43779232638
Latest PR Test (Extra): ❌ Run #43779232598
Latest PR Test (AMD ROCm 10): ❌ Run #43779232614
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: