Repository navigation
Conversation
There was a problem hiding this comment.
The GDPO math on SC was checked against the legacy path and matches: it uses the same scale_rewards and the same GDPOAdvantageEstimator. Unit tests pass, 755 across the touched files on CPU.
- (C5) The components-vs-scalar check crashes after reward penalties or effort shaping; validate against
reward_original. - (C2) Also reject GDPO with
reward_penaltiesandenv.nemo_gym.effort_levels. - (C3) Nit: reuse
get_gdpo_reward_component_keysinstead of copying thereward/rule. - (C4) Nit: the nightly.txt comment still says the native path is covered elsewhere.
Generated by Claude Code (#4999 version)
3f69fcc to
06dd112
Compare
|
/ok to test 06dd112 |
06dd112 to
2ad441e
Compare
|
/ok to test 2ad441e |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
The main correctness issue is C6: missing Gym reward components are zero-filled within a prompt group, but not across the groups selected for one GDPO batch. That can make the advantage-stage fetch fail. C7 corrects the new field contract; C8 adds the required header to the new nightly script.
I verified the earlier fixes in the current source: setup rejects scalar-only penalties and shaping, component discovery uses the shared helper, validation checks the verifier's original reward, and the stale nightly comment is gone.
Static review only. I did not run tests or lint, and CI results were unavailable. The Gym submodule source was not populated, so external Gym behavior could not be checked. Two delegated reports were unavailable; I inspected their estimation/setup and recipe/test assignments directly.
Generated by Codex
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| ) | ||
| # A sample without components gets zeros, as on the legacy path, so a | ||
| # verify result that omits them does not fail the group's payload. | ||
| component_columns = build_reward_component_columns( |
There was a problem hiding this comment.
C6 · 1 action item. TL;DR — correctness bug: group-local zero-filling leaves valid GDPO batches with missing component columns.
This is PR-introduced. Consider one step containing two two-response Gym groups. Group A returns components [{"a": 1, "b": 1}, None] and scalar rewards [2, 0]; group B returns no components and scalar zero on both responses. This conversion gives A both columns but gives B none. The payload helper omits component columns for B, selection concatenates the groups, and metadata concatenation unions their field names. The advantage stage requests both components for every selected row, which reaches the adapter's missing-column KeyError. B should receive zeros under the missing-component fallback.
AI-1
Normalize component coverage before selection merges the individual group metadata. Use each group's fields to identify missing components, write float32 zeros for those rows, and update the metadata through a replay-buffer helper under its checkpoint mutation barrier. The invariant is that every selected row has every component in the selected union. Do not use an intersection, overwrite existing values, or invent component names for an entirely scalar batch. This crosses batch assembly and replay-buffer writes, so the exact helper placement needs implementation verification rather than a one-region patch.
Acceptance, proposed and not run: publish and select the two groups above, then run the advantage stage. Both component columns should be [1, 0, 0, 0], fetching should succeed, and advantages should match the estimator given those complete columns. Keep the within-group zero-fill assertions, all-scalar omission behavior, and genuine verifier-mismatch rejection.
There was a problem hiding this comment.
Fixed in 837fbb3. TQReplayBuffer.claim_for_training now zero-fills the reward/<name> columns a claimed group lacks, so every built-in sampler is covered. Added TestTQReplayBufferRewardComponentFill with the two-group case from this comment.
| # dynamic sampling filters on. ``None`` means nothing rewrote ``reward``. | ||
| reward_original: Optional[float] = None | ||
| # Per-component rewards of a multi-reward environment, keyed by the | ||
| # environment's component names and summing to ``reward``. ``None`` for a |
There was a problem hiding this comment.
C7 · 1 action item. TL;DR — documentation: components need not sum to the completion's adjusted scalar reward.
This new contract contradicts the supported GRPO penalty path. The new regression explicitly expects scalar reward zero while keeping components summing to one. The component keys are also payload keys with the reward/ prefix, not unprefixed verifier names.
AI-1
Replace this comment line so the declaration describes the raw values without promising equality after scalar-only adjustments:
| # environment's component names and summing to ``reward``. ``None`` for a | |
| # ``reward/<name>`` keys, before scalar-only adjustments. ``None`` for a |
Acceptance, static check: read the resulting field comment as describing prefixed, unadjusted component values. Keep the penalty regression's zero scalar and unchanged component assertions; do not change runtime behavior to satisfy the old comment. The suggestion has not been executed.
There was a problem hiding this comment.
Fixed in 9bf3f0e. The comment now says the keys are reward/<name> and that effort shaping and reward penalties change reward but not the components.
| @@ -0,0 +1,38 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
C8 · 1 action item. TL;DR — guideline: the new nightly script is missing the required NVIDIA copyright header.
This is a new shell script, so the protected copyright rule applies. This finding does not cover the renamed Gym script's pre-existing header omission.
AI-1
Keep the shebang first and insert the notice immediately after it:
| #!/bin/bash | |
| #!/bin/bash | |
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. |
Acceptance, static check: the script starts with the shebang and complete notice; executable statements, the 30-minute allocation, and the reward assertion stay unchanged. This is a comment-only suggestion, not an executed validation result.
There was a problem hiding this comment.
Fixed in 61e0553. Added the header after the shebang.
AsyncRolloutImpl accumulates a dict of rewards per component, keeps their sum as the completion reward, and the rollout payload writes one reward/<name> column per component. Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Reward shaping adjusts only total_reward, which GDPO does not read, so the run would silently skip the shaping. Reject the combination at setup, and name gdpo in the full-batch error. Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
The recipe now inherits the SingleController exemplar (Megatron trainer, non-colocated vLLM, sync in_order sampler) and its script runs examples/run_grpo_single_controller.py. Signed-off-by: bg51717 <[email protected]>
grpo.length_penalty adjusts only the scalar reward after the Gym results become completions, and GDPO reads only the reward components, so the penalty would be silently skipped. Signed-off-by: bg51717 <[email protected]>
Adds the SingleController variant of gdpo_math_1B.yaml and a functional test that runs it, and registers both SingleController GDPO functional tests in the L1 list. Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Both change only the scalar reward, which GDPO does not read, so the run would silently skip them. Signed-off-by: bg51717 <[email protected]>
A prompt group writes only the reward/<name> columns its own completions carry, but a train step fetches the columns of all its groups from every row. A GDPO step that mixed a group with components and a group without them failed in the advantage stage with a missing-column KeyError. claim_for_training now writes float32 zeros for the columns a claimed group lacks and adds them to its metadata, inside the claim's mutation section. Existing values are kept and a claim without any component column writes nothing. Signed-off-by: bg51717 <[email protected]>
2ad441e to
837fbb3
Compare
|
/ok to test 837fbb3 |
RayenTian
left a comment
There was a problem hiding this comment.
Thanks for adding GDPO support to the single-controller path! The test coverage is thorough. I left a few comments inline.
| ) | ||
| # Check the verifier's own reward: effort shaping and the penalties | ||
| # above rewrite full_result["reward"] but not its components. | ||
| validate_reward_components_match_scalar( |
There was a problem hiding this comment.
C9 · 1 action item. TL;DR — Could the new sum check reject a correct MCQA answer when both grading rules give it full credit?
In boxed_and_normalized mode, the answer \boxed{B} with gold label B gets strict_boxed=1.0 and normalized=1.0. MCQA uses the strict score as its scalar reward, so it returns 1.0. The previous SC path accepted that result. This check raises ValueError because the scores sum to 2.0, even with shaping and penalties disabled. MCQA scoring code
AI-1
Should the SC Gym path accept this result and preserve both the verifier’s scalar reward and its named scores?
| "preserve. Set token_capture.enabled=false to use GDPO." | ||
| ) | ||
|
|
||
| if algo_cfg.adv_estimator.name == "gdpo" and algo_cfg.reward_shaping.enabled: |
There was a problem hiding this comment.
C10 · 1 action item, 1 follow-up. TL;DR — Could SC reject reward-side KL for GDPO when the coefficient is nonzero? The configuration currently passes setup but silently drops the penalty.
This behavior predates this PR and also affects standard GRPO. With loss_fn.use_kl_in_reward=true and loss_fn.reference_policy_kl_penalty=0.01, the shared loss sets its own KL coefficient to zero, expecting the estimator to apply the penalty. Neither the standard GRPO nor the legacy GDPO estimator does so. This PR makes that combination reachable for GDPO on SingleController. Existing loss behavior · Existing GRPO and GDPO estimators
AI-1
Could we reject that GDPO combination here at setup and point users to use_kl_in_reward=false to keep the penalty in the loss? A regression test could check that the same nonzero coefficient is rejected with the flag on and accepted with it off.
Follow-up
Could we track reward-side KL support for both GRPO and GDPO in a separate issue, so the legacy and SingleController paths can share the implementation?
| input_fields = cfg.input_fields() | ||
| repeated_batch_fields = list(adv_cfg.repeated_batch_fields) | ||
| if not cfg.is_ppo and cfg.algo.adv_estimator.name == "gdpo": | ||
| component_fields = get_gdpo_reward_component_keys( |
There was a problem hiding this comment.
C11 · 1 action item. TL;DR — Could a run mixing Gym environments silently apply the same weight to different reward objectives across steps?
This behavior predates this PR. Legacy GDPO sorts the component names present in each batch and pairs them with reward_weights by position. Suppose one step contains only an environment scoring correctness and format, and the next contains only one scoring latency and safety. With reward_weights=[1, 0], both steps pass the length check, but the nonzero weight moves from correctness to latency. Legacy GDPO estimator
AI-1
Can this happen in a supported multi-environment Gym run? If so, should GDPO check that the component names associated with explicit, nonuniform weights stay consistent across steps?
| cd $PROJECT_ROOT | ||
| uv run --group test coverage run -a --data-file=$PROJECT_ROOT/tests/.coverage --source=$PROJECT_ROOT/nemo_rl \ | ||
| $PROJECT_ROOT/examples/run_grpo_single_controller.py \ | ||
| --config $PROJECT_ROOT/examples/configs/gdpo_math_1B_megatron_single_controller.yaml \ |
There was a problem hiding this comment.
C12 · Optional suggestion (non-blocking). TL;DR — Would it be useful to run the native SC GDPO functional test with AutoModel?
The SC GDPO functional and nightly tests added here all use Megatron. GDPO computes advantages before the policy update, so switching this functional test to AutoModel would exercise the same multi-reward training path with a second training backend. The Gym functional test and both nightlies would still cover Megatron.
Once this branch is up to date with main, would you consider adapting this test to the existing AutoModel SC full-batch smoke configuration?
| @@ -56,7 +55,4 @@ uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS | |||
| if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then | |||
| uv run tests/check_metrics.py $JSON_METRICS \ | |||
| 'max(data["train/reward"]) > 0.0' | |||
There was a problem hiding this comment.
Could this check be too lenient for a nightly? A positive reward on the first step would let the run pass even if the reward stays at zero for every remaining step. Is that sufficient for this Gym recipe?
What does this PR do ?
Adds GDPO (
grpo.adv_estimator.name: gdpo) to the SingleController path, for multi-reward native environments and for NeMo Gym rollouts with token capture off.Depends on #5287; until it merges, this diff also shows its commit.
reward/<name>column in the step's payload and passes them to the GDPO estimator. It raises if there are fewer than two.Completion.reward_componentsfrom the verifier'sreward_components, so native and Gym rollouts write the columns through the same payload code. A sample without components gets zeros, and a verifier whoserewarddiffers from the sum of its components is rejected, both as on the legacy path.grpo.reward_shaping, withgrpo.length_penalty, withreward_penalties, and withenv.nemo_gym.effort_levels. The last four adjust only the scalar reward, which GDPO does not read.examples/configs/gdpo_math_1B_megatron_single_controller.yaml, the SingleController variant ofgdpo_math_1B.yaml.Issues
Part of the "GDPO / component-wise reward advantages" item in #5044.
Usage
uv run examples/run_grpo_single_controller.py \ --config examples/configs/gdpo_math_1B_megatron_single_controller.yamlBefore your PR is "Ready for review"
Pre checks:
Additional Information
math_multi_reward: correctness, integer, format; maximum 3.0), with Qwen2.5-1.5B-Instruct, Megatron, 8 prompts x 8 generations, 50 steps, one run each.train/rewardandtrain/grad_norm:NeMo Gym has no environment for this task, so the Gym run used a local resources server that scores a response with the same rules as
math_multi_reward. It is not part of this PR.example_tool_call_multireward) on SingleController, 30 steps: mean reward 1.98 to 2.00 of 2.0 throughout. The task is saturated from the first step, so this run shows that the Gym path works, not that it learns.gdpo_single_controller.sh(native) andgdpo_gym_single_controller.sh(Gym). Both are inL1_Functional_Tests_SingleController_1.sh.grpo_dp_single_controller.sh,ppo_async_single_controller.sh,grpo_async_gym_single_controller.sh.