Fix stream race in dispatch/combine with deterministic algorithms#600
Open
ccs668899 wants to merge 1 commit intodeepseek-ai:mainfrom
Open
Fix stream race in dispatch/combine with deterministic algorithms#600ccs668899 wants to merge 1 commit intodeepseek-ai:mainfrom
ccs668899 wants to merge 1 commit intodeepseek-ai:mainfrom
Conversation
Add stream_wait(comm_stream, compute_stream) after torch::empty() allocations and before kernel launches in all four dispatch/combine functions. When fill_uninitialized_memory=True, torch::empty() enqueues a NaN-fill kernel on compute_stream after the initial stream_wait snapshot, causing a write-write race with the communication kernel on comm_stream. The second sync captures these fill kernels. Add regression test with 4-config control matrix.
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.
The cause of #589 so far as I can tell is as follows in
deep_ep.cpp:Now this could be fixed by putting the stream wait until after the empty allocation, but we have the comment
"NOTES: do not allocate tensors upfront!". I don't want to mess up the stream ownership so I just add a second sync stream wait right before the intranode combine:The tests should deterministically catch the bug once the fix is in. I don't have a multi-GPU setup on hand to validate myself, any recommendations?