Skip to content

feat(grpo): support message penalties in single controller - #3734

Merged
yuki-97 merged 4 commits into
mainfrom
amahishi/malformed_thinking_sc
Aug 31, 2026
Merged

feat(grpo): support message penalties in single controller#3734
yuki-97 merged 4 commits into
mainfrom
amahishi/malformed_thinking_sc

Conversation

@macandro96

@macandro96 macandro96 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Adds SingleController support for NeMo-Gym message-level advantage penalties for invalid tool calls and malformed thinking. (Adapts #2656 for single controller path)

The rollout payload now converts NeMo-Gym message flags into token-aligned masks and per-sample counters, carries them through the data plane, and applies the configured advantage values after normal advantage estimation. Invalid-tool-call penalties take precedence when both masks overlap. The SingleController path also validates that these penalties are only enabled with NeMo-Gym and reports global per-step violation counts and rates.

Issues

None.

Usage

env:
  should_use_nemo_gym: true

grpo:
  invalid_tool_call_advantage: -5.0
  malformed_thinking_advantage: -5.0

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

Unit tests were added for payload conversion, mask application and precedence, metric reduction, configuration validation, and SingleController advantage-stage integration. Tests and commit hooks have not been run locally.

@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 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.

@macandro96
macandro96 marked this pull request as ready for review August 20, 2026 19:31
@macandro96
macandro96 requested review from a team as code owners August 20, 2026 19:31
@github-actions

Copy link
Copy Markdown

❌ Submodule Fast-Forward Check Failed

Check based on commit: d7318d1 (PR #3734 from amahishi/malformed_thinking_sc)

❌ Submodules that need attention:

Gym: ❌ PR branch is BEHIND main branch
TARGET (main branch): https://github.com/NVIDIA-NeMo/Gym/commits/bb9b26de3dac1294faccccb5ed70f3386c16de10/
CURRENT (PR #3734 from amahishi/malformed_thinking_sc): https://github.com/NVIDIA-NeMo/Gym/commits/610a08ab5fe9f8f5fb5fff36b170429ea67f0f92/

Megatron-Bridge: ❌ PR branch is BEHIND main branch
TARGET (main branch): https://github.com/NVIDIA-NeMo/Megatron-Bridge/commits/8c46dc4259080c510b7455f43e836fdff222c5d3/
CURRENT (PR #3734 from amahishi/malformed_thinking_sc): https://github.com/NVIDIA-NeMo/Megatron-Bridge/commits/554c7b9324225aa863eee52e8b8fdde7abced2b1/

Please ensure all submodule commits are fast-forwards of the main branch before merging.

@macandro96
macandro96 force-pushed the amahishi/malformed_thinking_sc branch from d7318d1 to 458f25b Compare August 20, 2026 19:38

@macandro96 macandro96 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Team review of PR #3734 by rl-expert, bug-finder, test-agent, and design-reviewer, with devil-advocate stress-testing findings. Semantics faithfully mirror the legacy dtensor GRPO path (PR #2656) via precomputed masks + torch.where; all 42 relevant unit tests pass locally and pre-commit is clean. Design surface is bounded; no over-abstraction warranted for the first violation flag.

4 low-severity suggestions inline (1 consistency, 1 efficiency, 1 test coverage, 1 docstring). 6 additional findings were downgraded or disputed by devil-advocate (hypothetical KeyError path already blocked by the SC validator; unconditional _step_log_dict init is load-bearing for the reduce_advantage_pump_metrics kwargs unpack; ordering already locked by test_invalid_tool_call_takes_precedence_on_overlap).

Generated by Claude Code

Comment thread nemo_rl/algorithms/single_controller_utils/config.py Outdated
Comment thread nemo_rl/experience/payload.py Outdated
Comment thread nemo_rl/algorithms/single_controller_utils/utils.py
Comment thread tests/unit/single_controller/test_utils.py
@macandro96 macandro96 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Aug 20, 2026
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 542ce26

@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 53094ea

@macandro96
macandro96 requested a review from yfw August 21, 2026 23:16
yuki-97
yuki-97 previously approved these changes Aug 28, 2026

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the SingleController port of message-level advantage penalties (adapting #2656): the mask/count plumbing through payload.py → data-plane schema/column_io.pysingle_controller.py's advantage stage → metrics reduction, the NeMo-Gym validation gate, and invalid-tool-call-vs-malformed-thinking precedence on mask overlap. All consistent, tests cover the added paths, and I don't see anything blocking — LGTM.

Also cross-checked against the review comments on #2656 (the legacy path this ports from); none of them recur here.

One thing to handle before merge: this branch currently conflicts with main (mergeable_state: dirty) and the submodule fast-forward check is failing — please rebase.

Comment thread nemo_rl/algorithms/single_controller.py Outdated
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 971332f

@macandro96
macandro96 requested a review from yuki-97 August 31, 2026 00:16
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test dfe2d2d

yuki-97
yuki-97 previously approved these changes Aug 31, 2026
@yuki-97
yuki-97 enabled auto-merge (squash) August 31, 2026 16:57
Signed-off-by: Anish Mahishi <amahishi@nvidia.com>
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 9cd5e2e

@yuki-97
yuki-97 merged commit 71a0831 into main Aug 31, 2026
148 of 151 checks passed
@yuki-97
yuki-97 deleted the amahishi/malformed_thinking_sc branch August 31, 2026 21:46
pthombre added a commit that referenced this pull request Sep 2, 2026
Main's #3734 message penalties require invalid_tool_call_mask /
malformed_thinking_mask train-batch columns; the native rollout path
stamps them per message, but the token-capture finalizer publishes a
fixed column set that predates the feature, so the first streamed group
kills the train pump with a KeyError at the advantage stage (job
6810181). Fail loudly at config validation instead; emitting the masks
from capture receipts is a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranav Thombre <pthombre@nvidia.com>
pthombre added a commit that referenced this pull request Sep 3, 2026
Main's #3734 message penalties require invalid_tool_call_mask /
malformed_thinking_mask train-batch columns; the native rollout path
stamps them per message, but the token-capture finalizer publishes a
fixed column set that predates the feature, so the first streamed group
kills the train pump with a KeyError at the advantage stage (job
6810181). Fail loudly at config validation instead; emitting the masks
from capture receipts is a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranav Thombre <pthombre@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants