Repository navigation
feat(gym): send policy sampling with each rollout instead of into its task - #5030
Conversation
26b8663 to
90dd761
Compare
|
/ok to test 90dd761 |
90dd761 to
d5c885e
Compare
|
/ok to test d5c885e |
d5c885e to
bd35f96
Compare
|
/ok to test bd35f96 |
bd35f96 to
d5e29cf
Compare
|
/ok to test d5e29cf |
d5e29cf to
b488b20
Compare
yfw
left a comment
There was a problem hiding this comment.
GitHub reports a conflict with main, so please rebase on main. The only conflict is in the import block of nemo_rl/experience/rollout_manager.py, against #4588 (single-controller dynamic sampling). To resolve it, keep this PR's single get_nemo_gym_attribution_key import and the nemo_rl.experience.dynamic_sampling import block from main. A trial 3-way merge with that resolution has no unused or undefined names (ruff F401/F821).
Sending the sampling values beside the task, and letting Gym's model server apply them, is the right design. One place serves every agent shape, and the task stays as the dataset wrote it. The change fixes the Codex sandbox, Hermes and Pi agents that refused the stamped rows. It also lets multi-turn Harbor tasks through, and it lets an LLM judge that a resources server calls on policy_model keep its own sampling on vLLM. These parts work as described:
- Both GRPO drivers stamp the values: legacy
_prepare_nemo_gym_rowsand single-controller_build_inputs. grpo.validatepasses theval_*values.- Only the exact value
nullskips the vLLM sampling guard. - The copied Gym names have a test,
test_sampling_names_match_gym, that fails, and does not skip, in theL0_Unit_Tests_Nemo_Gym.shCI job.
Inline comments:
- (C1) Merge blocker: the new
nemo_gym.configimport fails at the current Gym pin and at Gym main. Please bump the Gym submodule in this PR to a commit with NVIDIA-NeMo/Gym#5462, NVIDIA-NeMo/Gym#5463 and the change inc1f64f10a3, and update the design doc on Environment Servers. - (C2) A
nullcall that token capture records skips the vLLM sampling guard. Please run the guard on captured calls, and test that case. - (C3) Servers that
_copypolicy_modelare not inrequired_model_servers, and the recipe's own list is overwritten. - (C4) The design doc says that all untrained calls keep their own sampling, but Gym marks only some of them.
docs/guides/grpo.mddoes not mention thenullexception. - (C5) No test covers stamping a task that has no
responses_create_params. - (C6) The comment on the copied Gym names gives the wrong reason for the copy.
- (C7) Two docstrings describe behavior that the code does not have.
For information, no action needed in this PR:
- The description says that a
policy_modelcall that lost the values "fails (422)". The 422 comes from Gym's model server. Inside an agent session, the agent returns it as an HTTP 200 with a failed, empty turn (C1). Outside a session, the agent turns it into a 500. RL counts that as an infrastructure failure and retries before the run stops. - The description says that validation rows get the
val_*values. That is true forgrpo.validate. The validation ingrpo_sync(grpo_sync.py#L323-L330, sync_rollout_actor.py#L251-L253) and in distillation stamps the training values. That is older than this PR. - The TRT-LLM HTTP server keeps its own train/val guard, with no
nullskip (trtllm_http_server.py#L478-L491). The design doc already limits thenullbehavior to "On the vLLM backend". - Agents that fill a missing output limit from their own configuration (
image_tools_agent,hermes_sandboxed_agent,simple_strands_agent) now cap at the smaller of that default andmax_new_tokens. No RL recipe uses them. - A follow-up after the bump: test_nemo_gym_episode_collection.py#L39-L46 calls
pytest.importorskipon old Gym module paths. Gym keeps them only as aliases and plans to remove them in nemo_gym 0.10.0. After that, the whole file skips without an error. - For the Gym side: please make the
trained=Falsehelper from65398414b5also turn off token capture for the roles that it marks, so their calls stay out of RL's training ledger (C2).
The end-to-end runs in the description used RL bd35f96 and Gym 8d075644a. Both are from before the rebase and before NVIDIA-NeMo/Gym#2890, which changes how context variables reach Gym routes. The sampling values travel in such a context variable. After the bump, please run the sync and single-controller 1-step smoke tests again at the final commits, and say whether token capture was on.
CI ran only the pre-test jobs at head b488b20a2, because no /ok to test was posted for that commit.
Generated by Claude Code
b488b20 to
0a09316
Compare
|
/ok to test 0a09316 |
0a09316 to
8639516
Compare
|
/ok to test 8639516 |
Approved by mistake while posting C8. C8 blocks the merge.
8639516 to
fdbfe24
Compare
|
/ok to test fdbfe24 |
… task NeMo RL wrote policy.generation's temperature, top_p and max_new_tokens into each Gym row's responses_create_params. Harness agents reject those fields, CLI harnesses do not send them on every call, and multi-agent tasks have no single responses_create_params to write into (review item C4). RL's vLLM check also rejected every call that matched neither the train nor the validation values, including an untrained judge's call on the policy model. Rows now carry the values for the rollout's phase beside the unchanged task, as _ng_model_sampling, and Gym applies them to every model call of the trained agent. Gym's model server keeps a smaller output limit the call asks for, as the min() here did. - The NeMo-Gym actor sets Gym's model_call_sampling block, so a call that lost the values fails on policy_model, on servers that _copy it and on any the recipe lists, and it refuses sampling_overrides on policy_model. - The vLLM HTTP server skips its train/val check for calls that Gym marks with x-ng-sampling: null, which come from agents NeMo RL does not train. Only calls Gym does not mark null are held to top_k and the policy's sampling. _spinup imports Gym's model_call_sampling block name, so a stale Gym fails at spinup; a test checks the names RL copies (row key, header, null) against Gym's. A spinup test checks that score centering's logprobs/top_logprobs pin on the required policy_model is accepted by Gym's VLLMModel. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
fdbfe24 to
db37d48
Compare
|
/ok to test db37d48 |
The NeMo-Gym actor tells Gym to require sampling values on calls to policy_model, the label RL's recipes give the policy's Model Server, and Gym refuses a run whose config has no Model Server by that name. The sanity test's config labeled the server openai_model, so its NeMo-Gym actor failed to start. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
|
/ok to test 5fe979c |
…tron actor concurrency, Qwen3-30B recipe tuning) into jthomson04/dynamo-gym One conflict, in nemo_rl/models/generation/vllm/vllm_worker_async.py: NVIDIA-NeMo#5030 changed the chat route's sampling check, which this branch moved to nemo_rl/models/generation/vllm/chat_server.py. The branch's worker is kept, and NVIDIA-NeMo#5030's change is applied in chat_server.py: a call NeMo-Gym marks with `x-ng-sampling: null` skips the train/validation sampling check. - tests/unit/models/generation/test_vllm_generation.py: NVIDIA-NeMo#5030's new test expects this branch's HTTP 400 answer for an off-policy call instead of a raised error. - docs/guides/dynamo-generation.md: through Dynamo every chat call is still checked, because NeMo RL's chat engine does not read that header. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
…ting Resolve two conflicts with NVIDIA-NeMo#5030. In the design doc's data-flow paragraph, keep main's sampling text and add the multi_harness routing and per-agent metric clauses. In rollout_manager.py, drop the get_nemo_gym_task_input import that main no longer uses and keep the multi-harness imports. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…ym rollout) into jthomson04/dynamo-1.7 Brings in NVIDIA-NeMo#4979's merge of main 89329fc (NVIDIA-NeMo#5030, NVIDIA-NeMo#5120, NVIDIA-NeMo#5007, NVIDIA-NeMo#5187, NVIDIA-NeMo#5265). Git merged the five files both sides changed without a conflict: the Dynamo guide, nemo_gym.py and three test files. pyproject.toml, uv.lock and the submodule pins are unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
The native chat route skips the train/validation sampling check for a call NeMo-Gym marks with the header x-ng-sampling: null, such as an LLM judge's on the policy model (NVIDIA-NeMo#5030). Dynamo's frontend does not forward request headers, so NeMo RL's chat engine checked every call and refused that one with HTTP 400. The chat engine now reads the mark from the nemo_rl:gym: annotation (GymCallExtras.ng_sampling) and skips the check on the same value the native route compares. NeMo-Gym's Dynamo dialect has to send it there; the pinned Gym does not yet, and the guide says so. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
What does this PR do ?
RL side of PR 1 in the design doc "RL sampling through Gym": single-agent paths. The Gym side is NVIDIA-NeMo/Gym#5463.
Needs #5195, which bumps the Gym submodule and goes in first.
Problem
policy.generation'stemperature,top_pandmax_new_tokensinto each row'sresponses_create_params, which does not reach every model call. Harness agents reject the fields (Coding-agent servers reject generation controls sent by NeMo-RL Gym#4656), CLI harnesses don't send them on every call, and multi-agent tasks have no singleresponses_create_params(review comment on #4429).Changes
_prepare_nemo_gym_rowsandAsyncNemoGymRolloutImpl._build_inputsput the values on each row as_ng_model_samplingand leave the task unchanged. The values aretemperature,top_p, andmax_new_tokensasmax_output_tokens, with theval_*values for validation. Gym applies them to every model call of the trained agent.model_call_sampling: {required_model_servers: [policy_model]}.policy_modelcall that lost the values fails (422) instead of sampling with other values.null, so a judge keeps its sampling.sampling_overridesonpolicy_modeland points topolicy.generation.x-ng-sampling: null, which Gym sends only for callers RL does not train. Trained agents' calls are still checked.docs/design-docs/nemo-gym-integration.mddescribes the new flow.Usage
No new configuration. Set
policy.generationas before.Validation
ruffon the changed files.temperature/top_p0.85/0.97 (no agent's default), validation 0.6/0.95,max_new_tokens2048, withvllm_cfg.logprobs_mode: processed_logprobs(main requires it whentop_p < 1).examples/nemo_gym/run_grpo_nemo_gym.pyexamples/run_grpo_single_controller.pysimple_agent+ LLM judgesingle_agent_turnsimple_agent+ LLM judgesingle_agent_turn_legacysimple_agent+ LLM judgelegacy_agentverifiers_agentlegacy_agentsingle_agent_turnsingle_agent_turnsingle_agent_turnEvery trained call carried its phase's values within the cap. LLM-judge calls carried
nulland kept their own values. No refusals, no vLLM sampling assertion, and both training steps completed. In the async run, RL's rollout reassembler dropped one of 16 rollouts from training (mini-SWE,ambiguous_terminal); its 5 calls carried the training values.🤖 Generated with Claude Code