Repository navigation
DDP tests: drop leaked rank env for the child runs, fail a hung child with its output (rest-2 timeouts) - #18180
Conversation
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0664c02914
ℹ️ 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".
| out = (e.stdout or "") + (e.stderr or "") | ||
| out = out.decode(errors = "replace") if isinstance(out, bytes) else out |
There was a problem hiding this comment.
Normalize timeout output streams before concatenating them
When a timed-out child writes to only one stream, TimeoutExpired contains bytes for that stream and None for the other, even with text=True. Replacing the missing stream with "" then concatenating raises TypeError before decoding or pytest.fail runs, losing the diagnostic output this helper is intended to preserve. This reproduces with both stdout-only and stderr-only children. Decode each stream separately before concatenating, or use byte fallbacks for both streams.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 2c34536: right, TimeoutExpired keeps raw bytes even with text = True and None for a stream that wrote nothing. Each stream is now decoded on its own before joining. Checked with a child that writes only to stdout and one that writes only to stderr: both now reach pytest.fail with their output.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
tests/test_ddp_find_unused_default.py::test_trainable_embeddings_train_under_ddp_reentrant_checkpointinghits pytest-timeout in the CPUrest-2shard on unrelated PRs (#18135, #18165, #18171 today):The test takes about 11 s locally and hung only on some workers, with no child output in the log.
Cause
The test copies
os.environinto both children: the single-process reference and thetorchrunpair. The worker decides it is distributed fromWORLD_SIZE. Several tests write rank variables (RANK,WORLD_SIZE,MASTER_PORT, ...) into the pytest process environment, so on a worker that ran one of them first, the single-process reference seesWORLD_SIZE=2, callsinit_process_group("gloo")and waits for a second rank that never comes. It never returns, and the child'stimeout = 600is longer than pytest-timeout's 330 s, so CI only showed a bare timeout.Reproduced on main by running the file with
WORLD_SIZE=2 RANK=0 MASTER_ADDR=127.0.0.1 MASTER_PORT=29555in the environment: it hangs until killed.Fix
_rank_env(tmp_path)builds the child environment withoutRANK,WORLD_SIZE,LOCAL_RANK,LOCAL_WORLD_SIZE,GROUP_RANK,ROLE_RANK,MASTER_ADDR,MASTER_PORT(torchrun sets its own) and theUNSLOTH_DDP_FIND_UNUSED_PARAMETERS_AUTOoverride the test already dropped._run_childruns each child under a timeout below pytest-timeout (150 s each for the two-step test, 300 s for the single torchrun in the VLM test) and, if one still hangs, fails with the tail of its output instead of a bare timeout.Verification
tests/test_ddp_find_unused_default.py: 63 passed.WORLD_SIZE=2 RANK=0 MASTER_ADDR=127.0.0.1 MASTER_PORT=29555exported: 63 passed (main: hangs).