Repository navigation
feat(single-controller): vLLM rollout-only simulator (no_op train backend) - #4914
Conversation
Signed-off-by: Shiki Wu <[email protected]>
…e data_plane.enabled Signed-off-by: Shiki Wu <[email protected]>
shikicloud
left a comment
There was a problem hiding this comment.
This PR adds examples/run_single_controller_simulator.py with --mode rollout_only: an SC recipe's rollout side (vLLM generation, the environments, the TransferQueue data plane) runs for real on the same pumps, sampler and refit lifecycle as a training run, while a CpuTrainer holds --train-time-s where the train step would run and a NoOpWeightSynchronizer runs the refit pause and resume for --refit-time-s without moving weights; the rollout-only smoke is wired into the L1 SC lane. The seams are clean: the trainer factory keeps one return shape for both trainers (setup.py#L1867-L1885), the no-op synchronizer implements every abstract member of the weight-sync ABC, the simulated train step is one awaited call inside the controller's existing timer (single_controller.py#L3649-L3654), simulator validation runs at the setup choke point before any engine starts (setup.py#L1196-L1197), and CpuTrainer is unit-tested against the in-process data plane with no Ray or GPU (test_simulator.py#L293).
Before marking the PR ready for review
- CI label. The PR is a draft with no
CI:*label. AddCI:L1: the new smoke is wired into the L1 SC lane (L1_Functional_Tests_SingleController_1.sh#L44-L46), functional lanes run only atCI:L1and above (cicd-main.yml#L194), and the quality-check job stays red until a label is attached (#L1130-L1141). The PR also edits the SC train loop (single_controller.py#L3864-L3872). A vetter then posts/ok to test a348e01f05d5ae57b4aabd71880b373ab8501a4f. - Rebase. A merge against main (6e68b17) conflicts in
nemo_rl/algorithms/single_controller_utils/setup.pyandtests/unit/single_controller/test_setup.py. Main commits since the base that touch those files: #4818, #4200, #4245, #4124, #3321, #4684, #4712, #3964, #4551. Others that auto-merge but touch PR files: #4919, #4812, #4730, #4473, #4728, #4769, #4859, #4857. After the rebase, re-run test_simulator.py, test_setup.py, test_entrypoint.py and the smoke. - PR template (PULL_REQUEST_TEMPLATE.md). "Issues" should read "Part of #4860 (rollout_only only; train_only and the cpu rollout backend stay open)", not "Closes", as the guide itself says (single-controller.md#L451). "Usage" is the command from the guide (#L434-L437) plus the smoke invocation. Tick the pre-checks and say which tests ran locally and on what hardware; the smoke needs GPUs (
cluster.gpus_per_node=2). #4814 is the legacy-path driver this was modeled on; it is unmerged and this PR does not depend on it. - One real run. The PR adds a measurement tool and changes no numerics, and the body carries no numbers. Please paste 3–4 steps of
timing/train/total_step_time,train/simulated_train_time_s,train/simulated_train_idle_skipped_s,timing/train/weight_sync,train/max_seq_mult_prob_error(expected exactly 1.0) andtrain/reward, with the--train-time-sand--refit-time-sused. Keys: single_controller.py#L3869-L3870 under thetrain/prefix (#L3939-L3941); the step timer (#L3050) and thetiming/trainprefix (#L3948-L3952); theweight_synctimer (#L3819). That lets a reader check the guide's claim that the e2e step time istotal_step_time + simulated_train_idle_skipped_s(single-controller.md#L444) and the quantities the smoke gates on (#L117-L121).
Rebase notes (not blockers)
- #4975 made
grpo.max_num_epochs: nullmean "no epoch limit" (grpo.py#L360 on main) and main's SC loop honours None.apply_simulator_overridesturns an explicit null intonum_stepsepochs. Harmless, but the comment "The recipe may omit max_num_epochs and take the schema default" goes stale, and"max_num_epochs" in algowould tell an omitted key from an explicit null (see C20). - #4200 adds SC checkpoint and resume on the paths C3 touches; the
checkpointing.enabled=falserejection must survive the merge. - On main, setup reads
trainer.worker_groupandtrainer.sharding_annotationswhentoken_capture.forest_trainingis on (setup.py#L2280-L2285 on main, #L2311-L2318). After the rebase a forest-training recipe dies in setup onCpuTrainer.worker_groupwith "CpuTrainer has no worker group" and no hint why;validate_simulator_configshould rejecttoken_capture.forest_trainingas a trainer-side feature. Main's SC driver also callsmaterialize_vllm_video_config(config.policy, config.data)after the MasterConfig build (run_grpo_single_controller.py#L112 on main); the simulator driver should mirror it.
Review environment
Seven agents reviewed head a348e01. The review host had no gh or GitHub token, no GPU, and the repo's Python pin (3.13.14) could not be installed, so no test was executed: every suggested test is marked "not verified". The pinned ruff hooks (uvx [email protected] check, isort and format) pass on all 10 PR Python files; pre-commit's pyrefly step and CI's zero-error whitelist check could not be run locally. No CI has run on this draft.
Inline comments
Medium: C1 is_eval=True also turns on vLLM detokenization, so the measured engine is not the training engine.
Low: C2 reject vllm_cfg.load_format: dummy at setup; C3 refuse to resume from a populated checkpoint directory; C4 the guide's gen_kl_error sentence; C5 the guide's "recipe above" pointer; C6 the guide's "every node serves generation" sentence; C7 the observability docs' launcher lists; C8 derive the mode and backend tuples with get_args; C9 import the logprob column names from schema.py; C10 drop train_backend; C11 and C12 gate the simulated train step and its metrics on uses_cpu_trainer; C13 share the inference-sizing block with _build_clusters; C14 the train_fields annotation, with a trainer Protocol as a follow-up; C23 and C24 two more signature drifts from TQPolicy.
Tests: C15 and C16 a main() fixture with two tests and its import; C17 a ragged-rows copy test; C18 a smoke gate that can fail; C19 drop the dead validation dataset from the smoke; C20 the omitted-epoch branch test; C21 pump-level tests for the simulated train step; C22 a test for C2's guard.
Devil's advocate pass: 24 comments posted after 5 drops or disputes (the getattr on the simulator field, the is_trajectory_collection pop, the shard-death log line, the moved call-site defaults, --train-time-s guidance) and 3 downgrades (the idle-node warning became a docs sentence, the trainer Protocol became a follow-up, the observability docs ask was trimmed to two targets).
Generated by Claude Code
…nly-simulator Signed-off-by: Shiki Wu <[email protected]> # Conflicts: # nemo_rl/algorithms/single_controller_utils/setup.py # tests/unit/single_controller/test_setup.py
Signed-off-by: Shiki Wu <[email protected]>
…imulator driver Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shiki Wu <[email protected]>
…nly-simulator Signed-off-by: Shiki Wu <[email protected]> # Conflicts: # nemo_rl/algorithms/single_controller.py # nemo_rl/algorithms/single_controller_utils/setup.py
…4/C23/C24) Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shiki Wu <[email protected]>
shuyixiong
left a comment
There was a problem hiding this comment.
One docstring correction on the simulator hold (C28).
Generated by Claude Code
shuyixiong
left a comment
There was a problem hiding this comment.
A non-blocking follow-up on driver and controller placement in simulator runs (C32).
Generated by Claude Code
… docstrings and the head-node caveat in the guide Signed-off-by: Shiki Wu <[email protected]>
…cover non-Megatron and load failure - Submit build_tasks["trainer"] for the held-back trainer and for the rebuild, so a replacement task (open PR #4914's stand-in) is not skipped. - The "overlapped with ..." log line no longer claims the trainer overlapped the load. - Comments follow the repo rule: no timing on the constant, no "read lazily" claim, one line inside the function body. - Tests: the overlap test now uses a wait longer than the load's own wait, so it fails if a non-Megatron trainer is ever held back; a new test covers a dataset load that fails while a Megatron trainer waits (the trainer is never built and Gym is shut down). Signed-off-by: sniverty <[email protected]>
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
… merging main Signed-off-by: Shiki Wu <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Partial review: nemo_rl/algorithms/single_controller_utils/ and nemo_rl/algorithms/single_controller.py have not been reviewed yet.
Thanks for adding rollout-only profiling on the SingleController path while keeping real generation and environments. The GB200 comparisons and curves are helpful, and thanks for the thorough self-review.
Scope: Entrypoints, documentation and functional-test checks at 1749900. Review of the controller implementation and its utility modules is deferred.
Remaining comments
- Rebase on main and preserve dedicated-head controller placement in the simulator launcher.
- Keep simulator settings in a separate YAML loaded alongside the training recipe.
- Move the simulator section into
docs/guides/single-controller-simulator.md, register it in the docs index, and leave a short link in the main guide. - Correct the documented router placement, conditional logprob metric and simulator-only forest restriction.
nit
- Share the entrypoint execution pipeline through
single_controller_utils/entrypoint_utils.pyand move watchdog configuration and liveness helpers intosingle_controller_utils/watchdog.py. - Add simulator entrypoint wiring coverage and strengthen the functional check to require six steps and the configured refit delay.
- Shorten the two long comment blocks in the simulator entrypoint.
Validation: Static inspection only; unit, functional and GPU tests were not run in this pass.
Generated by Codex (#4999 version)
…nly-simulator Signed-off-by: Shiki Wu <[email protected]> # Conflicts: # docs/guides/single-controller.md # examples/run_grpo_single_controller.py # nemo_rl/algorithms/single_controller_utils/utils.py # tests/unit/single_controller/test_entrypoint.py
… settings to YAML Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test b573ad5 |
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test 852ea14 |
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test d4bc0dd |
…nly-simulator Conflict in examples/run_grpo_single_controller.py: main reworded one comment in the setup code this branch moved to single_controller_utils/entrypoint_utils.py. Kept the branch's file and carried the comment change over. Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test b214793 |
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test daee763 |
There was a problem hiding this comment.
- Merge conflicts: the PR conflicts with
main. Please rebase and resolve them first. - Thanks for building the rollout-only simulator on the real SC pumps and data plane. The GB200 side-by-side and the thin shared launcher (
run_single_controller) make it easy to trust and reuse. KeepingNoOpWeightSynchronizeron theWeightSynchronizerABC means drift there is caught at construction — please keep that. - This review adds two items on top of Yuki's round-2 threads (checked at
daee7636):- (C33)
simulator.num_nodesis applied after the config is resolved, so keys computed fromcluster.num_nodeskeep the recipe's value. - (C35) the
load_format: dummyerror names the wrong fix for recipes that set it themselves.
- (C33)
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4914-sim-vs-training.html
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4914-num-nodes-order.html
Generated by Claude Code
terrykong
left a comment
There was a problem hiding this comment.
One naming nit on top of my earlier review: (C36) rename the train_backend value cpu to no_op.
Generated by Claude Code
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
…esolves Review round on NVIDIA-NeMo#4914 (C33, C35, C36): - simulator.num_nodes was written onto the resolved config dict, so keys the recipe computes from cluster.num_nodes (data_plane.simple.num_storage_units, Gym's num_processes) kept the recipe's node count. It is now set on the OmegaConf object before resolving, as a cluster.num_nodes override is. - The load_format='dummy' error names the fix (set load_format=auto) instead of telling the user to drop an override the recipe may have set itself. - Rename the train_backend value cpu to no_op, matching NoOpTrainer and NoOpWeightSynchronizer. Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test 50ff5c8 |
…t-only-sglang Carries the NVIDIA-NeMo#4914 review fixes (simulator.num_nodes applied before the recipe resolves, cpu -> no_op). SGLang's num_gpus sizing moves with the node count into apply_simulator_node_count. Signed-off-by: Shiki Wu <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main and resolve conflicts.
Thanks for resolving the comments from the previous round.
Scope: fix commits f5020a6 through 50ff5c8, checked against the open threads from the previous review, plus a scan of the changed files for new issues.
Checked:
- The shared train pump on a rollout-only run — selection, cleanup of the consumed rows, buffer release, the version advance and the refit are the training code, and no configuration that setup accepts reaches a trainer method
NoOpTrainerlacks. - Training runs — with
simulator=Noneevery new branch insingle_controller.py,setup.py,tq_policy.pyandvllm_worker.pyreduces to the code on main, and the shared launcher matches main's training launcher statement by statement. - The trainer-side initial-weights rejection — each of the three selectors is read in the form the Megatron loader reads, before setup copies the checkpointing alias into the policy config.
- CI at 50ff5c8 — the rollout-only smoke ran its six steps in the fast SingleController lane, and the new unit tests passed.
Remaining comments:
- The
token_capture.forest_trainingcheck after main's rename. - An unused
NoOpTrainer.cfgand an unreachable early return.
nit
- Keyword arguments for one test config.
nemo-rl-review: kind=expert harness=claude-code/2.1.335 model=claude-fable-5-2 effort=medium review-pr-team=v3 reviewed=50ff5c8
…nly-simulator Signed-off-by: Shiki Wu <[email protected]>
…mulator code - validate_simulator_config reads token_capture.forest.enabled (renamed on main by NVIDIA-NeMo#5068) and names it in the message. - NoOpTrainer no longer takes or holds policy_config; nothing reads it. - Drop the unreachable uses_no_op_trainer early return in validate_simulator_config. - Build the on_policy_distillation test config with keyword arguments. Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test 31a42f4 |
One conflict, in nemo_rl/algorithms/single_controller_utils/setup.py: main adds the simulator checks (NVIDIA-NeMo#4914) after validate_single_controller_config, on the line where this branch calls validate_shared_prefix_config. The merge keeps both, the call of this branch first. Signed-off-by: Jorge Albericio <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
What and why
Implement vLLM as the rollout backend of a single-controller simulator (rollout-only mode) for #4860, inspired by #4814.
examples/run_single_controller_simulator.pyruns an SC recipe's rollouts exactly as training would, with a GPU-free trainer stand-in (mode: rollout_only). It is the SingleController counterpart of #4814 (legacy path, TRT-LLM), built on the SC pumps, TransferQueue data plane, sampler and refit lifecycle.The launcher takes two YAML files:
--configis the SC recipe, used as-is, and--simulator-config(defaultexamples/configs/simulator/rollout_only.yaml) holds the simulator keys. In the recipe the launcher overridesmax_num_steps(raisingmax_num_epochswith it so the step count is reachable) and the node count (from the simulator config'snum_steps/num_nodes),data.validationandvllm_cfg.load_format(defaults toautoso the engine loads the real checkpoint;dummyis rejected). The engine is configured exactly as the training entrypoint configures it, so it does the same per-token work as an engine beside a trainer.Design
NoOpTrainerreplacesTQPolicy: it bootstraps TQ and answers only what the shared step close and refit path ask of a trainer (data-plane metrics, a no-op pre-refit sync). No trainer-side stage runs: the train pump skips logprob evaluation, training-mask filtering, the advantage stage and microbatch training, sotrain/reward,train/advantages/*andtrain/max_seq_mult_prob_errorare absent; the reward of the generated rollouts istrain/unfiltered_reward.NoOpWeightSynchronizerreplaces the transport:is_staleis False,sync_weightsholdsrefit_time_sinside the generation pause so the refit bubble can be sized like a real transfer.setup_single_controller(simulator=...): every node is an inference node, no train cluster, nocreate_weight_synchronizer._train_pumpconsumes each selected chunk, then awaitssimulate_train_step(single_controller_utils/simulator.py) where the optimizer step would run: one hold oftrain_time_safter all chunks arrive, ended early once nothing is generating (polled every 50 ms), logged astrain/simulated_train_time_sandtrain/simulated_train_idle_skipped_s. Cleanup of the consumed rows, buffer release, the version advance and the refit pause/resume are the training code. e2e step time =total_step_time + idle_skipped._sync_weights,generation_router,generation_fleet_health, stall watchdog and token capture are untouched and stay available.SimulatorConfig(pydantic,extra="forbid") is the schema of the simulator YAML, withmodeandtrain_backendlimited to the implemented values;simulator.<key>=<value>on the command line overrides it.SingleControllerActorArgs.simulatordefaults toNone, so training runs are unchanged.run_single_controllerinsingle_controller_utils/entrypoint_utils.py(config load, Ray startup, setup, dedicated-head placement of the controller, liveness watch, cleanup).WatchdogConfigand the liveness watch live insingle_controller_utils/watchdog.py.docs/guides/single-controller-simulator.md.Rejected at setup: PPO, non-vLLM generation backends, Dynamo serving, checkpointing, trainer-side initial weights (
pretrained_checkpoint, PEFTrestore_from), OPD,token_capture.defer_routed_experts_to_policy,token_capture.forest.enabled, refittable fp8 KV caches, adaptive-ppo-clip, online quantization, quantized GPT-OSS and FP8 Mistral3 checkpoints (they only start from dummy weights that a refit fills in),async_rl.log_full_train_data,async_rl.refit_actorandasync_rl.trainer_warmup.Usage
uv run python examples/run_single_controller_simulator.py \ --config <SC recipe> \ --simulator-config examples/configs/simulator/rollout_only.yaml \ simulator.num_steps=6 simulator.num_nodes=1 \ simulator.train_time_s=15 simulator.refit_time_s=3 \ policy.model_name=Qwen/Qwen3-0.6B # recipe overrides pass through # <SC recipe>: any recipe that runs under examples/run_grpo_single_controller.py. # Runnable example with a NeMo-Gym recipe and its SC overrides, the CI smoke (L1 SingleController lane): bash tests/functional/grpo_async_gym_single_controller_rollout_only.shMetrics to watch:
train/simulated_train_time_s,train/simulated_train_idle_skipped_s,timing/train/weight_sync,timing/train/exposed_generation,train/unfiltered_reward.Issues
Part of #4860 (rollout_only only; train_only and the no_op rollout backend stay open).
Convergence / perf / functionality proof
GB200, one node, vLLM 0.33.0, 8 steps, recipe and overrides of
tests/functional/grpo_async_gym_single_controller.sh(Qwen3-0.6B, NeMo-Gym workplace_assistant, 4 prompts x 2 generations, 1 vLLM GPU): the real SC training run (Megatron TP1 on the second GPU) and two rollout-only runs of the same recipe.train_time_s=15train_time_s=30timing/train/exposed_generations, mean of steps 2-8timing/train/total_step_times, mean of steps 2-8timing/train/weight_syncs, meantiming/train/policy_trainings, mean of steps 2-8train/simulated_train_time_s, mean of steps 2-8train/simulated_train_idle_skipped_s, mean of steps 2-8train/unfiltered_reward, mean of the 8 stepsThe rollout side matches the training run: exposed generation per step agrees (0.33 vs 0.35 s) and the per-step rewards are identical.
weight_syncis the 3 s hold. With lookahead 0 nothing is generating while the train hold runs, so the hold is skipped as idle. With lookahead 1 the next step generates during the hold: 0.37 s is held, about one step of generation, and exposed generation drops to ~0. The comparison covers the measured full-batch case (one chunk per step); timing fidelity for steps that stream in several chunks is not validated.Curves
Needs upstream changes
None
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.