Repository navigation
[rl] Fix generator initialization race condition - #3809
Merged
Merged
Conversation
…build controller: spawn the generators only after the trainer's init settles, so the generator's first HybridEP MoE dispatch does not race the trainer's concurrent init and fault with cudaErrorIllegalAddress (hybrid_ep_backend.cuh:5693). Add an optional per-role generator_model_spec so the generator can use a different MoE comm backend than the trainer (e.g. trainer DeepEP-HT, generator HybridEP). deepep: fall back to deep_ep_cpp for EventHandle when the deep_ep top level omits it (hybrid-ep inference build), so the HT trainer dispatch can build the previous_event deep_ep requires (it asserts previous_event.has_value() and async).
…uencing Revert the generator/trainer different-MoE-backend change (f8eaf1f): - deepep.py: back out the deep_ep_cpp EventHandle import fallback. - controller.py: remove the generator_model_spec config field and its usages (generator now always uses model_spec); restore the FULL-cudagraph flex check to read model_spec directly. Keep the trainer-first spawn sequencing (so a generator's first MoE dispatch does not race trainer init) with simplified comments.
felipemello1
approved these changes
Jun 28, 2026
felipemello1
left a comment
Contributor
There was a problem hiding this comment.
is CI red related to this pr?
tianyu-l
approved these changes
Jun 28, 2026
saforem2
pushed a commit
to saforem2/torchtitan
that referenced
this pull request
Jun 28, 2026
Change the order or initialization to make sure the trainer is fully inited before generator init. If using HybridEP backend, initialization together would cause race condition issue. Need more investigation but this PR unblocks for now
saforem2
added a commit
to saforem2/torchtitan
that referenced
this pull request
Jun 28, 2026
Merged upstream/main 0e88661..390ea37 (3 commits) -- all under experiments/rl/ (weight-sync overlap pytorch#3810, Search R1 chunked loss pytorch#3813, generator init race fix pytorch#3809). ezpz does not import from rl/; model/ parallelize/config/trainer surface byte-identical pre/post merge, so no replays and no distributed smoke needed (import surface unchanged).
wwwjn
added a commit
that referenced
this pull request
Jul 10, 2026
Reverts the initialization reordering from #3809, which spawned the trainer first and moved TorchStore init + policy_version read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read policy_version.
wwwjn
added a commit
that referenced
this pull request
Jul 13, 2026
Reverts the initialization reordering from #3809, which spawned the trainer first and moved TorchStore init + policy_version read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read policy_version.
wwwjn
added a commit
that referenced
this pull request
Jul 13, 2026
Reverts the initialization reordering from #3809, which spawned the trainer first and moved TorchStore init + `policy_version` read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read `policy_version`.
jemitche1
pushed a commit
to jemitche1/torchtitan
that referenced
this pull request
Jul 15, 2026
Change the order or initialization to make sure the trainer is fully inited before generator init. If using HybridEP backend, initialization together would cause race condition issue. Need more investigation but this PR unblocks for now
jemitche1
pushed a commit
to jemitche1/torchtitan
that referenced
this pull request
Jul 15, 2026
pytorch#3871) Reverts the initialization reordering from pytorch#3809, which spawned the trainer first and moved TorchStore init + `policy_version` read before generator spawn. Restores the original ordering: spawn trainer and generators together, then init TorchStore and read `policy_version`.
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.
Change the order or initialization to make sure the trainer is fully inited before generator init.
If using HybridEP backend, initialization together would cause race condition issue. Need more investigation but this PR unblocks for now