Skip to content

feat(rollout): generation-only driver for NeMo Gym GRPO recipes - #4814

Draft
shuyixiong wants to merge 4 commits into
mainfrom
shuyix/rollout_only
Draft

shuyixiong wants to merge 4 commits into
mainfrom
shuyix/rollout_only

Conversation

@shuyixiong

@shuyixiong shuyixiong commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Config. The recipe is used as is: backend, generation engines, rollout shape (num_prompts_per_step × num_generations_per_prompt), sampling, Gym/agent settings, and epochs. Only two things are overridden:
    • the inference node count, set with --num-nodes;
    • data.validation, which is dropped.
  • Rollout path. grpo.async_grpo.enabled picks the path, matching the choice between grpo_train and async_grpo_train:
    • Sync: one run_nemo_gym_rollout_sync call per step with the training kwargs, the same call the sync training step makes.
    • Async: runs the same AsyncTrajectoryCollector + ReplayBuffer pair as async_grpo_train. The loop stands in for the trainer: it samples each step's groups the way training does, then advances the weight version through prepare_for_refit → set_weight_version → resume_after_refit, without moving any weights.
  • Training stand-in (--train-time-s). Each step can hold where policy.train() would run, so the async collector paces as it would in an e2e run.
    • The hold ends early once no rollout is in flight. That is every step on the sync path; on the async path it is when every target the age window allows already has a complete batch.
    • Each step reports the skipped seconds, so e2e_step = elapsed + skipped.
  • Per-step log. Elapsed and exposed-generation time, reward mean, solved count, turns mean, idle skipped and e2e step time. Async steps also log trajectory age and group duration (min/median/max).
  • Prefix cache. Kept across steps as in training. For TRT-LLM, the refit stand-in resets it only when recompute_kv_cache_after_weight_updates is set.
  • Rejected configs. Settings a run without refit cannot serve:
    • online quantization (fp8 precision, vLLM NVFP4 per-token, ModelOpt quant_cfg / real_quant);
    • dynamic sampling;
    • batch_multiplier != 1;
    • multiple dataloaders.
  • Other setup. Gym shards with dataset-agent coverage, the inference segment topology, and --profile-step (Nsight capture of one step).

Supporting changes

  • grpo.py: inference_gpus_per_instance() and prepare_inference_segment_topology() move out of setup() so the driver can reuse them. setup() behaves as before.
  • TRT-LLM:
    • TrtllmGeneration.invalidate_kv_cache() now resets the prefix cache on every engine; it used to be a no-op.
    • NcclExtension.reset_prefix_cache overrides WorkerExtension.reset_prefix_cache to run under control_action(drain=False), like an in-flight refit, instead of draining first. finish_generation and sleep_async use the same reset.
  • ray.sub:
    • NRL_CONTAINER_EXTRA_ARGS adds pyxis flags to the head and worker containers, e.g. --container-writable for images whose baked Gym SWE setup trees are written at run time.
    • NRL_HEAD_TOPO_RANK_LAST=1 ranks 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 COMMAND of a Ray cluster launched with ray.sub, on the inference nodes only:

COMMAND="uv run ./examples/nemo_gym/run_nemo_gym_rollout_only.py \
  --config <grpo_recipe>.yaml \
  --num-nodes 16 \
  --num-steps 4 \
  --train-time-s 2400 \
  [--profile-step 2]" \
NRL_CONTAINER_EXTRA_ARGS="--container-writable" \
NRL_HEAD_TOPO_RANK_LAST=1 \
sbatch --nodes=16 ray.sub

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
    • test_trtllm_generation.py: invalidate_kv_cache resets the prefix cache on every engine, colocated and not.
    • test_trtllm_backend.py: the non-draining reset_prefix_cache.
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • Used on GB200 with an Ultra SWE TRT-LLM disaggregated recipe (2 DEP16 prefill + 2 DEP16 decode, 16 nodes, async GRPO, num_prompts_per_step=32, 512 trajectories per step), on an earlier revision of this branch that also carried the recipe and timeline tooling.

shuyixiong and others added 2 commits October 20, 2026 06:21
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]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

shuyixiong and others added 2 commits October 20, 2026 06:32
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]>
@shuyixiong shuyixiong changed the title Shuyix/rollout only feat(nemo_gym): generation-only rollout driver for NeMo Gym recipes Oct 20, 2026
@shuyixiong shuyixiong changed the title feat(nemo_gym): generation-only rollout driver for NeMo Gym recipes feat(grpo): generation-only rollout driver for GRPO recipes Oct 21, 2026
@shuyixiong shuyixiong changed the title feat(grpo): generation-only rollout driver for GRPO recipes feat(grpo): generation-only rollout driver for NeMo Gym GRPO recipes Oct 21, 2026
@shuyixiong shuyixiong changed the title feat(grpo): generation-only rollout driver for NeMo Gym GRPO recipes feat(rollout): generation-only driver for NeMo Gym GRPO recipes Oct 21, 2026
@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants