Fix SDMA AllReduce corruption across HIP graph replays - #559
Open
hubertlu-tw wants to merge 2 commits into
Open
Conversation
Use fixed-stride protected scratch and graph-safe synchronization so changing message sizes cannot expose stale SDMA data.
Contributor
|
Thanks for the great work! wait_async() may race when using a different stream from start_async(). Could we add stream synchronization and a cross-stream test? |
Record completion on the start stream so wait_async can safely continue on another stream, with graph replay coverage for the dependency.
Author
@wuyl1 Thank you for reviewing the PR. I have refactored the PR and added stream synchronization and a cross-stream test. Notice that I haven't added the tests I created to mori's nightly CI. All the tests were run locally on my MI355x server. |
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.
Motivation
AllreduceSdmacould return stale data when one communicator replayed graphs with different message sizes. The reduce-scatter layout used message-dependent rank offsets, so an address written by a CU reduction in one graph could become an SDMA receive slot in another. On gfx950, that role change could expose stale cache lines and corrupt an entire rank shard.This matters for inference runtimes that capture several batch-size or token-count buckets and reuse the same communicator across them.
Changes
start_async;wait_asynconly performs copy-out and completion.wait_asyncstream after thestart_asyncstream with a graph-capturable HIP event.copy_output_to_user=Falseargument while always returning results through the caller-provided output.Validation
All tests below passed on gfx950.
The graph tests capture every size before replay, change input values on each operation, and cover one-shot/two-shot transitions plus compact-output reuse.
Additional checks:
uint32.copy_output_to_user=False.start_asyncon a side stream andwait_asyncon the capture stream.Reproduction
Run the following commands from the repository root after installing the package:
Performance
Measurements use BF16, 20 warmups, 100 measured iterations, five repetitions, and rank-averaged device-event timing. The baseline always uses separate ReduceScatter and AllGather kernels. The PR uses the new one-shot kernel through 1 MiB and the protected two-shot path for larger messages. Negative changes are improvements. PR measurements were refreshed after adding cross-stream event ordering. The 1 MiB graph and 64 MiB eager rows use isolated reruns because the full sweeps contained scheduler outliers.
TP=2
TP=4
TP=8
Cross-stream event overhead
The TP=4 async modes were also compared against the saved pre-event PR run using the same benchmark protocol. Graph replay shows no meaningful regression. Eager async adds approximately 3–5 us at 16 MiB and above, consistent with recording the completion event before the host-side wait.
Trade-offs
(TP + 1) / TPtimes that size: 192 MiB at TP=2, 160 MiB at TP=4, and 144 MiB at TP=8 for a 128 MiB maximum.copy_output_to_user=Falseremains source-compatible but no longer suppresses copy-out.