Skip to content

refactor: handle GDPO multi-reward by dict instead of positional list - #2597

Merged
yuki-97 merged 14 commits into
mainfrom
nliang/gdpo-multi-reward-dict
Jun 29, 2026
Merged

yuki-97 merged 14 commits into
mainfrom
nliang/gdpo-multi-reward-dict

Conversation

@NolenLiang

Copy link
Copy Markdown
Contributor

Replace positional Tensor[B,K] multi-reward with named dict[str, Tensor] using reward/ prefix (e.g. reward/correctness, reward/integer, reward/format).

Changes across 4 layers:

  • Environment: EnvironmentReturn.rewards supports dict type; HFMultiRewardVerifyWorker returns named reward components
  • Rollouts: sync/async paths accumulate and discover rewards by name (reward/ prefix) instead of regex reward\d+
  • Algorithm: get_gdpo_reward_component_keys() uses prefix matching; GDPOAdvantageEstimator unchanged in logic
  • Docs & tests updated to match

Closes: #2107

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

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

  • ...

@NolenLiang
NolenLiang requested review from a team as code owners May 28, 2026 07:02
@copy-pr-bot

copy-pr-bot Bot commented May 28, 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.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label May 28, 2026
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test ad88d28

@NolenLiang NolenLiang added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed Documentation Improvements or additions to documentation labels May 28, 2026
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test ad88d28

@NolenLiang
NolenLiang force-pushed the nliang/gdpo-multi-reward-dict branch from ad88d28 to 4199d0c Compare May 28, 2026 09:12
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label May 28, 2026
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 4199d0c

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test cb40d08

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test ccacc0e

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 4359b1c

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 218f2ed

Comment thread nemo_rl/experience/rollouts.py Resolved
Comment thread nemo_rl/experience/rollouts.py Resolved
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 170e6b7

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 7d995c5

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 9a152cf

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 536189f

@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 7ea141f

Comment thread nemo_rl/experience/rollouts.py Resolved
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 32a63dd

NolenLiang and others added 12 commits June 27, 2026 02:59
Replace positional Tensor[B,K] multi-reward with named dict[str, Tensor]
using reward/ prefix (e.g. reward/correctness, reward/integer, reward/format).

Changes across 4 layers:
- Environment: EnvironmentReturn.rewards supports dict type;
  HFMultiRewardVerifyWorker returns named reward components
- Rollouts: sync/async paths accumulate and discover rewards by name
  (reward/ prefix) instead of regex reward\d+
- Algorithm: get_gdpo_reward_component_keys() uses prefix matching;
  GDPOAdvantageEstimator unchanged in logic
- Docs & tests updated to match

Closes: #2107

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: nliang <[email protected]>
Per-prompt rollouts always use single-reward (Tensor), not dict.
Add assert to satisfy pyrefly type checker after rewards type changed
to Tensor | dict[str, Tensor].

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: nliang <[email protected]>
Leftover from rebase conflict resolution — function is not used in
advantage_estimator.py after the multi-reward dict refactor.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: nliang <[email protected]>
…ify calculate_rewards Signed-off-by: nliang <[email protected]>

Signed-off-by: nliang <[email protected]>
Co-authored-by: Yuki Huang <[email protected]>
Signed-off-by: NolenLiang <[email protected]>
Co-authored-by: Yuki Huang <[email protected]>
Signed-off-by: NolenLiang <[email protected]>
Co-authored-by: Yuki Huang <[email protected]>
Signed-off-by: NolenLiang <[email protected]>
Co-authored-by: Yuki Huang <[email protected]>
Signed-off-by: NolenLiang <[email protected]>
Signed-off-by: Nolen Liang <[email protected]>
Signed-off-by: Nolen Liang <[email protected]>
Co-authored-by: Yuki Huang <[email protected]>
Signed-off-by: NolenLiang <[email protected]>
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test dc986c3

Signed-off-by: nliang <[email protected]>
@NolenLiang

Copy link
Copy Markdown
Contributor Author

/ok to test 4a1fe2d

@yuki-97

yuki-97 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

/ok to test f2979a6

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) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle multi-reward by dict instead of list

3 participants