Repository navigation
feat(capture): support reward penalties and effort shaping - #4099
Conversation
45aef0a to
877707f
Compare
|
/ok to test 8c66da0 |
|
/ok to test 518b9e7 |
macandro96
left a comment
There was a problem hiding this comment.
Merge conflicts — this PR currently shows as CONFLICTING/DIRTY against main. The conflicts are narrow (2 files: nemo_rl/algorithms/single_controller.py, tests/unit/experience/test_rollout_reassembler_actor.py), but please rebase before further review.
Reviewed by a team of specialized agents (RL expert, bug finder, test agent, design reviewer) with an adversarial pass to stress-test every finding before posting. A few notes that didn't make it into inline comments:
Credit: _abandon_entire_group now also clears attempt.mask_sample (rollout_recovery.py:459), which incidentally fixes a pre-existing latent restore bug (verified against the base commit).
Credit: reward_penalties.py has no capture-vs-inline conditionals — the detectors, membership checks, and effort formula are single implementations shared by both paths, backed by a genuine differential parity harness rather than just coverage.
No convergence/A-B run requested: all new flags default off, so this PR is a no-op unless opted into, and the reward math is closed-form and pinned by exact parity tests (including one asserting real GRPO advantage values with unchanged tokens/logprobs).
Test evidence: 786 tests run locally (785 passed, 1 skipped), zero never awaited warnings. Pre-commit: all hooks pass clean.
Generated by Claude Code
518b9e7 to
1df0a0a
Compare
1df0a0a to
bad4645
Compare
|
/ok to test bad4645 |
@pthombre, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test 5818ddb |
@pthombre, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test 5818ddb |
abfb290 to
4efa3c6
Compare
Support duplicated-reasoning, empty-final-answer, and unwanted-token reward penalties on the token-capture path, and make effort shaping match non-capture rollouts for equivalent scored trajectories. - Share text detectors, token membership, original-prompt classification, and the effort formula between both paths in reward_penalties.py. - The manager saves the raw reward and one three-boolean RewardChecks record; sibling/prompt-group recovery and finalizer requests carry it. - After Gym verifies the selected chain, the finalizer shapes using the terminal generated span, then zeroes the reward for any enabled penalty. - Save and compare reward settings once per checkpoint (recovery schema 6); pool valid-row reward/penalty statistics and effort-length frequencies across recovery without double counting. Squash of the five original PR commits for the rebase onto main. Signed-off-by: Pranav Prashant Thombre <[email protected]>
…test main made is_final_checkpoint a required keyword of SingleControllerActor._save_checkpoint (#4213 lifecycle changes); the rebased PR test still used the old two-argument form and failed with a TypeError in the Slurm verification run. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…chema
Address the second review round on the capture reward-penalty PR:
- Release pending finalizer metrics and reward observations for groups
that leave the replay buffer without being trained on: pop them when a
committed group falls below min_valid_fraction_per_group, and prune
them against the live buffer after stale eviction.
- Renumber the rollout recovery sidecar to schema 3 and accept only the
current schema. reward_settings, finalizer_metrics_by_group and
finalizer_rewards_by_group are now required sidecar keys; a sidecar
saved with capture disabled is rejected under capture with a specific
error.
- CaptureRewardSettings.from_state accepts only version-1 records. The
bootstrap identity builds its projection from the typed config models
in a dedicated _normalize_capture_reward_config helper.
- Drop the redundant finalize/reward_{count,sum,sumsq,min,max} group
statistics; aggregate_capture_reward_metrics derives every reward
statistic from the retained per-row observations, which are now
required.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>
main migrated MasterConfig.logger from a TypedDict to the LoggerConfig model, so the capture controller must use attribute access when deciding whether to log full-result tables. main also made the advantage stage require a group_id tag on every row, so the recovered-statistics pump test stamps one per group. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
4efa3c6 to
2ba5bf1
Compare
|
/ok to test 2ba5bf1 |
@pthombre, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test 2ba5bf1 |
|
/ok to test 2ba5bf1 |
Reconciles the straggler cutoff with what main gained on the NeMo-Gym rollout path since the branch was cut: reward penalties and effort shaping (NVIDIA-NeMo#4099), per-prompt-group length penalties (NVIDIA-NeMo#4553) and per-agent token metrics (NVIDIA-NeMo#4379). - A cut placeholder is not a model output. _postprocess_single_nemo_gym_group now runs effort shaping and the reward-penalty checks over the scored rows only, and reports the penalty rates over that population, so an empty placeholder response is not counted as an "empty final answer". Cut rows also stay out of main's new per-agent token/truncation metrics, alongside the existing exclusion from the per-agent full_result means. Length penalties need no change: they only adjust rows with a positive reward. - Token-capture (receipt) mode is unsupported: a cancelled rollout has no receipt for the finalizer to rebuild. The actor now logs once and runs the batch uncut, the same fallback as a Gym without aclose(); the warning text names the reason. Tests: receipt-mode fallback; penalty rate and rewards with a cut row under penalize_empty_final_answer; per-agent gen-token mean excludes the cut row. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
What does this PR do?
Support duplicated-reasoning, empty-final-answer, and unwanted-token reward penalties on the token-capture path, and make effort shaping match non-capture rollouts for equivalent scored trajectories.
Capture previously shaped rewards using accumulated response usage. For a low-effort rollout with call lengths 900 then 100, raw reward 1, and
low_weight=low_penalty=1,low_ub=1000, capture now produces 1.9, matching the standard path's terminal-call length.RewardChecksrecord. Existing sibling/prompt-group recovery and finalizer requests carry this record.No environment reward plumbing, per-rollout fingerprints, additional token fetches, tokenizer decoding, or Gym/vLLM schema changes. Captured tokens, logprobs, and masks retain their existing behavior.
Issues
No linked issue.
Usage
Use the existing
reward_penaltiesflags andenv.nemo_gym.effort_levelssettings. Defaults are unchanged; active shaping requireslow_ub > 0. See the Single-Controller guide.Before your PR is "Ready for review"
Additional Information
Validation for
e3ad0eaa807e59a6c53dc5e6caa4929fc938c60e(identical code tree to the previously tested commit; Git identity corrected): 1,772 distinct tests passed, counting the latest result of each test after targeted fixes.Coverage includes all eight penalty combinations; positive/zero/negative rewards; disabled, low, and high effort; unequal call lengths; missing/misleading usage; both recovery modes; exact pooled medians; and metrics consumed once. Live TQ tests feed published rewards into the real GRPO advantage estimator and assert unchanged tokens, logprobs, and masks.
Recovery schema 5 saves the combined checks. Legacy capture checkpoint migration is outside scope. Malformed-thinking penalties and message-level advantage overrides remain unsupported with capture. Validation does not include full model generation/training or convergence measurements.
The latest follow-up adds the missing copyright header to
tests/unit/experience/test_capture_reward_penalties.py, fixing the copyright CI failure. Tests were not rerun for this header-only change.