NVIDIA-NeMo/RL #4914
(part of #4860). All permalinks pin the PR head daee7636.
examples/run_single_controller_simulator.py. It runs the same recipe, but swaps the trainer and the weight transfer for stand-ins that use no GPU.Two pages on this PR — this one: how the new run compares with a training run.
Both commands go through the same launcher,
run_single_controller, and the same
_train_pump.
Setup makes one choice, no_op_trainer, and uses it to pick three things:
which GPUs exist, which trainer object is built, and which weight transfer is built.
The vLLM engines, NeMo-Gym, the sampler and the data plane are the real ones. The trainer-side steps (logprobs, advantages, training) are skipped or replaced by a timer.
| Question | Answer |
|---|---|
| Where do the two runs split? | Only in setup (clusters, trainer, weight transfer) and at the no_op_trainer branches in the train pump: logprobs, advantages and the train step. |
| What still differs after that? | The vLLM engines never get new weights, so every step samples from the starting checkpoint. The train step's GPU time is a fixed number you choose (train_time_s), not a measurement. |
| Which settings does it refuse? | Anything that needs a real trainer: PPO, checkpointing, on-policy distillation, refit-time quantization and more (validate_simulator_config). Setup stops before any engine starts. |
| Why keep both runs? | The training run is the real thing. The simulator gives rollout timing (exposed generation, refit pauses) on only the vLLM GPUs, with the trainer's time set by hand. |
The PR adds two stand-in classes and one function: NoOpTrainer (a plain object that only
sets up the data plane and answers metrics calls),
NoOpWeightSynchronizer (a refit that sleeps) and
simulate_train_step (the hold). There is no mock policy worker and no CPU Ray cluster:
no train cluster is built at all. Green lines are new in this PR.
Setup, once
# driver process, once at startup: setup_single_controller() validate_simulator_config(cfg, simulator) # refuse PPO, checkpointing, OPD, ... before any GPU work no_op_trainer = simulator is not None and simulator.uses_no_op_trainer # the one switch; mode is decided here if no_op_trainer: infer = _build_inference_only_cluster(cfg) # vLLM GPUs only; no train cluster at all else: train, infer = _build_clusters(cfg) # training: train GPUs + vLLM GPUs trainer = NoOpTrainer(dp_cfg, policy_cfg) if no_op_trainer \ # plain object, no Ray workers, no GPU else TQPolicy(...) # Megatron workers on the train GPUs sync = NoOpWeightSynchronizer(refit_time_s) if no_op_trainer \ # sleeps; moves no weights else create_weight_synchronizer(...) SingleControllerActor(trainer, sync, simulator=simulator) # the controller checks simulator again, below
Train pump, one step
# controller: _train_pump(), async loop (rollout pump runs beside it) no_op_trainer = self._simulator is not None and self._simulator.uses_no_op_trainer for chunk in groups_of_this_step: # arrive as rollouts finish if not no_op_trainer: await to_thread(trainer.get_logprobs_from_meta, chunk) # check 1: GPU forward if no_op_trainer: valid = False # check 2: skip advantages else: chunk, valid = await self._advantage_stage(chunk) if train_step and not no_op_trainer: trainer.train_microbatches_from_meta(chunk) # check 3 if not no_op_trainer and not step_open: raise RuntimeError("empty batch") # check 4 if no_op_trainer: # check 5 held, skipped = await simulate_train_step(train_time_s, rollouts_idle) # sleep, poll every 50 ms else: metrics = await to_thread(trainer.finish_train_step) # optimizer step on the GPUs await self._sync_weights() # same pause/resume; the no-op sync sleeps refit_time_s if no_op_trainer: metrics |= {simulated_train_time_s: held, ..._idle_skipped_s: skipped} # check 6
Real code: setup_single_controller,
_train_pump. This NoOpTrainer answers only data-plane and metrics calls, so the controller skips the rest itself: six no_op_trainer checks in the pump, one in the
refit watchdog, five in setup.
Nothing in B or C is implemented. They differ in where the fake sits, so they differ in how much of the training code a simulator run still exercises.
Two facts make the table readable. Logprobs are the trainer's job: a GPU forward pass writes
prev_logprobs. Advantages are the controller's job, not the trainer's, and they read that
prev_logprobs column. So advantages can only run if something writes the column.
| Logprobs (trainer step) | Advantages (controller step) | TQPolicy's own code | Checks in the controller | |
|---|---|---|---|---|
| A · this PR | Skipped. Nothing writes prev_logprobs. | Skipped, by a check, since their input is missing. | Not run: replaced by NoOpTrainer. | 6 |
| B · full stand-in | Faked: FullNoOpTrainer copies generation_logprobs into prev_logprobs. | Run, as in training. | Not run: replaced by FullNoOpTrainer, a hand-written copy of its method list. | 1 (the hold) |
| C · simulator worker | Faked the same way, inside the worker. | Run, as in training. | Run: the real TQPolicy splits the batch across workers, merges their replies and reads the data plane. | 1 (the hold) |
C · simulator worker (proposed): a third worker class, chosen where Policy already picks one
# driver: Policy.__init__ already picks a worker class per backend worker_fqn = MegatronPolicyWorker if megatron else AutomodelPolicyWorker if simulator: worker_fqn = SimulatedPolicyWorker # same config path; only the class changes # setup: the train cluster exists, with CPU-only bundles train = RayVirtualCluster(..., use_gpus=simulator is None) # already supported trainer = TQPolicy(cfg, train, ...) # unchanged: same driver code as training sync = create_weight_synchronizer(..., simulator=simulator) # factory picks the no-op # SimulatedPolicyWorker: Ray actor, 0 GPU, one per bundle class SimulatedPolicyWorker: # answers the 15-20 calls a simulator run makes def setup_data_plane(...): connect a TQ client def get_logprobs_presharded(meta): copy generation_logprobs -> prev_logprobs def train_microbatch_presharded(...): pass def finish_train_step_presharded(): return {is_replica_leader: True} # well-formed, empty metrics def offload_to_cpu() / prepare_for_training() / ...: pass # controller: _train_pump() runs the training code; one check left logprobs -> advantages -> train_microbatches -> finish_train_step # as in training if simulator: held, skipped = await simulate_train_step(...) # the hold needs to see the rollouts
B · full stand-in (proposed), for comparison
# driver: a second trainer class with TQPolicy's driver-side methods class FullNoOpTrainer(Trainer): # ~24 methods, no Ray workers def get_logprobs_from_meta(meta): copy generation_logprobs -> prev_logprobs def finish_train_step(): return {} trainer = FullNoOpTrainer(...) if simulator else TQPolicy(...)
C is the one to pick. It makes the simulator a variant of things that already exist: a worker class (Policy
already picks one per backend, and swaps it again for quantization), a CPU cluster
(use_gpus=False), and one more case in
create_weight_synchronizer. The cost: CPU Ray actors at startup, and a worker that must
return well-formed replies for each call TQPolicy reads (it merges worker replies in
finish_train_step).
num_steps, num_nodes) are applied on top of the recipe. The next page shows that num_nodes is applied too late, so values the recipe computes from the node count keep the old count.