Repository navigation
fix(grpo): group env-reward baseline by prompt group ids - #4620
Merged
Merged
Conversation
#3882 switched calculate_baseline_and_std_per_prompt to group by prompt_group_ids and removed input_ids from _grpo_train_impl; #4553, merged right after, added the env-reward baseline call still passing input_ids. On main that is an undefined name (ruff F821, failing Lint check) and a NameError whenever grpo.length_penalty sets env_reward. Use repeated_batch[PROMPT_GROUP_IDS_KEY] there, and prompt_group_ids (instead of prompt token ids) for the same baseline in grpo_sync, so the env-reward baseline groups rows exactly like the main baseline. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zhiyu Li <[email protected]>
Contributor
Author
|
/ok to test 5328e0c |
yfw
approved these changes
Oct 9, 2026
ZhiyuLi-Nvidia
enabled auto-merge (squash)
October 9, 2026 04:44
alexandery-nvidia
added a commit
that referenced
this pull request
Oct 10, 2026
…lit baselines GRPO's baselines key on the explicit prompt-group ids since #3882 and #4620, so a per-rollout string in the harness prompt no longer splits a group into singleton baselines. The comment and the warning now say what the condition does mean: the rollouts of a group do not share a prompt prefix, so the engine's prefix cache and anything keyed on first-prompt tokens see one group per rollout. The test asserts the new wording. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
1 task done
alexandery-nvidia
added a commit
that referenced
this pull request
Oct 12, 2026
…lit baselines GRPO's baselines key on the explicit prompt-group ids since #3882 and #4620, so a per-rollout string in the harness prompt no longer splits a group into singleton baselines. The comment and the warning now say what the condition does mean: the rollouts of a group do not share a prompt prefix, so the engine's prefix cache and anything keyed on first-prompt tokens see one group per rollout. The test asserts the new wording. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
linj-glitch
added a commit
to linj-glitch/RL
that referenced
this pull request
Oct 13, 2026
main grew a fourth all-ones valid-mask site after NVIDIA-NeMo#4553/NVIDIA-NeMo#4620: the env_baseline that grpo.length_penalty keeps for the pct_* diagnostics. Pass the same participation mask there, so a masked row's env reward does not vote in its siblings' env baseline either. State the two rules the mask follows in the helper docstring and at both call sites. Participation is binary: a nonzero fractional loss_multiplier still counts as one vote, and the training loss weights are never changed. Truncated rollouts keep voting under overlong_filtering because the mask is taken before that rewrite, which is what docs/guides/grpo.md documents for these loops; the SingleController advantage_stage folds truncated rows into its valid_mask instead, and reconciling the two is left to the configurable policy work rather than decided here. Tests: fractional-nonzero versus zero loss weight, the truncated-row call-order rule, one driver test asserting the trivial check, the baseline/std and the env baseline all receive the mask (and that the env baseline of the real rows ignores the masked reward), a fractional case for the sync/async forwarding test plus an assertion that the forwarded sample_mask keeps the original weight, and a sync/async test that a truncated row votes in the baseline while overlong filtering removes it from the loss. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
linj-glitch
added a commit
to linj-glitch/RL
that referenced
this pull request
Oct 23, 2026
main grew a fourth all-ones valid-mask site after NVIDIA-NeMo#4553/NVIDIA-NeMo#4620: the env_baseline that grpo.length_penalty keeps for the pct_* diagnostics. Pass the same participation mask there, so a masked row's env reward does not vote in its siblings' env baseline either. State the two rules the mask follows in the helper docstring and at both call sites. Participation is binary: a nonzero fractional loss_multiplier still counts as one vote, and the training loss weights are never changed. Truncated rollouts keep voting under overlong_filtering because the mask is taken before that rewrite, which is what docs/guides/grpo.md documents for these loops; the SingleController advantage_stage folds truncated rows into its valid_mask instead, and reconciling the two is left to the configurable policy work rather than decided here. Tests: fractional-nonzero versus zero loss weight, the truncated-row call-order rule, one driver test asserting the trivial check, the baseline/std and the env baseline all receive the mask (and that the env baseline of the real rows ignores the masked reward), a fractional case for the sync/async forwarding test plus an assertion that the forwarded sample_mask keeps the original weight, and a sync/async test that a truncated row votes in the baseline while overlong filtering removes it from the loss. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
mainfails Lint check at39eeee7eb(#4553):This is a semantic conflict between two PRs that merged back to back:
calculate_baseline_and_std_per_promptto group byrepeated_batch[PROMPT_GROUP_IDS_KEY]and removedinput_idsfrom_grpo_train_impl.grpo.length_penalty) that still passesinput_ids.Besides failing lint, that path raises
NameErrorwheneverenv_rewardis set.Fix (2 lines)
grpo.py: the env-reward baseline groups byrepeated_batch[PROMPT_GROUP_IDS_KEY], the same key as the main baseline just above it.grpo_sync.py: the same baseline useddriver_carry["prompt_ids_for_adv"](prompt token ids). It now usesprompt_group_ids, which the main baseline and dynamic sampling already use, so all three group rows the same way.ruff checkpasses on both files. This also unblocks lint on PRs based on currentmain(e.g. #4618).🤖 Generated with Claude Code