Repository navigation
feat(rollouts): carry a training framework's sampling values to every model call - #5463
Conversation
|
Review concerns from #4867, and where they stand here
One deliberate change from #4867: |
2b79be9 to
fe7c39e
Compare
|
/ok to test fe7c39e |
|
/ok to test 51189ad |
51189ad to
478eb64
Compare
|
/ok to test 478eb64 |
478eb64 to
8d07564
Compare
|
/ok to test 8d07564 |
… model call A training framework that serves the policy needs every model call of the agents it trains sampled with its own values: its training values, or its validation values for a validation rollout. NeMo RL writes them into each row's responses_create_params today. Harness agents reject those fields (NVIDIA-NeMo#4656), CLI harnesses do not send them on every call, and multi-agent rows have no single responses_create_params to write into. The framework now sets the values on each row as _ng_model_sampling, next to _ng_rollout_id, and leaves the task unchanged. Gym carries them into the URL of every model call the rollout's agent makes, as /ng-sampling/<values> after any rollout prefix. The Model Server writes them into the request before policy admission and capture see it: temperature and top_p replace the call's, and max_output_tokens caps the call's own limit under each endpoint's name. - Typed rows: the collector copies the field into the episode request, and single_agent_turn and harbor add the segment to the agent's activation URL. single_agent_turn_legacy reads it from the flat row. - Flat rows: the agent reads it from its /run body. - Agents: an inbound segment becomes the request's, and Gym's URL helpers and ServerClient put it on every model URL the agent builds. - In a run that sets the model_call_sampling block, resources servers send /ng-sampling/null with their model calls, so a verifier's LLM judge keeps its own sampling or its Model Server's sampling_overrides. vllm_model forwards null to its generation server as the header x-ng-sampling: null. - A Model Server in model_call_sampling.required_model_servers refuses a generation call without a segment and cannot set sampling_overrides. Gym-only evaluation sets neither the field nor the block, so its URLs and requests are unchanged. Replaces NVIDIA-NeMo#4867. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Harbor's compose sidecars, such as a simulated user, call a model server through URLs that harbor builds for them. They are never the agent being trained, so in a run that sets model_call_sampling their URLs now carry /ng-sampling/null. Their calls keep their own sampling instead of failing policy_model's missing-segment check or the training framework's check on the policy's values. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
… URLs verifiers_agent, mini_swe_agent and harbor_agent build their model URLs without Gym's URL helpers. In a training run, their calls therefore reached the trained agent's model server without the rollout's sampling values and were refused. NeMo RL's QA distillation recipe runs verifiers_agent this way. - verifiers_agent uses its per-rollout client copy whenever the rollout carries values, not only when capture is on. The shared client's URL, built once for every rollout, still carries none. - mini_swe_agent builds its model URL with base_url_for_run, as mini_swe_agent_2 already does. A caller's policy_base_url is still used as given. - harbor_agent builds its model URL with base_url_for_run. With observability or capture on, mini_swe_agent's and harbor_agent's calls now also carry the rollout prefix, so they appear in per-rollout capture. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e reports NeMo RL's score centering pins logprobs and top_logprobs on policy_model, which a training run lists as required, so score-centering runs failed at startup. These fields change what the engine reports, not how it samples: both the startup refusal and the per-call refusal now ignore them. A real pin conflict is a configuration error, so the per-call refusal answers 409 instead of a plain error that surfaced as a retryable 500. A test also checks that a null call's x-ng-sampling header reaches the HTTP request. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
ServerClient gave the current segment only to calls aimed at a model server, so an agent calling its own /v1/responses (langgraph, haystack, finance_agent) started a request without it, and its model calls got a 422 from a required policy_model. Generation calls to agents now carry it too; /run does not. apply_rollout_prefix now keeps an explicitly passed segment even with trace_context=False, as its docstring said. CallerSamplingMiddleware declares applies_to_mcp_requests, so a resources server that exposes tools over MCP starts in a training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…carries sampling OpenHands ignores llm.base_url and reads the model server from the global config unless the overlay redirects it, and the overlay was installed only under token capture. With capture off, as in NeMo RL's SWE2 recipes, every policy call lost the sampling segment and got a 422. Gym-only evaluation, which carries no segment, keeps the bare URL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
An agent's URL helpers gave every model URL it built the run's segment, so a role the agent runs besides the one a training framework trains sampled with the framework's values: tau2's simulated user, pinchbench's judge (when judge_model_server is set) and conversational_tool_use_policy_tool_generation's judge. On a Model Server with its own sampling_overrides, every such call failed with 409. url_path_for_run, base_url_for_run and resolve_model_base_url take trained=False for such a role, which then gets null wherever the run carries a segment, and those three agents pass it. A run without values is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…t ignore them An episode request carries a training framework's sampling values in model_sampling, but only single_agent_turn (and its legacy variant) and harbor put them in the trained agent's URLs. Every other environment server accepted them and ran its agents without them: the agent the framework trains then got a 422 from its required Model Server, which agent sessions turn into failed, empty turns, so an RL run continued, or failed much later with an unrelated error. Environment servers now declare applies_model_sampling. An episode that carries values is refused at admission, terminally, by a server that does not declare it; Gym-only evaluation sends no values and is unaffected. single_agent_turn and harbor declare it. model_sampling_segment gives one participant's segment value: the episode's values for a participant the framework trains, null for every other one, none without values. single_agent_turn and harbor use it for their agent's path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
A trained agent's server may still pin logprobs and top_logprobs. The null header is sent on Chat Completions requests. Only model calls a resources server makes through Gym's server client while handling a request are marked null; judges with their own clients and agent-driven untrained roles are not yet. The middleware comment says where it runs instead of calling it outermost. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
21b729d to
2a3a42b
Compare
|
/ok to test 2a3a42b |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42902094007 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42905415488 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42908308447 |
|
Two follow-ups on the per-rollout sampling values, both reproduced on Collating a dataset that declares a A redirect drops the |
What does this PR do?
Gym side of PR 1 in the design doc "RL sampling through Gym": single-agent paths. The RL side is NVIDIA-NeMo/RL#5030.
Problem
responses_create_params, Gym'ssampling_overridespins values on the Model Server, and RL's vLLM checks every call. These paths can collide, and a pin cannot hold separate training and validation values.responses_create_params.Where each agent's sampling comes from
policy.generation, and theval_*values for validationsampling_overrideson its own Model ServerHow the values travel
_ng_model_sampling, next to_ng_rollout_id. The task is unchanged./runas they are./ng-sampling/<values>to the trained agent's activation URL.…/ng-sampling/<values>/v1/……/ng-sampling/null/v1/…sampling_overrides. It tells the generation server with the headerx-ng-sampling: null, so NeMo RL's check skips the call.…/v1/…model_call_sampling.required_model_servers: something dropped the values. A listed name that is not a Model Server of the run fails the run at start-up.Untrained callers get
nullwithout any configuration: in a run that setsmodel_call_sampling, resources servers (judges, tools), harbor's sidecars and the roles an agent runs but does not train mark their calls. Those roles are tau2's simulated user, pinchbench's and conversational_tool_use_policy_tool_generation's judges, and Hermes's compression helper; an agent marks one by building its URL withtrained=False.Scope
single_agent_turn, thelegacy_agentrelay andharbor, with any agent, including CLI harnesses. That includes/v1/messagesfor Claude Code.verifiers_agent,mini_swe_agentandharbor_agentbuilt theirs by hand and now use the helpers, andswe_agentsnow points OpenHands at the per-run URL whenever the rollout carries values, not only under token capture.nemo_user_simorswe_together, refuses an episode that carries them before it starts (applies_model_sampling).Gym-only eval sends no values, so no call carries a segment and sampling is unchanged. One URL change: with observability on (the Slurm default),
harbor_agentandmini_swe_agentnow build their model URLs with Gym's helpers, which add/ng-rollout/<id>as other agents' URLs already do; Gym's Model Servers strip it.Replaces #4867. Refs #4656.
Validation
tests/unit_tests/core/test_model_call_sampling.py,tests/unit_tests/server_runtime/test_model_sampling.pyand the/ng-sampling/cases intests/unit_tests/core/test_correlation.py, including an end-to-end test across an agent, a resources server and a Model Server, plus tests in each touched server.pytest tests/unit_testsonmainat 50f0932: the 135 tests that fail here (sandbox, orchestration and Harbor task-folder tests that need packages or tools this environment lacks) fail the same way onmain; everything else passes.main. The tau2, hermes_agent, conversational_tool_use_policy_tool_generation, verifiers_agent, mini_swe_agent, swe_agents and harbor_agent suites need their own packages, so they run in CI.pre-commit run --fileson the changed files: passed.Rollouts
Validated end to end in NVIDIA-NeMo/RL#5030 at 8d07564. Later changes come from rebases and review fixes, covered by the tests above.
🤖 Generated with Claude Code