Repository navigation
Skip interpreter teardown in the DDP trainable-embeddings worker - #18238
Merged
Merged
Conversation
Member
Author
|
@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. |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
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.
Skip interpreter teardown in the DDP trainable-embeddings worker
tests/test_ddp_find_unused_default.py::test_trainable_embeddings_train_under_ddp_reentrant_checkpointinghas hung onRepo tests (CPU, rest-2)twice: on #12258, and on #18220, whose base is currentmain.Both ranks had finished. They printed
RANK_OKafter writing their results, and then the processes never exited. Locally the whole test takes about 12 s.Cause
After
RANK_OK,tests/_ddp_trainable_embeddings_worker.pycallsdist.destroy_process_group()and returns to normal interpreter teardown. The repo's other gloo workers do not do that.tests/test_tp_native_gloo.py,test_tp_host_input_embedding_gloo.py,test_sharded_load_bnb4_gloo.py, thepp_*_glooworkers and others all:os._exit(0)once results are saved, because interpreter teardown can wedge or abort on a gloo C++ thread after the work is done.This worker predates that pattern. That is the failure seen here: the run is finished, but the process never exits.
I could not trigger the CI hang itself: 48 local torchrun launches, 8 in parallel, all exited 0. So the hang is shown with an injected teardown wedge (see Verification).
Fix
On the distributed path, after
RANK_OK, the worker now does what the other gloo workers do:dist.barrier(), thendist.destroy_process_group();os._exit(0).Nothing before
RANK_OKchanges. That includes the training steps, the result files and the single-process reference run. The test's assertions are unchanged, and a rank that fails beforeRANK_OKstill exits non-zero.Verification
tests/test_ddp_find_unused_default.py: 63 passed.RANK_OKon the distributed path, I injected a thread that never ends, standing in for a teardown thread that wedges.main:hung past 150swith bothRANK_OKlines printed, which is the CI signature.