Skip to content

[rl] Fix generator initialization race condition - #3809

Merged
tianyu-l merged 3 commits into
mainfrom
deepep-ll-cudagraph-2
Jun 28, 2026
Merged

tianyu-l merged 3 commits into
mainfrom
deepep-ll-cudagraph-2

Conversation

@wwwjn

@wwwjn wwwjn commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

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

wwwjn added 3 commits June 26, 2026 23:23
…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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 27, 2026

@felipemello1 felipemello1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is CI red related to this pr?

@tianyu-l
tianyu-l merged commit abaf11c into main Jun 28, 2026
12 of 19 checks passed
@tianyu-l
tianyu-l deleted the deepep-ll-cudagraph-2 branch June 28, 2026 08:05
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants