Repository navigation
feat(checkpoint): support typed Gym environment servers in turn/prefix recovery - #5340
Conversation
zyzhou5
left a comment
There was a problem hiding this comment.
- Nit: "(the default for agents and resources servers)" in
docs/guides/single-controller.md,single_controller_utils/config.pyand both example YAMLs should also list environment servers, since they now reach this check. - I am wondering whether we should report your e2e result for partial rollout ckpting here.
040da6c to
4697dd6
Compare
|
/ok to test 4697dd6 |
terrykong
left a comment
There was a problem hiding this comment.
Thanks @macandro96 — replacing the blanket refusal with one owner per episode is simpler than what was there, and the schema 9 bump keeps old checkpoints loading. We checked the Gym side at the pin: typed servers decode the <id>-a<N> restored ids, the task digest ignores every _ng_* key so keeping _ng_task_index is enough, and restart-only typed servers still go through allow_restart_only_gym_servers. The queue guard (37e1738) and the older-schema comment fix (51f84b3) look good.
- (C2) Add a unit test for the task-index wiring in the finalization dispatch.
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-5340-gym-server-roles.html
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-5340-typed-servers-resume.html
nemo-rl-review: kind=expert harness=claude-code/2.1.332 model=claude-opus-5-5 effort=medium review-pr-team=v3 reviewed=d421014
Turn and prefix recovery refused every Gym environment server except the legacy_agent relay, twice: at setup (_reject_typed_environment_servers) and at checkpoint discovery (environment-kind participants). Configs had to swap typed servers such as string_match's single_agent_turn_legacy back to legacy_agent, or fall back to sibling recovery. Gym already checkpoints these servers: each typed environment server is an "environment" checkpoint participant that owns the episodes it runs, and the agent sessions it opens for them are not the agent's own /run episodes. Gym also decodes the restored-attempt rollout id <id>-a<N> for both flat and materialized rows, so the setup guard's premise no longer holds. Remove both refusals and teach the commit summary that an environment server's exported episodes are owned, so their agent sessions are no longer reported as unowned live episodes. An episode claimed by more than one participant of any kind still fails the commit. Restart-only servers stay behind the existing allow_restart_only_gym_servers startup check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…ask index A typed Gym environment server fingerprints each episode's task when it starts and resumes a restored episode only for that task. A row without its own task ID takes its Gym task ID from _ng_task_index, and RL gave every rollout dispatch a fresh one, including the redispatch of a restored group. Gym therefore saw each continued attempt as a different task, refused it, and RL restarted it from its prompt: turn and prefix recovery through a typed environment server silently became restart-from-task. Record each attempt's task index in the rollout-recovery ledger when it is dispatched, persist it (schema 10; older schemas load without it), and re-send an attempt that continues environment state under the index it was first sent with. Every other row of the dispatch shares one fresh index, so a restarted attempt never reuses keys the attempt it replaces may have left in Gym. The ledger refuses a continued attempt whose index changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…tch's typed server Turn and prefix recovery now support typed Gym environment servers, so drop the override that swapped string_match's single_agent_turn_legacy server for legacy_agent. The test now exercises an environment-server checkpoint participant: each restored episode resumes from the environment server's saved boundary and its generation prefix. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
… queue episodes With max_concurrent_episodes set, a Gym environment server queues a request beyond the limit before it claims checkpoint state, so prepare does not report it. The parked episodes keep their slots, so it cannot start, and every snapshot times out waiting for its reply until the run aborts. Refuse the setup instead, for typed servers and the legacy_agent relay alike. Signed-off-by: Anish Mahishi <[email protected]>
… task index Older checkpoints could only hold legacy_agent episodes, and Gym checks the task only for episodes an environment server exported itself, so those continuations resume rather than start over. Signed-off-by: Anish Mahishi <[email protected]>
…aults Environment servers now reach the restart-only startup check, and BaseEnvironmentServer also defaults to restart_only. Signed-off-by: Anish Mahishi <[email protected]>
…ow's task index Runs generate_for_finalization on a restored turn group through the Gym rollout impl: the continued sibling goes out and is recorded under its original task index, the restarted one under a fresh index. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
4697dd6 to
8933c5a
Compare
|
/ok to test 8933c5a |
What and why
Turn- and prefix-level rollout recovery used to work only when every Gym environment server was the
legacy_agentrelay. Recipes with a typed server (for examplestring_match'ssingle_agent_turn_legacy) had to swap it back tolegacy_agentor fall back tosiblingrecovery. The pinned Gym already checkpoints typed servers, so this PR lets RL use them:max_concurrent_episodesset can hold a request in a queue the checkpoint cannot see, so every snapshot would time out. Turn/prefix recovery now refuses those setups up front.The L1 functional test
grpo_router_replay_prefix_recovery_single_controller_1n2g.shno longer swapsstring_matchtolegacy_agent, so it now covers a typed server end to end.Issues
None.
Convergence / perf / functionality proof
grpo_router_replay_prefix_recovery_single_controller_1n2g.shwith the typedstring_matchserver passes; Gym accepted all 4 restored episodes (0 of 4 before the task-index fix). Run before the rebase onto current main.Needs upstream changes
None. The Gym version this needs (
9e2e5d0ad) is already pinned on main.PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./nightly-ci test-case=<test>: run NVIDIA's nightly CI for the PR head; eligible teams only./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.🤖 Generated with Claude Code