feat: single controller (w/o sync_weight)#2819
Draft
yuki-97 wants to merge 22 commits into
Draft
Conversation
mehraakash
added a commit
to mehraakash/RL
that referenced
this pull request
Jun 16, 2026
Two bugs around the split-API state machine fixed in one pass: 1. **no_sync_func leak (latent assertion on step 2 with PP=1).** `forward_backward_no_pipelining` (the PP=1 path, which is the common one) wraps inner microbatches in `model.config.no_sync_func` but runs the *last* microbatch OUTSIDE of it. Our outer `with self.model.no_sync():` in `train_microbatch` was therefore bypassed for the trailing MB. `register_grad_ready` leaked per-param counts past the explicit DP sync at `finish_train_step`, and the next `begin_train_step` then asserted on the stale counts (typically step 2). Fix: in `begin_train_step` also save and null `no_sync_func` (set to `contextlib.nullcontext`). Restore both hooks at finish/abort via the new `_restore_saved_grad_sync_func` helper. Spotted in yuki-97's PR NVIDIA-NeMo#2819 (`begin_train_step` also nulls `config.no_sync_func`); same fix landed here. 2. **No exception safety around the open step (terrykong, NVIDIA-NeMo#2683:640).** If `train_microbatch` or `finish_train_step` raised mid-body, both `grad_sync_func` and (now also) `no_sync_func` would stay nulled and future steps would run with the PP scheduler bypass disabled silently. Fix: extract `_train_microbatch_body` and `_finish_train_step_body`, wrap each entry method in try/except that calls `_restore_saved_grad_sync_func` before re-raising. Caller is still expected to invoke `abort_train_step` (idempotent on the saved values) to drop `_train_step_state`. 3. **Cleanup (terrykong, NVIDIA-NeMo#2683:582).** Drop dead `no_sync_active` field from `_split_step_state_init` — never read or written; `no_sync` is applied via the `with self.model.no_sync():` context manager. Also: add module-level `log = logging.getLogger(__name__)` so the try/except handlers can `log.exception(...)` if the restore itself fails. Signed-off-by: Akash Mehra <akamehra@nvidia.com>
c1fc94f to
3a55904
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
… reserve/commit slots Signed-off-by: Yuki Huang <yukih@nvidia.com> update unit test Signed-off-by: Yuki Huang <yukih@nvidia.com>
3a55904 to
22b9e48
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
d2b5182 to
98daa14
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
98daa14 to
7976488
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
a049782 to
36c7e50
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
36c7e50 to
44fc9a4
Compare
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
Signed-off-by: Yuki Huang <yukih@nvidia.com>
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.
Summary
Adds the SC (Single Controller) entrypoint for async GRPO on the TransferQueue data plane.
SingleControllerActor(nemo_rl/algorithms/single_controller.py): CPU-only Ray actor with three asyncio pumps._rollout_pump: iterates the dataloader →RolloutManager.generate_and_push→TQReplayBuffer.addwrites N training rows per group. Gated by_buffer_capacity/max_inflight_prompts/_rollout_permitted._train_pump:sampler.evict→sampler.select→_advantage_pump→TQPolicysplit API (begin/train_microbatch/finish_train_step) →dp_client.clear_samples._sync_weights: drain gate + (stubbed)WeightSynchronizer.sync_weights.single_controller_utils/:MasterConfig+AsyncRLConfig;setup()builds the fullSingleControllerBundlevia inlined_build_clusters/_build_generation/_build_trainer.async_utils/:TQReplayBuffer(group-granular, owns producer-side tensorization) +StalenessSampler(filter-only).examples/run_grpo_single_controller.py,examples/configs/grpo_math_1B_single_controller.yaml.begin_train_stepalso nullsconfig.no_sync_funcso the outermodel.no_sync()covers the last MB — otherwiseregister_grad_readyleaks counts past the explicit sync and asserts on step 2.Known limits (TODOs in code)
max_train_stepsnot bounded bymax_num_epochs * len(dataloader).compute_prev_logprobs/compute_reference_logprobsgating is provisional.sampler.selectonly enforcesmin_prompt_groups_per_batch; nomax_*yet._sync_weightsstubbed.Current state
grpo_dp_single_controller.sh, Qwen3-0.6B / 2 GPU / 2 steps).sync_weightsnot wired, generator never refreshes.grpo_train_syncyet.