Repository navigation
Diffusion DDP tests: rendezvous through a FileStore, not a port picked up front (intermittent diffusion-shard timeout) - #18885
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
that referenced
this pull request
Nov 22, 2026
…tuck rank stack (all-reduce timeout) (#18908) ## Summary `studio/backend/tests/test_diffusion_ddp.py::test_all_reduce_averages_grads_and_loss_and_flags` still times out now and then after #18885. It failed again on the Imagineer99 staging run for #18900, on base `da4430f`, which includes #18885. That run settles what #18885 got wrong: both ranks print `[Gloo] Rank N is connected to 1 peer ranks` before the hang, so the rendezvous works and a port race was not the cause. (The `FileStore` rendezvous from #18885 is still fine to keep.) The ranks stall after connecting, and pytest-timeout then kills the test with only the parent's `p.wait()` stack in the log, so nothing says where. I could not reproduce it here: 24 runs, 12 at a time, all passed in about 10 s each. ## Changes (test harness only) - Each spawned rank calls `dist.destroy_process_group()` on the way out, as the real workers do in `DistContext.close()`. The children used to exit with a live gloo group, and that teardown at interpreter exit is the most likely place for an intermittent stall. - Each rank arms `faulthandler.dump_traceback_later(240, exit = True)`, below the 330 s pytest-timeout. If a rank is still running at 240 s it prints every thread's stack and exits non-zero, `_spawn`'s exit-code assert fails, and the log says exactly where it was stuck. If this does not remove the flake, the next failure is self-diagnosing. ## Testing - `studio/backend/tests/test_diffusion_ddp.py`: 22 passed. - Sabotage: with rank 1 made to sleep and the dump window shortened to 8 s, the test fails in 19 s with `assert [1, 1] == [0, 0]` and both ranks' stacks, pointing at the line in `_child_grads` where each was waiting.
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.
Summary
(Python 3.13, diffusion)fails intermittently on unrelated PRs with the same test:It is the failing test in 3 of the last 6 failed Backend CI runs (
studio-wan-vae-2frame,audio-cpp-accelerator-chosen-install,perf/r37-translate-history-memo) and on #18851 and #18702.The test (from #18771) spawns two gloo ranks and joins them through a
TCPStoreon a port that_port()found free by binding and closing a socket in the parent. The port is only bound for real later, by rank 0 in its own process, after torch has imported. Under xdist another worker can take that port in the meantime. Rank 0 then fails to bind, rank 1 waits out the store's 300 s timeout, and pytest-timeout kills the test at 330 s. In the failing logs only one of the spawned pairs ever prints the gloo "connected to 1 peer ranks" lines.Fix
The two spawned ranks rendezvous through a
FileStorein a fresh temp directory per spawn (same 300 s store timeout), so there is no port to race for.diffusion_ddp's gate only usesstore.set/store.wait, whichFileStoreprovides. Production code is unchanged; this is the test harness only.Testing
studio/backend/tests/test_diffusion_ddp.py: 22 passed, including the gradient all-reduce and the two-ranktrainspawns.