Skip to content

feat(sc): support GDPO with token capture on the SingleController path - #5357

Open
bg51717 wants to merge 18 commits into
NVIDIA-NeMo:mainfrom
bg51717:feat/sc-gdpo-capture
Open

bg51717 wants to merge 18 commits into
NVIDIA-NeMo:mainfrom
bg51717:feat/sc-gdpo-capture

Conversation

@bg51717

@bg51717 bg51717 commented Nov 21, 2026 •

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

What and why

GDPO (grpo.adv_estimator.name: gdpo) could not run on the SingleController path with token capture on (token_capture.enabled: true). #5301 added GDPO with token capture off and rejected this combination at setup. This PR makes the combination work.

Depends on #5287 and #5301.

With token capture on, the finalizer actor writes the training rows, and it receives only the capture receipts and the scalar reward. This PR carries the reward components along the same route as the scalar reward:

  • The rollout manager now fills Completion.reward_components for results that carry a capture receipt too. A verifier whose reward differs from the sum of its components is now rejected with token capture on, as it already is with token capture off.
  • The recovery ledger stores the components of each sealed rollout and saves them in the checkpoint, so a rollout sealed before a restart keeps its components. The ledger schema version goes from 8 to 9. A checkpoint written at version 8 still loads; its sealed rollouts have no components.
  • The finalizer receives the components with the reassembly request and writes the reward/<name> columns with the same payload code as the path without token capture. A rollout whose capture failed becomes a placeholder row that keeps its component values and has sample_mask 0.
  • Setup no longer rejects GDPO with token capture.

GDPO with token_capture.forest_training is still rejected at setup, as before. The finalizer also raises if a forest row arrives with components.

Usage:

uv run examples/run_grpo_single_controller.py \
    --config <a NeMo Gym config with a multi-reward environment> \
    grpo.adv_estimator.name=gdpo \
    ++token_capture.enabled=true

Issues

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

Convergence / perf / functionality proof

  • GDPO through NeMo Gym on SingleController, with token capture on and off. The task and settings are the ones in feat(sc): support GDPO on the SingleController path #5301: GSM8K scored on three rewards (maximum 3.0), Qwen2.5-1.5B-Instruct, Megatron, 8 prompts x 8 generations, 50 steps, one run each. train/reward:
image
  • New functional tests pass locally, both in L1_Functional_Tests_SingleController_3.sh:
    • gdpo_gym_single_controller.sh ++token_capture.enabled=true, which also checks that the finalizer ran.
    • grpo_async_gym_single_controller_sibling_recovery.sh with SC_SIBLING_RECOVERY_ADV_ESTIMATOR=gdpo. It checkpoints a group with one sealed and one unfinished rollout, restarts, and checks that the checkpoint holds the sealed rollout's components.
  • Existing functional tests pass locally: gdpo_gym_single_controller.sh with token capture off, and the GRPO variant of the sibling recovery test.
  • Unit tests cover the component extraction for receipt results, the ledger save and load including a version 8 state, the request forwarding, the finalizer columns and placeholder rows, and the setup check.

Needs upstream changes

None.

@copy-pr-bot

copy-pr-bot Bot commented Nov 21, 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 Documentation Improvements or additions to documentation CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 21, 2026
@bg51717
bg51717 force-pushed the feat/sc-gdpo-capture branch from 17837dd to 879f3bf Compare November 21, 2026 16:52

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

Self-review of the 4 commits on top of #5301 (837fbb37..879f3bfe), by a team of agents (code, bugs, tests, design, existing threads) plus an adversarial pass.

The change is well shaped: capture and non-capture rows write their reward component columns through the same payload helper, the zero-fill sits in the finalizer (the one place that sees the whole group), and the ledger bump to schema 9 keeps a schema-8 load path.

Needs a rebase. #5158 landed on main and conflicts with the import block of nemo_rl/experience/rollout_manager.py. The conflicting hunk comes from #5301, so fix it there and rebase this PR on top. Nothing else that landed on main touches the code this PR changes.

What was checked:

  • Unit tests at this head, on CPU: 749 passed across the five changed files in the default lane, 131 passed in tests/unit/data_plane/test_rollout_reassembler.py in the NeMo Gym lane.
  • The functional tests were read but not run (no GPU on the review machine). No unit or functional CI job has run on this PR yet.
  • pre-commit run --all-files is clean.
  • Two inline comments:
    1. (C1) A header comment in the sibling-recovery script describes a check the test does not make.
    2. (C2) One missing unit test for a restored sibling's components in the reassembly request.

One behaviour to know about, no action: the reward == sum(reward_components) check now also runs on token-capture rows, for every estimator. A verifier that breaks that rule (for example Gym's vibench, or mcqa in boxed_and_normalized mode) is now rejected under GRPO with token capture too, as it already is on the legacy path.

nemo-rl-review: kind=self harness=claude-code/2.1.332 model=claude-fable-5-2 effort=medium review-pr-team=v3 reviewed=879f3bf

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]>
Reward shaping adjusts only total_reward, which GDPO does not read, so the run would silently skip the shaping. Reject the combination at setup, and name gdpo in the full-batch error.

Signed-off-by: bg51717 <[email protected]>
The recipe now inherits the SingleController exemplar (Megatron trainer, non-colocated vLLM, sync in_order sampler) and its script runs examples/run_grpo_single_controller.py.

Signed-off-by: bg51717 <[email protected]>
grpo.length_penalty adjusts only the scalar reward after the Gym results become completions, and GDPO reads only the reward components, so the penalty would be silently skipped.

Signed-off-by: bg51717 <[email protected]>
Adds the SingleController variant of gdpo_math_1B.yaml and a functional test that runs it, and registers both SingleController GDPO functional tests in the L1 list.

Signed-off-by: bg51717 <[email protected]>
Both change only the scalar reward, which GDPO does not read, so the run
would silently skip them.

Signed-off-by: bg51717 <[email protected]>
A prompt group writes only the reward/<name> columns its own completions
carry, but a train step fetches the columns of all its groups from every
row. A GDPO step that mixed a group with components and a group without
them failed in the advantage stage with a missing-column KeyError.

claim_for_training now writes float32 zeros for the columns a claimed
group lacks and adds them to its metadata, inside the claim's mutation
section. Existing values are kept and a claim without any component
column writes nothing.

Signed-off-by: bg51717 <[email protected]>
Token capture kept only the scalar reward: a receipt completion dropped
its reward components, and the recovery ledger, the reassembly request
and the finalizer carried one number per rollout. Setup therefore
rejected GDPO with token_capture.enabled.

A receipt completion now keeps its reward/<name> components. The
recovery ledger stores them per attempt (schema version 9; versions up
to 8 load without them), the reassembly request forwards them, and the
finalizer publishes them as columns on every row, placeholders included.
Forest rows carry no components, so the finalizer rejects that pairing,
which setup already excludes. The setup reject for GDPO with token
capture is removed.

Signed-off-by: bg51717 <[email protected]>
Run the sibling recovery functional test through the GDPO smoke on a
multi-reward environment. The checkpoint must hold the sealed sibling's
reward components, and the resumed group, which mixes the restored
sibling with a regenerated one, must publish.

Signed-off-by: bg51717 <[email protected]>
@bg51717
bg51717 force-pushed the feat/sc-gdpo-capture branch from 879f3bf to 28b666f Compare November 25, 2026 14:48
@bg51717

bg51717 commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

/ok to test 28b666f

@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 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

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