What a rollout-only simulator run keeps from a training run, and what it fakes

NVIDIA-NeMo/RL #4914 (part of #4860). All permalinks pin the PR head daee7636.

Before
Measuring the rollout side of a SingleController recipe meant a full training run, with GPUs set aside for the trainer.
This PR
Adds 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.
Status
New feature, under review. One open bug sits in its config loading (next page).

Two pages on this PR — this one: how the new run compares with a training run.

Background. A SingleController run has three parts: vLLM engines that generate, a trainer (Megatron workers on their own GPUs) that learns, and a refit that copies new weights to vLLM after each step. Dotted words have a short explanation: hover or tap them.

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.

One step, side by side (4 prompts × 2 answers = 8 rows)

Training run Simulator run (mode: rollout_only) ①setup _build_clusters train GPUs + vLLM GPUs vLLM load_format: dummy → 1st refit fills _build_inference_only_cluster vLLM GPUs only, no train cluster load_format: auto (reads the checkpoint) ②rollouts rollout pump → vLLM → NeMo-Gym → data plane (same code in both runs) 8 rows written: tokens, reward, generation_logprobs ③logprobs TQPolicy.get_logprobs_from_meta GPU forward pass on the 8 rows prev_logprobs ≈ generation_logprobs skipped: if not no_op_trainer no forward pass, nothing written no prev_logprobs column ④advantage _advantage_stage 8 rows get advantages from rewards skipped: groups consumed as-is 8 rows released, no advantages ⑤train step TQPolicy.finish_train_step Megatron forward + backward + optimizer rollouts for the next step keep running metrics: loss, grad_norm, … simulate_train_step waits train_time_s = 15 s, or less once no rollout is in flight metrics: held_s, idle_skipped_s only ⑥refit create_weight_synchronizer pause vLLM, copy new weights, resume version 0 → 1, vLLM serves new weights NoOpWeightSynchronizer same pause/resume; sleeps refit_time_s = 3 s version 0 → 1, vLLM keeps starting weights same code in both runs simulator: skipped, or a stand-in that holds a set time Green values: real data. Orange values: what the simulator does or reports instead. Both runs log timing/train/* the same way, so step times can be compared directly.
QuestionAnswer
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 code, as pseudocode: what the PR adds and how it is chosen

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.

Three ways to fake the trainer (B and C are proposed, not in the PR)

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 codeChecks in the controller
A · this PRSkipped. Nothing writes prev_logprobs.Skipped, by a check, since their input is missing.Not run: replaced by NoOpTrainer.6
B · full stand-inFaked: 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 workerFaked 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).

So what. Generation, Gym, the sampler and the data plane are real, so rollout-side timing is meaningful. The trainer side is two timers. The simulator's own settings (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.