Skip to content

feat(sc): support multi-reward native environments in rollouts - #5287

Open
bg51717 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
bg51717:feat/sc-native-multi-reward
Open

bg51717 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
bg51717:feat/sc-native-multi-reward

Conversation

@bg51717

@bg51717 bg51717 commented Nov 18, 2026

Copy link
Copy Markdown
Member

What does this PR do ?

Lets the SingleController path roll out native environments that return several named rewards per turn (for example math_multi_reward), instead of failing an assertion on the first step.

  • AsyncRolloutImpl accumulates each reward component across turns. The completion's reward is the sum of the components, as on the legacy path.
  • Completion gains reward_components; it is None for a single-reward environment.
  • The rollout payload writes one reward/<name> column per component next to total_reward. It rejects a prompt group whose completions disagree on the component names, and component names that do not start with reward/.

Single-reward environments are unchanged.

Issues

Part of the "GDPO / component-wise reward advantages" item in #5044.

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: components accumulate across turns in the rollout loop; the payload writes the columns, omits them for single-reward groups, and rejects the two invalid cases.
  • Existing functional tests pass locally: grpo_dp_single_controller.sh (native, single reward) and grpo_async_gym_single_controller.sh (Gym, token capture off).
  • Local SingleController run of math_multi_reward on GSM8K (Qwen2.5-1.5B-Instruct, 8 prompts x 8 generations, 10 steps): completes, and the maximum total_reward is 3.0 at every step, which only the sum of the three components can reach.

@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 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 Nov 18, 2026

@bg51717 bg51717 left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One item: (C1) the GDPO rejection message in config.py is out of date now that the payload writes reward/<name> columns. Everything else matched the legacy path.

Generated by Claude Code (#4999 version)

TRUNCATED: truncated,
"total_reward": total_reward,
_VIOLATION_COUNTS_KEY: violation_counts,
**_reward_component_columns(completions),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

C1 · 1 action item (stale error message; not a correctness bug). TL;DR: after this PR the SC payload writes reward/<name> columns, so the GDPO rejection in config.py now gives the wrong reason.

This line adds the per-component columns. The GDPO guard at config.py#L1510-L1522 still says:

the SC payload writes only total_reward

The rejection itself is still right. The advantage stage fetches only input_fields(), and repeated_batch_fields is empty, so it never reads reward/*. Only the stated reason is out of date.

AI-1

In config.py#L1510-L1522, change the comment and the message to the reason that still holds. This is not a suggestion block because the target lines are outside this PR's diff.

    # Rejected here rather than at the first advantage call, which is a whole
    # round of rollouts and logprobs later: the payload writes reward/<name>
    # columns, but AdvantageConfig.repeated_batch_fields is never populated,
    # so the advantage stage does not fetch them.
    if algo_cfg.adv_estimator.name == "gdpo":
        raise NotImplementedError(
            "adv_estimator 'gdpo' is not supported on the SingleController "
            "path. The advantage stage does not fetch the per-component reward "
            "columns (reward/<name>), so the first advantage call would raise "
            "'GDPO requires multiple reward components' after the run had "
            "already paid for a full step of rollouts. Set adv_estimator.name "
            "to 'grpo'."
        )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9077840. The comment and the message in config.py now give the reason that still holds: the advantage stage does not fetch the reward/<name> columns.

@bg51717
bg51717 force-pushed the feat/sc-native-multi-reward branch from eaa647a to 9077840 Compare November 18, 2026 13:20
@bg51717 bg51717 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 18, 2026
@bg51717

bg51717 commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

/ok to test 9077840

@bg51717
bg51717 force-pushed the feat/sc-native-multi-reward branch from 9077840 to 0d1a9a7 Compare November 19, 2026 03:00
@bg51717

bg51717 commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/ok to test 0d1a9a7

@bg51717
bg51717 requested a review from yuki-97 November 19, 2026 06:24
@bg51717
bg51717 force-pushed the feat/sc-native-multi-reward branch from 0d1a9a7 to 729b7a2 Compare November 19, 2026 07:34
@bg51717

bg51717 commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/ok to test 729b7a2

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]>
@bg51717
bg51717 force-pushed the feat/sc-native-multi-reward branch from 729b7a2 to 6419ed9 Compare November 20, 2026 19:38
@bg51717

bg51717 commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

/ok to test 6419ed9

@RayenTian RayenTian 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.

LGTM. Would you please rebase main and solve conflicts?

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

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.

3 participants