Repository navigation
fix(single-controller): pass rewards to the loss for the positive-example NLL term - #5535
Open
Srivatsan6923 wants to merge 1 commit into
Open
Srivatsan6923 wants to merge 1 commit into
Srivatsan6923 wants to merge 1 commit into
Conversation
…mple NLL term ClippedPGLossFn adds the positive-example NLL term only when "rewards" is in its data. SingleController's train step fetches only the DP_TRAIN_FIELDS columns, so with loss_fn.positive_example_nll_weight > 0 the term was always 0. When the weight is set, the advantage stage now writes the per-sample reward after reward scaling and shaping (what legacy PPO passes) as a "rewards" column, the train step fetches it, and the partition registers it up front. The trainer warm-up batch gets a synthetic value for it. Signed-off-by: Srivatsan Sarvesan <[email protected]>
4 of 21 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
With
loss_fn.positive_example_nll_weight > 0, SingleController trains as if the weight were 0.ClippedPGLossFnonly adds the NLL term when"rewards"is in its data, and the SC train step only fetches theDP_TRAIN_FIELDScolumns, which don't include rewards. Sopositive_nll_lossis always 0 and nothing warns about it.This PR passes the rewards through when the weight is set:
rewardscolumn. As agreed in SingleController parity with legacy GRPO/PPO: remaining features and validation gaps #5044, it holds the reward after reward scaling and shaping, which is what legacy PPO passes to the loss. The rawtotal_rewardcolumn is not changed.AdvantageStageConfig.train_fields()addsrewards, so the workers fetch it.rewardson the rollout partition before producers start, the same way the reducer columns are registered. It was missing on the token-capture path.rewardsvalue (the same +1/-1 as the advantages), otherwise warm-up fails with "no synthetic value for train fields".Runs with the weight at 0 don't change. Runs that set it on SC GRPO will now get the term, which they silently didn't before. Legacy GRPO has the same gap and #3792 fixes it there. #3791 (how the NLL term is normalized) now matters for SC too.
Issues
Part of the "Additional loss/advantage capabilities" item in #5044. The SC parity tests and the SC CISPO nightly from that item will come in separate PRs.
Convergence / perf / functionality proof
GPU run:
tests/functional/grpo_dp_single_controller.shon 2x L40S (nvcr.io/nvidia/nemo-rl:v0.8.0with main's venvs rebuilt), Qwen3-0.6B, withloss_fn.positive_example_nll_weight=0.1 grpo.max_num_steps=5 policy.max_total_sequence_length=1024 'policy.tokenizer.chat_template_kwargs={enable_thinking:false}'. I needed the last two overrides because with the defaults every response hits the 512-token limit, the reward is 0, and the term can't show up. Same settings for both runs:positive_nll_losspositive_nll_lossOn main the term stays at 0 even in steps with correct samples. With this PR it's non-zero whenever a step has a correct sample, and 0 in the one step without any. The script's own metric checks pass in both runs.
New unit tests:
positive_nll_loss(1.1667, thevapo_mixed_rewardscase). On main it's 0.0.train_fields()includesrewardsonly when the weight is set.total_rewardraw. Nothing is written when the weight is 0.rewardson both the token-capture and the normal path.The first, second and fourth fail on main (the fourth on the token-capture path). All related unit test files pass on CPU (876 tests).
Needs upstream changes
None
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.