Skip to content

draft: gym yield rollouts - #2939

Closed
yfw wants to merge 5 commits into
mainfrom
yifu/gym_yields_rollouts
Closed

yfw wants to merge 5 commits into
mainfrom
yifu/gym_yields_rollouts

Conversation

@yfw

@yfw yfw commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • 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

  • ...

HeyyyyyyG and others added 2 commits June 23, 2026 10:53
(cherry picked from commit f57f6adc4798334005d81ec7514e34737ebc62eb)
Signed-off-by: Anish Mahishi <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Jun 25, 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.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Jun 25, 2026
yfw added 2 commits June 26, 2026 23:32
…biguation

Port the internal async-GRPO rework (1f0eda7de) and its follow-up fix
(5dd399698) onto a mopd_gym_bump + format_penalty base, adapted to main's
package layout, typed MasterConfig, effort-shaping, and reward penalties.

NeMo-Gym now streams rollouts:
- nemo_gym.py: run_rollouts is an async generator yielding (rowidx, result,
  timing) per completed task; NaN logprobs fail loudly (no whole-batch retry).
- rollouts.py: run_async_nemo_gym_rollout is an async generator yielding one
  AsyncNemoGymRolloutResult per prompt group (extracted _postprocess_single_group,
  which applies effort shaping + reward penalties per group). A new
  run_nemo_gym_rollout_sync drains it for synchronous callers, preserving input
  ordering via returns_entire_batch.
- trajectory_collector.py: one worker thread per batch (was per prompt) consuming
  the per-group stream with create_task fan-out; the inflight semaphore is removed
  and per-target accounting reworked. The MOPD teacher-logprob block runs off the
  event loop via asyncio.to_thread.

Duplicate-prompt fix (5dd399698): stamp a unique monotonic _ng_task_index per
prompt group into extra_env_info and carry it into the buffered trajectory and
forward group_num to NeMo-Gym, so identical prompts in one batch no longer collide
in genrm_compare. The counter is checkpointed via rollouts.pt.

The non-gym async rollout path is preserved (1f0eda7de had dropped it): the worker
runs one batched run_async_multi_turn_rollout and slices it into per-group pushes.

All run_rollouts consumers were updated for the generator API:
- six synchronous run_async_nemo_gym_rollout call sites (grpo_train, validate,
  distillation x2, ppo, sync TQ rollout actor) route through run_nemo_gym_rollout_sync;
- rollout_manager.py drains the streaming generator;
- the gym actor run_rollouts consumers (rollouts.py, test_nemo_gym_sanity) iterate
  the streaming ObjectRefGenerator.

Tests: per-group group_num metadata test, rollouts-state checkpoint test, updated
the generator-shaped rollout tests, the Strategy-2 _process_batch tests, and the
gym sanity test. Validated on GPU: 3 gym integration tests pass (gym sanity,
streaming rollout, rollout manager).

Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw
yfw force-pushed the yifu/gym_yields_rollouts branch from 00e27c7 to 3f2b8ac Compare June 27, 2026 06:40
…e gym test

Restore the transient-failure retry (MAX_RETRIES=3, exponential backoff) in AsyncTrajectoryCollector._run_prompt_group_worker that was dropped when porting the streaming rollout rework. A single transient gym failure mid-stream previously dropped trajectories with no recovery while still marking the batch complete.

Add a buffered_keys dedup set (keyed by _ng_task_index on the gym path, group index otherwise) so a retry regenerates the batch but skips groups already buffered -- restoring resilience without re-pushing duplicate trajectories (a latent double-push hazard in the internal source's own retry).

Also fix test_async_nemo_gym_rollout_manager_matches_original, which still called the now-async-generator run_async_nemo_gym_rollout synchronously and read .final_batch; it now uses run_nemo_gym_rollout_sync.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Merged as #3000

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

Labels

Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants