Skip to content

Gloo two-rank precision test: bounded collectives, captured rank output, kill on timeout - #19044

Merged
danielhanchen merged 1 commit into
mainfrom
fix/gloo-two-rank-test-bounded
Nov 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/gloo-two-rank-test-bounded

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

(Python 3.13, diffusion) intermittently fails studio/backend/tests/test_diffusion_ddp_effective_precision.py::test_real_gloo_two_ranks[fp8,fp8-SAME] with subprocess.TimeoutExpired after 180 s, for example the staging run for #19024 on a base that already has #19027. Locally the test takes about 1.4 s per case, so this is a hang, not a slow runner.

The log has nothing to go on: the two ranks' stderr is not captured, a rank stuck in a Gloo collective waits out Gloo's 30 minute default, and on timeout the children are left running.

Change

studio/backend/tests/test_diffusion_ddp_effective_precision.py only; no product code changes, and the checks are the same.

  • Child: init_process_group(..., timeout=timedelta(seconds=60)), so a stuck collective raises inside the rank with its own error instead of hanging.
  • Parent: each rank writes stdout and stderr to files under tmp_path instead of pipes, so one rank cannot block on a full pipe while the other is being waited on.
  • Both ranks share one 180 s deadline. On expiry both are killed and the test fails with each rank's return code, stdout and stderr, so the next occurrence names the stuck rank and where it was.
  • A nonzero exit also reports both ranks' output.

This bounds the hang and makes it diagnosable; it does not claim a root cause, since no failing run has captured the ranks' output yet.

Testing

  • The file: 13 passed, also under -n 2.
  • Sabotage, rank 1 stalled before init_process_group (deadline shortened for the check): the test fails after the deadline with rank 0 rc=-9 / rank 1 rc=-9 and both outputs, and no child process is left behind.
  • Sabotage, rank 1 exits right after init: rank 0 reports the closed connection and the test fails on the verdict within seconds.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T10:31:33.774448Z 3ec9505 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 3ec950525b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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
danielhanchen merged commit 9709f21 into main Nov 23, 2026
@danielhanchen
danielhanchen deleted the fix/gloo-two-rank-test-bounded branch November 23, 2026 10:32
danielhanchen added a commit that referenced this pull request Nov 23, 2026
…er teardown (#19070)

## Summary

`(Python 3.13, diffusion)` still occasionally fails
`studio/backend/tests/test_diffusion_ddp_effective_precision.py::test_real_gloo_two_ranks`.
With the diagnostics from #19044, the latest occurrence (the staging run
for #18925, on a base that has #19044) says where it hangs:

```
Failed: the two Gloo ranks did not finish within 180 s:
rank 0 rc=0
stdout:
[Gloo] Rank 0 is connected to 1 peer ranks. Expected number of connected peer ranks is : 1
REFUSED Multi-GPU training stopped: the GPUs ended up training different base precisions after conversion (rank 0: fp8, rank 1: bf16). ...
rank 1 rc=-9
stdout:
[Gloo] Rank 1 is connected to 1 peer ranks. Expected number of connected peer ranks is : 1
REFUSED Multi-GPU training stopped: the GPUs ended up training different base precisions after conversion (rank 0: fp8, rank 1: bf16). ...
```

## Root cause

The test's child script, not `diffusion_ddp`. Both ranks run the
precision check and print the correct verdict; rank 0 then exits, and
rank 1 never does: it hangs at interpreter exit, in the teardown of a
Gloo process group whose peer has already gone. The child never leaves
the group itself. The trainer does not have this problem:
`DistContext.close()` destroys the group on a bounded thread for exactly
this reason ("a communicator whose peers already exited must not hold up
the trainer child").

## Fix

`studio/backend/tests/test_diffusion_ddp_effective_precision.py` only.
After printing its verdict, each rank:

- waits at `dist.barrier()` (bounded by the 60 s group timeout from
#19044), so neither rank leaves while the other is still in the group,
- calls `dist.destroy_process_group()`,
- flushes and leaves with `os._exit(0)`, skipping interpreter teardown.

An exception anywhere before that still propagates and gives a nonzero
exit, which the parent reports with both ranks' output.

## Testing

- The file: 17 passed, three runs in a row, and under `-n 2`.
- The hang does not reproduce on a quiet host (each case takes about 1.5
s here), so the evidence for the cause is the rank report above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant