Repository navigation
feat(rollout): generation-only driver for NeMo Gym GRPO recipes - #4814
Draft
shuyixiong wants to merge 4 commits into
Draft
shuyixiong wants to merge 4 commits into
shuyixiong wants to merge 4 commits into
Conversation
examples/nemo_gym/run_nemo_gym_rollout_only.py runs a GRPO recipe's rollouts with no trainer: the recipe decides everything except the inference node count (--num-nodes) and data.validation (dropped). It follows grpo_train / async_grpo_train for the rollout path (run_nemo_gym_rollout_sync with the training kwargs; or the AsyncTrajectoryCollector + ReplayBuffer pair, chosen by grpo.async_grpo.enabled), Gym shards and dataset-agent coverage, the inference segment topology, epochs, and the vLLM config normalization. It rejects what a run without refit cannot serve: online quantization (fp8 precision, vLLM NVFP4 per-token, ModelOpt quant_cfg/real_quant), dynamic sampling, batch_multiplier != 1 and multiple dataloaders. Between steps it keeps training's cache behavior: the async stand-in for the refit makes the collector's prepare_for_refit / resume_after_refit calls (so in_flight_weight_updates and recompute_kv_cache_after_weight_updates apply) and, for TRT-LLM, whose refit resets the prefix cache itself, resets it via invalidate_kv_cache. - grpo.py: inference_gpus_per_instance and prepare_inference_segment_topology move out of setup() so the driver reuses them; setup() behaves as before. - TRT-LLM: invalidate_kv_cache resets the prefix cache on every engine instead of being a no-op. NcclExtension overrides WorkerExtension.reset_prefix_cache to run under control_action(drain=False), like an in-flight refit, rather than draining first; finish_generation and sleep_async use the same reset. - ray.sub: NRL_CONTAINER_EXTRA_ARGS adds pyxis flags to the head/worker containers; NRL_HEAD_TOPO_RANK_LAST=1 ranks the head node last in its NVLink domain (off by default). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: shuyixiong <[email protected]>
--train-time-s holds each step where policy.train() would run, between sampling the batch and the refit stand-in, recorded as the policy_training span an e2e step records. On the async path generation keeps running during the hold, as with non-colocated training, so the collector paces as in an e2e run. The hold ends early once every target the age window allows has a full batch in the buffer: the collector is then paused on its generation limit with no rollout in flight, and waiting out the rest changes nothing in a rollout-only run. The skipped seconds are reported per step (e2e step = step + skipped) and in total; the sync path, which generates nothing while training, skips the whole hold. The async refit stand-in resets the reusable prefix cache only when grpo.async_grpo.recompute_kv_cache_after_weight_updates is set, matching an in-flight refit (vLLM's pause clear_cache, TRT-LLM's finish_weight_update), and each async step now reports the trajectories' reward_mean, solved count and turns_mean. The replay buffer writes the rollout lifecycle log to NRL_ROLLOUT_LIFECYCLE_FPATH, as async_grpo_train does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: shuyixiong <[email protected]>
The driver passed lifecycle_log_path to ReplayBuffer, a parameter main's ReplayBuffer does not take, so the async rollout path failed with a TypeError when creating the actor. Remove it together with the rest of the timeline plumbing: the Timer spans (total_step_time, exposed_generation, policy_training) only fed the training-timeline JSONL. Step timing, the simulated-training hold and Nsight capture are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: shuyixiong <[email protected]>
…iver Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: shuyixiong <[email protected]>
1 task done
1 task done
This branch has not been deployed
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.
What does this PR do ?
Adds
examples/nemo_gym/run_nemo_gym_rollout_only.py, a generation-only driver that runs a NeMo Gym GRPO recipe's rollouts exactly as training would, without creating a trainer. Use it to benchmark and tune rollout throughput and latency on the inference nodes alone.Driver
num_prompts_per_step × num_generations_per_prompt), sampling, Gym/agent settings, and epochs. Only two things are overridden:--num-nodes;data.validation, which is dropped.grpo.async_grpo.enabledpicks the path, matching the choice betweengrpo_trainandasync_grpo_train:run_nemo_gym_rollout_synccall per step with the training kwargs, the same call the sync training step makes.AsyncTrajectoryCollector+ReplayBufferpair asasync_grpo_train. The loop stands in for the trainer: it samples each step's groups the way training does, then advances the weight version throughprepare_for_refit→set_weight_version→resume_after_refit, without moving any weights.--train-time-s). Each step can hold wherepolicy.train()would run, so the async collector paces as it would in an e2e run.e2e_step = elapsed + skipped.recompute_kv_cache_after_weight_updatesis set.quant_cfg/real_quant);batch_multiplier != 1;--profile-step(Nsight capture of one step).Supporting changes
grpo.py:inference_gpus_per_instance()andprepare_inference_segment_topology()move out ofsetup()so the driver can reuse them.setup()behaves as before.TrtllmGeneration.invalidate_kv_cache()now resets the prefix cache on every engine; it used to be a no-op.NcclExtension.reset_prefix_cacheoverridesWorkerExtension.reset_prefix_cacheto run undercontrol_action(drain=False), like an in-flight refit, instead of draining first.finish_generationandsleep_asyncuse the same reset.ray.sub:NRL_CONTAINER_EXTRA_ARGSadds pyxis flags to the head and worker containers, e.g.--container-writablefor images whose baked Gym SWE setup trees are written at run time.NRL_HEAD_TOPO_RANK_LAST=1ranks the Ray head node last in its NVLink domain. The head also runs the driver and the NeMo Gym actor, so this keeps rank 0 of the first engine, and the context engines and frontends under PD disaggregation, on other nodes. It is off by default, so training keeps pure topology order.Issues
N/A
Usage
Run as the
COMMANDof a Ray cluster launched withray.sub, on the inference nodes only:Before your PR is "Ready for review"
Pre checks:
test_trtllm_generation.py:invalidate_kv_cacheresets the prefix cache on every engine, colocated and not.test_trtllm_backend.py: the non-drainingreset_prefix_cache.Additional Information
num_prompts_per_step=32, 512 trajectories per step), on an earlier revision of this branch that also carried the recipe and timeline tooling.