Skip to content

fix(single-controller): pass rewards to the loss for the positive-example NLL term - #5535

Open
Srivatsan6923 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
Srivatsan6923:fix/sc-positive-example-nll
Open

Srivatsan6923 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
Srivatsan6923:fix/sc-positive-example-nll

Conversation

@Srivatsan6923

@Srivatsan6923 Srivatsan6923 commented Dec 3, 2026 •

Copy link
Copy Markdown
  • I, the PR author, have personally reviewed every line of this PR.

What and why

With loss_fn.positive_example_nll_weight > 0, SingleController trains as if the weight were 0. ClippedPGLossFn only adds the NLL term when "rewards" is in its data, and the SC train step only fetches the DP_TRAIN_FIELDS columns, which don't include rewards. So positive_nll_loss is always 0 and nothing warns about it.

This PR passes the rewards through when the weight is set:

  • The advantage stage writes a per-sample rewards column. 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 raw total_reward column is not changed.
  • AdvantageStageConfig.train_fields() adds rewards, so the workers fetch it.
  • Setup registers rewards on the rollout partition before producers start, the same way the reducer columns are registered. It was missing on the token-capture path.
  • The trainer warm-up batch gets a synthetic rewards value (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.sh on 2x L40S (nvcr.io/nvidia/nemo-rl:v0.8.0 with main's venvs rebuilt), Qwen3-0.6B, with loss_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:

step main: reward main: positive_nll_loss this PR: reward this PR: positive_nll_loss
1 0.125 0.0 0.25 0.392
2 0.0 0.0 0.0 0.0
3 0.125 0.0 0.125 0.457
4 0.625 0.0 0.5 0.317
5 0.375 0.0 0.75 2.410

On 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:

  • Controller to loss: with the weight set, a batch built from exactly the controller's train fields gives the golden positive_nll_loss (1.1667, the vapo_mixed_rewards case). On main it's 0.0.
  • train_fields() includes rewards only when the weight is set.
  • The stage writes the scaled and shaped reward (2 * raw - 1 plus the DAPO overlong penalty), both in process and with 3 advantage actors, and leaves total_reward raw. Nothing is written when the weight is 0.
  • The partition registers rewards on 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 label, exactly one:
    • 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. Add mode=strict for a stricter review, reset=true for a fresh full review.
  • /resolve-conflict: Autobot merges main into this PR and resolves the conflicts. PRs from forks must allow edits by maintainers.
  • Locally: /review-pr-team <pr-number> for a team review before you ask for human review.
  • Contributor guidelines

…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]>
@copy-pr-bot

copy-pr-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) labels Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-request complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants