Skip to content

build(gym): bump the Gym submodule - #5195

Merged
terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
zyzhou5:gym-bump-5711
Nov 16, 2026
Merged

terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
zyzhou5:gym-bump-5711

Conversation

@zyzhou5

@zyzhou5 zyzhou5 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Moves the Gym submodule from 5911d628c to 23557b7c2 (Gym main on 2026-11-12) and fixes what the bump breaks.

  • uv.lock: openai 2.44.0 → 2.45.0 and nemo-gym's requirement list. Written with uv 0.11.18, which keeps main's lock format; uv 0.13.6 accepts it unchanged.
  • Recipes: Gym now ships most of its bundled environment servers as single_agent_turn_legacy. RL recipes restate many of them as legacy_agent, so those servers got both types and Gym refused to start them. Each restated block now also deletes Gym's type with _delete_key: single_agent_turn_legacy and keeps legacy_agent (102 blocks in 23 files). The single_agent_turn recipe deletes single_agent_turn_legacy instead of legacy_agent.
  • code_gen: at this pin it grades only in a sandbox. The 8 base recipes that load it also load Gym's OpenSandbox provider config, which reads CODE_GEN_SANDBOX_IMAGE, OPENSANDBOX_DOMAIN and OPENSANDBOX_API_KEY from the launch environment; none of them is in the repository, and only Gym reads the key. The 3 prefetch configs set a placeholder image for the image build's dry run. The 16 GPU tests that load code_gen set USES_OPENSANDBOX=1, so nemo-ci passes them the three variables. The L0 Gym test grades code_gen with Gym's local provider. The environments guide documents the variables and how to run without OpenSandbox, and the Nemotron 3 Nano, Super and Ultra and Nemotron 3.5 Lightning guides set them.
  • browsecomp: the compaction functional test sets the resources server type and allow_host_execution, which Gym's browsecomp agent no longer defaults.
  • Synchronous rollouts: Gym's default environment server builds a flat row's task from _ng_task_index. The synchronous path (sync GRPO, PPO, distillation and validation) now gives each flat prompt group a task index, and names its episodes with _ng_rollout_id (prompt group ID, rollout index and attempt), so names do not repeat after a restart or between async validation and training. The task-index check runs per prompt group.
  • Tests: CaptureContext takes capture_key, the exporter test collects names from the modules that define them, and the checkpoint adapter test's export hooks take checkpoint_id.
  • Behavior: RL refuses rollout_recovery.target_level turn and prefix for environment servers that are not legacy_agent. That now includes Gym's bundled servers that a recipe loads without restating them. No recipe sets those levels; the default is sibling.
  • Follow-up: Move NeMo RL's nemo_gym imports to Gym's new module paths before Gym 0.10 #5254 moves RL's imports off the Gym module paths this pin deprecates.

Validation

  • Every example recipe's env.nemo_gym, composed through Gym's parser: 36 recipes failed at 23557b7c2 before this change and none after; the 5 that also fail on main are unchanged.
  • nemo-ci, with the OpenSandbox variables set: grpo-nanov3-30BA3B-2n8g-megatron_generation-noncolocated-async-gym-quick passed at 5ff3ddf.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 12, 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

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 313fb81 (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@zyzhou5 zyzhou5 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 12, 2026
@zyzhou5

zyzhou5 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 313fb81

@zyzhou5

zyzhou5 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1fb5715

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 1fb5715 (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 1cd7285 (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@zyzhou5

zyzhou5 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1cd7285

jthomson04 added a commit to jthomson04/RL that referenced this pull request Nov 13, 2026
NVIDIA-NeMo#5195 moves the Gym submodule to 23557b7c2 (Gym main on 2026-11-12) and
makes the recipe and test changes that bump needs. This branch pinned
the Dynamo dialect (NVIDIA-NeMo/Gym#4817) on the old Gym base, so the
two pins conflict.

The submodule is now 234bb55da, the head of Gym#4817: the dialect
rebased onto Gym main 0aedecf12, which contains 23557b7c2. Gym's
dependencies are the same at both commits, so uv.lock is NVIDIA-NeMo#5195's plus
this branch's own entries.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
@qiaochuz-nv

Copy link
Copy Markdown
Contributor

This bump moves Gym to 23557b7c2, which includes NVIDIA-NeMo/Gym#5489. That PR made browsecomp_agent.resources_server default to null and turned off host /run unless allow_host_execution: true (see responses_api_agents/browsecomp_agent/README.md). The compaction functional test (tests/functional/grpo_async_gym_single_controller_context_compaction.sh, overrides in grpo_async_gym_single_controller.sh:76) sets only resources_server.name, so on this Gym it fails first with resources_server.type Field required, and then every /run returns 422 with Legacy /run requires allow_host_execution=true and resources_server; use agent sessions.

These two overrides fix it in our runs:

++env.nemo_gym.browsecomp_agent.responses_api_agents.browsecomp_agent.resources_server.type=resources_servers
++env.nemo_gym.browsecomp_agent.responses_api_agents.browsecomp_agent.allow_host_execution=true

We tested them on eos with the RL nightly image (27fac5f3d), Gym main (dfed8a3b2) in place of the submodule, and NRL_FORCE_REBUILD_VENVS=true. All 10 steps passed every gate of the functional test: up to 18 valid rows for 8 rollouts, max gen_kl_error 0.0011, max token_mult_prob_error 1.025.

There is also a related issue outside this bump. Forest training imports nemo_gym inside SingleControllerActor (nemo_rl/experience/rollout_recovery.py:544). That actor runs in the driver venv, where nemo_gym is only an optional extra. The functional test passes only because its uv run ng_prepare_data call inside the Gym directory installs Gym into the driver venv (UV_PROJECT_ENVIRONMENT points there). If the data is prepared somewhere else, the first rollout fails with No module named 'nemo_gym'. Running the driver with uv run --extra nemo_gym avoids the failure; that is how the run above starts it.

jthomson04 added a commit to jthomson04/RL that referenced this pull request Nov 13, 2026
…m pinned to the rebased dialect) into jthomson04/dynamo-1.7

No conflicts. uv.lock still matches pyproject.toml (uv 0.13.6, lock --check).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
Comment thread 3rdparty/Gym-workspace/Gym Resolved
@zyzhou5

zyzhou5 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 07a716b

@zyzhou5

zyzhou5 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5ff3ddf

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 5ff3ddf (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@kajalj22
kajalj22 self-requested a review November 13, 2026 21:35
@zyzhou5

zyzhou5 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 64e87da

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: 64e87da (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

yfw
yfw previously approved these changes Nov 13, 2026

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the bump. The recipe sweep checks out: no recipe is left with two agent types, and every restated block matches Gym's configs. The L0 local-sandbox override and the browsecomp fix also check out, and the new _nemo_gym_group_task_index helper is small and easy to test. CI is green on 64e87da (Lfast only); the Super 3.5 nightly is still pending, per the description.

  1. (C1) The sync-path task counter reuses Gym episode names after a resume, and between async validation and training.
  2. (C2) The PR description says the restated blocks were removed; the diff keeps them.
  3. (C3) The guides don't mention the three OpenSandbox variables.
  4. (C4) Follow-up: RL imports Gym paths that this pin deprecates.

Generated by Claude Code

Comment thread nemo_rl/experience/rollouts.py Resolved
Comment thread examples/nemo_gym/grpo_nanov3.yaml Resolved
@zyzhou5

zyzhou5 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8cfdc12

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 16, 2026
Moves the Gym submodule from 5911d628c to 23557b7c2 (Gym main on
2026-11-12).

uv.lock is updated with uv 0.11.18, which keeps main's lock format:
openai 2.44.0 -> 2.45.0 and nemo-gym's own requirement list. uv 0.13.6, the
Dockerfile's version, accepts the file unchanged.

Recipes: Gym now ships most of its bundled environment servers as
single_agent_turn_legacy. RL recipes declare legacy_agent for many of the same
servers on purpose, so each recipe states its path; with both, Gym refused to
start the server. Each such block now also deletes single_agent_turn_legacy,
so the server keeps the type the recipe declares (102 blocks in 23 files). The
single_agent_turn recipe deletes single_agent_turn_legacy instead of
legacy_agent.

Tests: CaptureContext's rollout_id is now capture_key. The exporter test
collects names from the modules that define them, since
nemo_gym.openai_utils serves moved names only on request. The checkpoint
adapter test's export hooks take checkpoint_id, which Gym now requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
zyzhou5 and others added 3 commits November 16, 2026 19:56
At the new Gym pin, code_gen grades only in a sandbox and browsecomp no longer
has a default resources server or a default host /run path. This breaks every
recipe that loads code_gen, the rl-gym image build, the L0 Gym test and the
browsecomp compaction test.

- The 8 base recipes that load code_gen also load Gym's OpenSandbox provider
  config. The image, endpoint and key come from CODE_GEN_SANDBOX_IMAGE,
  OPENSANDBOX_DOMAIN and OPENSANDBOX_API_KEY. None are in the repository, and
  only Gym reads the key, so it stays out of RL's logged config.
- The 3 prefetch configs that load code_gen set a placeholder image. The image
  build's dry run validates the image but starts no sandbox.
- The 16 GPU tests whose recipes load code_gen set USES_OPENSANDBOX=1, so the
  internal CI can pass them the three variables.
- The L0 Gym test grades code_gen with Gym's local provider, since GitHub CI
  has no sandbox service.
- The browsecomp compaction test sets the resources server type and
  allow_host_execution.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
At the new Gym pin, Gym's default environment server builds a flat row's task
from _ng_task_index and names its episode "{task}-{rollout}". The async
collector stamps a run-wide counter, but the synchronous path (sync GRPO, PPO,
distillation, validation, the L0 Gym test) did not, so every flat row it sent
to that server failed with KeyError '_ng_task_index'.

_prepare_nemo_gym_rows now gives each flat prompt group one task index from a
process-wide counter, and keeps an index the rows already carry. Materialized
rows are unchanged: they carry their own task ID, and the NeMo-Gym actor names
their synchronous episodes by prompt group.

The task-index check now runs per prompt group: the synchronous path hands in
a whole batch of several groups, whose result carries no single task index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
…en sandbox

Rows that take their task index from the process-wide counter now also name
their episode with _ng_rollout_id (prompt group ID, rollout index and
attempt), the format the NeMo-Gym actor already uses for materialized rows.
Gym keys captures and exports on the episode name, and the counter restarts
with each process and counts apart from the async collector's, so
"{task}-{rollout}" could repeat after a restart or between async validation
and training.

Docs: the environments guide gains a NeMo Gym Code Generation Sandbox
section (the three variables, and running without OpenSandbox), and the
Nemotron 3 Nano, Super and Ultra and Nemotron 3.5 Lightning guides set the
variables in their launch instructions. The workplace_assistant recipe's
commented code_gen entry gains the commented OpenSandbox entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
@zyzhou5

zyzhou5 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b2e5b01

@github-actions

Copy link
Copy Markdown

✅ Submodule Fast-Forward Check Results

Check based on commit: b2e5b01 (PR #5195 from gym-bump-5711)

✅ Submodules that are properly updated:

Gym: ✅ PR branch is ahead of main branch (fast-forward)

All submodule changes look good! ✨

@terrykong
terrykong enabled auto-merge (squash) November 16, 2026 20:38
@terrykong
terrykong merged commit 8f3595a into NVIDIA-NeMo:main Nov 16, 2026
97 checks passed
jthomson04 added a commit to jthomson04/RL that referenced this pull request Nov 16, 2026
… two-phase SimpleStorage checkpoint capture) into jthomson04/dynamo-gym

No conflicts. main now has NVIDIA-NeMo#5195, so this branch's diff against main no
longer includes it, and it brings NVIDIA-NeMo#5195's code_gen fix for the Gym rollout
test.

The Gym pin stays 9e2e5d0ad0, which contains main's 23557b7c2a. uv.lock and
pyproject.toml are unchanged and equal main's.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
mxinO added a commit that referenced this pull request Nov 16, 2026
Re-lock uv.lock on the branch lock against main's bumped Gym submodule.

Signed-off-by: Meng Xin <[email protected]>
seonjinn added a commit to seonjinn/RL that referenced this pull request Nov 17, 2026
macandro96 added a commit that referenced this pull request Nov 18, 2026
…ture path

After the rebase onto #4979, both native and Dynamo calls restore through
prompt_and_capture.start_capture, which now carries the restored routes and
sampler top-k on RestoredCall. Test that path and run router replay with
prefix recovery behind Dynamo:

- The restored-call wiring test asserts the routes and top-k reach the
  call's capture, and that a prefix that had already finished answers with
  its restored routes.
- Fakes of resolve_restore return _ResolvedGenerationCut, and the fake chat
  handler worker sets _cut_routes_dtype.
- run_prefix_recovery_phases sets PHASE1_RUN_LOG, so stop_phase1 cleans up
  phase one's Dynamo services for every caller.
- L1_Functional_Tests_Dynamo.sh runs the router-replay prefix-recovery test
  behind Dynamo on the tiny DeepSeek model.
- The router-replay prefix test serves string_match's environment server
  through legacy_agent: the Gym bump (#5195) made it typed, which prefix
  recovery refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit that referenced this pull request Nov 18, 2026
…ture path

After the rebase onto #4979, both native and Dynamo calls restore through
prompt_and_capture.start_capture, which now carries the restored routes and
sampler top-k on RestoredCall. Test that path and run router replay with
prefix recovery behind Dynamo:

- The restored-call wiring test asserts the routes and top-k reach the
  call's capture, and that a prefix that had already finished answers with
  its restored routes.
- Fakes of resolve_restore return _ResolvedGenerationCut, and the fake chat
  handler worker sets _cut_routes_dtype.
- run_prefix_recovery_phases sets PHASE1_RUN_LOG, so stop_phase1 cleans up
  phase one's Dynamo services for every caller.
- L1_Functional_Tests_Dynamo.sh runs the router-replay prefix-recovery test
  behind Dynamo on the tiny DeepSeek model.
- The router-replay prefix test serves string_match's environment server
  through legacy_agent: the Gym bump (#5195) made it typed, which prefix
  recovery refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit that referenced this pull request Nov 18, 2026
…ture path

After the rebase onto #4979, both native and Dynamo calls restore through
prompt_and_capture.start_capture, which now carries the restored routes and
sampler top-k on RestoredCall. Test that path and run router replay with
prefix recovery behind Dynamo:

- The restored-call wiring test asserts the routes and top-k reach the
  call's capture, and that a prefix that had already finished answers with
  its restored routes.
- Router-replay and score-centering hosting tests restore through
  start_capture on a real worker and check the trained row: the routes keep
  the saved prefix's rows, the sampler top-k starts with them, and a prefix
  that had already finished stages its saved rows alone.
- Fakes of resolve_restore return _ResolvedGenerationCut, and the fake chat
  handler worker sets _cut_routes_dtype.
- run_prefix_recovery_phases sets PHASE1_RUN_LOG, so stop_phase1 cleans up
  phase one's Dynamo services for every caller.
- L1_Functional_Tests_Dynamo.sh runs the router-replay prefix-recovery test
  behind Dynamo on the tiny DeepSeek model.
- The router-replay prefix test serves string_match's environment server
  through legacy_agent: the Gym bump (#5195) made it typed, which prefix
  recovery refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
macandro96 added a commit that referenced this pull request Nov 18, 2026
…ture path

After the rebase onto #4979, both native and Dynamo calls restore through
prompt_and_capture.start_capture, which now carries the restored routes and
sampler top-k on RestoredCall. Test that path and run router replay with
prefix recovery behind Dynamo:

- The restored-call wiring test asserts the routes and top-k reach the
  call's capture, and that a prefix that had already finished answers with
  its restored routes.
- Router-replay and score-centering hosting tests restore through
  start_capture on a real worker and check the trained row: the routes keep
  the saved prefix's rows, the sampler top-k starts with them, and a prefix
  that had already finished stages its saved rows alone.
- Fakes of resolve_restore return _ResolvedGenerationCut, and the fake chat
  handler worker sets _cut_routes_dtype.
- run_prefix_recovery_phases sets PHASE1_RUN_LOG, so stop_phase1 cleans up
  phase one's Dynamo services for every caller.
- L1_Functional_Tests_Dynamo.sh runs the router-replay prefix-recovery test
  behind Dynamo on the tiny DeepSeek model.
- The router-replay prefix test serves string_match's environment server
  through legacy_agent: the Gym bump (#5195) made it typed, which prefix
  recovery refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anish Mahishi <[email protected]>
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) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants