Skip to content

feat(algorithms): support Reinforce++ baseline whitening on Forest owners - #5519

Open
jinglinglingling wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
jinglinglingling:linglinj/pr-b-reinforce-pp-forest
Open

jinglinglingling wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
jinglinglingling:linglinj/pr-b-reinforce-pp-forest

Conversation

@jinglinglingling

@jinglinglingling jinglinglingling commented Dec 2, 2026 •

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

What and why

Split out from #4581 per review feedback so the general Forest advantage/loss changes can be reviewed and verified independently.

  1. Reuse ReinforcePlusPlusAdvantageEstimator for Forest logical owners (logical_advantage.py, advantage_stage.py, config.py)
    • Instead of adding a duplicate advantage estimator class, reuses the existing ReinforcePlusPlusAdvantageEstimator with minus_baseline=True and use_kl_in_reward=False.
    • Adds LogicalOwnerBatch.action_token_counts(action_mask) and passes the per-owner eligible action-token counts as normalization_mask to ReinforcePlusPlusAdvantageEstimator.compute_advantage, while keeping valid_mask=owner_participation for per-prompt baseline estimation and zeroing filtered owners via owner_batch.valid_mask.
    • Because ReinforcePlusPlusAdvantageEstimator.requires_global_batch is True, the SingleController automatically disables sharding across advantage actors so global whitening runs over the full step batch.
    • Updates validate_forest_estimator and validate_forest_objective to allow reinforce_plus_plus (non-PPO) with minus_baseline=True, use_kl_in_reward=False, masked_reward_policy="include", seq-mask-tis token-level IS correction, and force_on_policy_ratio=True, while rejecting invalid combinations.
  2. Per-row finite-gate isolation in seq-mask-tis (nemo_rl/algorithms/loss/loss_functions.py)
    • Saturates ±inf log ratios to ±30.0 before computing per-sequence ratios so a non-finite token on one physical row cannot taint other rows in the same batch.
  3. Unit tests (tests/unit/single_controller/test_logical_advantage.py, tests/unit/algorithms/test_loss_functions.py)
    • Verifies exact numeric parity against token-expanded per-owner group-mean baseline + global whitening across multi-segment owners and masked owners, verifies shardable == False (never sharded across advantage actors), covers all 10 objective validation guard rails, and tests per-row seq-mask-tis finite-gate isolation.

Issues

Split from #4581.

Convergence / perf / functionality proof

  • Verified in rl.nightly container:
    • pytest tests/unit/algorithms/test_advantage_estimator.py tests/unit/algorithms/test_loss_functions.py tests/unit/single_controller/test_logical_advantage.py: 322 passed, 1 skipped.
    • ruff check and ruff format --check pass on all modified files.

Needs upstream changes

None.

@copy-pr-bot

copy-pr-bot Bot commented Dec 2, 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 CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Dec 2, 2026
@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 2, 2026
@jinglinglingling jinglinglingling changed the title feat(algorithms): support Reinforce++ baseline whitening for Forest logical owners feat(algorithms): support Reinforce++ baseline whitening on Forest owners Dec 2, 2026
@jinglinglingling
jinglinglingling force-pushed the linglinj/pr-b-reinforce-pp-forest branch 2 times, most recently from ad4fc08 to 2945ed2 Compare December 4, 2026 01:43
@jinglinglingling

Copy link
Copy Markdown
Contributor Author

/ok to test 2945ed2

…ogical owners

Compute the group baseline from one finalized reward per participating owner. Weight global whitening by surviving action tokens, excluding late execution padding. Exercise both Forest penalty scopes through finalization, step padding, and advantage writeback.

Signed-off-by: Linglin Jing <[email protected]>
@jinglinglingling
jinglinglingling force-pushed the linglinj/pr-b-reinforce-pp-forest branch from 2945ed2 to 9e4eefd Compare December 4, 2026 09:28
@jinglinglingling

Copy link
Copy Markdown
Contributor Author

/ok to test 9e4eefd

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) 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