Repository navigation
feat(grpo): add full-group std, vLLM per-sample caps, placeholder prompt checks - #5092
Conversation
|
/ok to test 5e9a0f8 |
|
/ok to test f340c3d |
vmendelev
left a comment
There was a problem hiding this comment.
Self-review before human review, as requested on #4748.
The PR adds three opt-in features and keeps current behavior by default. The full-group std estimator, the per-sample output caps on the sync path and the placeholder-aware prompt check are each covered by focused unit tests. CI lint, semantic-title and DCO checks pass at this head.
- (C1) Per-sample
max_output_tokenscaps are dropped on every async-rollout path, and non-vLLM backends do not raise there. - (C2)
full_group_std: truewithnormalize_rewards: falseis accepted but has no useful effect. - (C3) Low priority: unquantized refit still imports the FP8 module in
_weight_update_lifecycle.
Scope: this review covers three findings. Four review lanes (RL expert, bug finder, test agent, design reviewer) were stopped before they finished, so the review is not a full pass. The three findings come from their partial notes and repro logs; each was checked against the code at this head and challenged by one devil's-advocate pass. The lanes ran as independent Cursor subagents, not as a Claude Code agent team. None of the three findings affected the research recipe's GPU validation in #4748, which uses the sync rollout path, keeps normalize_rewards: true, and imports FP8 without error.
Generated by Claude (Cursor agent) using the review-pr-team skill
|
/ok to test c5d1c14 |
|
/ok to test 1e79ee1 |
yuekaizhang
left a comment
There was a problem hiding this comment.
Thanks — this is a clean split out of #4748. Solid points worth calling out: defaults are pinned by tests, the new validators reject misconfiguration loudly, and output_limits.py as a pure module makes the cap logic testable without an engine.
I also ran the suites on an 8xH100 node against the locked env (vLLM 0.29.0 / torch 2.13): 161 passed in the default lane and 215 passed in the vLLM lane — including test_vllm_unquantized_refit.py, which is vllm-marked and therefore wasn't covered by your local runs, and the three suites listed as "not verified locally" in the PR description (test_vllm_backend.py, test_vllm_refit_loader.py, test_vllm_utils.py). All green.
3 action items as inline comments (hf_overrides sibling call sites; sync/async cap divergence on exhausted context; Dynamo silently dropping caps). A few smaller suggestions I'll leave for a follow-up pass: eager validation of expanded_placeholder_token at _load_model time instead of first generate, zeroing invalid rows via is_trivial_distribution instead of the exact-float std > 0 contract, documenting that the cap is per-turn in multi-turn rollouts, and a couple of test gaps (notably: the [1] entry in the invalid-caps parametrize only passes via the length-mismatch branch — cap=1 is never actually tested as valid).
…holder-aware prompt validation - adv_estimator.full_group_std normalizes GRPO advantages by the sample std of all valid rewards in the group (default off); applied in grpo and grpo_sync. - extra_env_info["max_output_tokens"] caps one sample's response length in the sync and async vLLM workers, composed with the context and speculative limits; other backends raise. - vllm_cfg.expanded_placeholder_token lets rollout prompt validation accept a single declared media-placeholder expansion. - Generation-only vllm_kwargs.hf_overrides are merged with policy overrides instead of being replaced; unquantized refit no longer imports FP8; the mm_device_do_normalize default is only set when vLLM supports it. Signed-off-by: Valentin Mendelev <[email protected]>
Signed-off-by: Valentin Mendelev <[email protected]>
Async rollouts built each turn without extra_env_info, so max_output_tokens caps never reached generation and non-vLLM backends never raised. Pass the sample metadata into the turn and check the backend once per batch, where the error cannot be swallowed by the per-turn handler. Signed-off-by: Valentin Mendelev <[email protected]>
Without reward normalization the full-group std is never applied, so reject the combination instead of accepting a no-op. Signed-off-by: Valentin Mendelev <[email protected]>
_weight_update_lifecycle imported the FP8 module on every standard refit. Import it only when the model has a quant_config, and cover the lifecycle in the unquantized refit test. Signed-off-by: Valentin Mendelev <[email protected]>
Signed-off-by: Valentin Mendelev <[email protected]>
…setup Signed-off-by: Valentin Mendelev <[email protected]>
Signed-off-by: Valentin Mendelev <[email protected]>
Signed-off-by: Valentin Mendelev <[email protected]>
1e79ee1 to
7deed80
Compare
|
/ok to test 7deed80 |
|
@yuekaizhang thanks for the review and the H100 run. I rebased the PR onto main, which is now on vLLM 0.33, and replied in the three threads. From the smaller suggestions:
I left load-time |
|
CI label:
|
main renamed VllmGeneration.dynamo_frontend_url to the dynamo_frontend_urls tuple (#5115), so the test no longer routed through Dynamo and failed on the missing async_engine key. Signed-off-by: Valentin Mendelev <[email protected]>
|
/ok to test 97e439a |
The Dynamo frontend and non-vLLM backends reject per-sample max_output_tokens caps, but the native multi-turn turn handler caught the ValueError and returned an empty, zero-reward rollout. Raise UnsupportedOutputCap (a ValueError) at both rejections and re-raise it past the per-turn catch, with a regression test through _run_multi_turn_rollout_async. Signed-off-by: Valentin Mendelev <[email protected]>
test_output_limits.py and test_rollout_prompt_validation.py matched no unit-test shard: the vLLM base run selects test_vllm*.py, the Models shard ignores generation/, and the tests carry no backend marker. Contents unchanged. Signed-off-by: Valentin Mendelev <[email protected]>
vmendelev
left a comment
There was a problem hiding this comment.
The pure cap helper and shared HF override merger keep these changes testable and consistent across entry points.
- (C4) Async multi-turn rollouts swallow driver-side cap rejection and return empty responses.
- (C5) Unit CI skips 30 new regression cases.
Four collaborating agents plus the lead covered seven review roles. Repository pre-commit checks and 569 focused/base unit tests passed locally. Fresh real-engine vLLM/refit tests were not run; the linked research training results use an older stack.
nemo-rl-review: kind=self harness=codex/0.159.2 model=gpt-6.1-sol effort=medium review-pr-team=v3 reviewed=6834488
|
/ok to test 9161821 |
…std-vllm-fixes Signed-off-by: Valentin Mendelev <[email protected]> # Conflicts: # tests/unit/single_controller/test_setup.py
|
/ok to test 138ed91 |
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main; the PR is 15 commits behind and the "Check if PR branch is up to date" job allows at most 10.
Thanks for moving the generic pieces of #4748 into core: a full-group std option for GRPO, per-sample output caps for vLLM rollouts and placeholder-aware prompt validation, each off by default.
Thanks also for the two self-review rounds done before this pass.
Scope: the whole diff, at 138ed91
Checked:
- Full-group std math — groups with zero or one valid row never reach the new block, and the worked example in
grpo.mdrecomputes to the stated numbers. validate_rollout_prompt— it accepts exactly one run of the declared placeholder and rejects every other difference.- Cap plumbing on the legacy paths — caps stay with their rows through sharding, and a rejected cap cancels the sibling rollout tasks without leaving anything held.
- Shared vLLM fixes — all four setup paths go through
merge_vllm_hf_overrides, and thequant_config is Noneguards take the path an unquantized model already took. - Earlier review threads — all eight asks hold at this head, and the new and renamed test files pass in the head's CI lanes.
Remaining comments are on:
- Per-sample caps on SingleController rollouts.
full_group_stdtogether withuse_leave_one_out_baseline: false.full_group_stdarguments in the legacy trainers that nothing reads.- Test coverage of caps on the sync path.
- The vLLM version check around
mm_device_do_normalize.
nit
- Hard-wrapped paragraphs in
grpo.md. expanded_placeholder_tokenin the base configs.- Test file placement.
- An outdated comment in
rollouts.py. - A note in the base configs on how
vllm_kwargs.hf_overridesis merged. - The name of the per-sample cap key.
- A duplicated cap validation in the async worker.
nemo-rl-review: kind=expert harness=claude-code/2.1.332 model=claude-fable-5-2 effort=medium review-pr-team=v3 reviewed=138ed91
…std-vllm-fixes Signed-off-by: Valentin Mendelev <[email protected]>
- Apply per-sample output caps on SingleController rollouts, and stop the run on an unsupported cap instead of retrying or skipping the sample. - Rename the per-sample cap key to max_new_tokens_for_sample. - Reject adv_estimator.full_group_std unless use_leave_one_out_baseline is true (default null), and drop the unused full_group_std trainer arguments. - Validate caps once inside per_request_output_limits. - Restore the unconditional mm_device_do_normalize default for vLLM 0.33. - Add expanded_placeholder_token and the hf_overrides merge comment to the base configs. - Cover sync-path caps, and move the placeholder and hf_overrides tests next to the modules they test. Signed-off-by: Valentin Mendelev <[email protected]>
|
/ok to test 882a48a |
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for resolving the comments from the previous review.
Scope: fix commits 29d930a through 882a48a, checked against the open threads from the previous review, plus a scan of the changed files for new issues.
Checked:
- SingleController caps — the cap is read from the sample's current
extra_env_infoon every turn and reaches the async vLLM worker; Megatron, SGLang and Dynamo raiseUnsupportedOutputCap, which stops the run without a retry or a skip.rollout_manager.py:760 full_group_std—nullby default and rejected when set withuse_leave_one_out_baseline: false; no shipped config that turns leave-one-out off resolves to a set value.advantage_estimator.py:93- Moved tests — the placeholder and
hf_overridestests pass in the vLLM unit shards at 882a48a, and the worker test now also runs the async worker withexpanded_placeholder_tokenset.test_vllm_prompt_validation.py:174 - Merge of main — it did not touch the cap, estimator or
hf_overridescode paths.
LGTM — no remaining findings from this re-review.
nemo-rl-review: kind=expert harness=claude-code/2.1.333 model=claude-fable-5-2 effort=medium review-pr-team=v3 reviewed=882a48a
Resolve conflicts with #5092: - grpo.py, distillation.py: build vLLM hf_overrides with main's merge_vllm_hf_overrides (a new dict, so real quant can still add quantization_config without touching the policy's overrides); distillation keeps it before the real-quant policy is built. - vllm_backend.py: skip the FP8 reload conversion for real-quant weights or when vLLM has no quant_config. - test_vllm_backend.py: give the fake-quant FP8 reload test a quant_config, as main's FP8 reload tests now do. Signed-off-by: Meng Xin <[email protected]>
NVIDIA-NeMo#5092 added merge_vllm_hf_overrides and called it at the same four entry points (GRPO, PPO, distillation, SingleController setup) with a shallow merge where the policy value wins on a shared key. Keep main's name, signature and call sites, and give it this PR's reviewed behaviour: nested sub-configs merge key by key, and a leaf set to different values on both sides raises at setup. Drop merge_policy_hf_overrides and move its tests into test_vllm_config.py next to main's. Main's policy-wins tests (helper and SingleController) now use non-conflicting keys, and the base and reference config comments describe the error instead of "policy wins". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pa8JdzpuUd2BVbxJ8Anoba Signed-off-by: Shubhankar Tripathy <[email protected]>
What and why
GRPO training of speech models (#4748) needs three options that are not speech-specific, so this PR adds them to core. All three are opt-in and off by default, so current behavior is unchanged.
grpo.adv_estimator.full_group_std: truenormalizes GRPO advantages by the sample std (correction=1) of all valid rewards in the group, instead of the per-rollout leave-one-out std. The baseline is unchanged. Constant groups and masked rows get zero advantage. It requiresnormalize_rewards: trueanduse_leave_one_out_baseline: true, since without leave-one-out the per-rollout std already covers the whole group. Other estimators reject it, and the defaultnullleaves it off. The advantage estimator applies it on every training path.extra_env_info["max_new_tokens_for_sample"]. On both the legacy and SingleController rollout paths, the sync and async vLLM workers then generate at mostmin(max_new_tokens, cap)tokens for that sample, still bounded by the remaining context and the speculative-decoding margin. In multi-turn rollouts the cap applies to each turn. Samples without a cap keepmax_new_tokens. Dynamo serving and other generation backends raiseUnsupportedOutputCapinstead of dropping the cap, and the error stops the run rather than ending, retrying or skipping only that sample.policy.generation.vllm_cfg.expanded_placeholder_tokennames a media placeholder that the learner prompt keeps as one token while vLLM expands it into a contiguous run. Rollout prompt validation then accepts exactly that one expansion. When unset, prompts must still be token-identical.vllm_kwargs.hf_overrideskeys are merged withpolicy.hf_config_overridesinstead of being replaced, at every entry point (GRPO, PPO, distillation, single-controller setup). Policy keys win on shared keys.Docs:
docs/guides/grpo.mdgains a "Full-group standard deviation" subsection with a worked example, and a note on per-sample caps next toDatumSpec. The newvllm_cfgkey is documented inVllmSpecificArgsand set tonullin the base configs, which also say howvllm_kwargs.hf_overridesmerges withpolicy.hf_config_overrides, anddocs/guides/dynamo-generation.mdlists caps as unsupported.Usage
Issues
Part of the split agreed in #4748: generic pieces go to core, and the Transcribe-specific recipe moves to
research/.Convergence / perf / functionality proof
N/A for convergence and speed: the three features are off by default, and unit tests pin the default behavior. Without opting in, behavior changes only where it was broken: generation-only
hf_overrideskeys that were silently dropped now reach vLLM.Functionality is covered by new unit tests:
tests/unit/algorithms/test_full_group_std.pytests/unit/experience/test_rollout_output_caps.pyTestOutputCapsintests/unit/experience/test_rollout_generation_failures.py, for SingleController caps and the run-terminalUnsupportedOutputCaptest_sync_rollout_forwards_output_caps_to_vllmandtest_async_rollout_forwards_output_caps_to_vllmintests/unit/experience/test_rollouts.pytests/unit/models/generation/test_vllm_output_limits.py, which covers sync caps with and withoutcap_max_tokens_to_contextand the async captests/unit/models/generation/test_vllm_prompt_validation.py, on both the sync and async workershf_overridesmerge tests intests/unit/models/generation/test_vllm_config.pytest_vllm_dynamo_rejects_per_sample_output_capsandtest_vllm_dynamo_output_cap_rejection_stops_async_rolloutintests/unit/models/generation/test_vllm_generation.pytests/unit/models/generation/test_vllm_unquantized_refit.pyChecks run locally:
882a48a7e, the current head, which addresses the Nov 28 review and mergesmainat02eb4d933: 4705 unit tests acrosstests/unit/experience,tests/unit/algorithms,tests/unit/single_controller/test_setup.py, the rollout reassembler, the config tests and the vLLM cap, prompt-validation and config tests pass. 6 draft-loss and x_token tests that this PR does not touch fail only because the local environment lacks Megatron. Thevllm-marked tests in the touched vLLM test files (211) and the Dynamo tests (11) pass. Pre-commit and ruff pass on the changed files, and pyrefly reports no new errors in them.138ed912f, which fixes the two self-review findings and mergesmainatd2313cca4: 1658 unit tests (all oftests/unit/experience,tests/unit/single_controller/test_setup.py, the rollout reassembler, and the cap and prompt-validation tests) and the Dynamo cap tests pass. Pre-commit and ruff pass on the changed files, and pyrefly reports 0 errors over the whole project.0721c31c78, which mergesmainatda067f1331: pyrefly 1.4.0 over the whole project,ruff checkandruff format --check(0.9.9) on the changed files, and 485 focused unit tests (this PR's tests,test_setup.py, the hf-override handoff tests and the advantage-stage test). All pass.7deed809f, before the two latest merges ofmain: the default unit lane passed (1285 passed, 1 skipped). On vLLM 0.33.0, main's pin, the fast generation tests passed (44) and the GPU vLLM lane had 226 passed and 1 failed. The failure,test_vllm_policy_generation_with_fastokens_enabled, fails while Ray starts its worker in my local environment, before any code from this PR runs.Needs upstream changes
None.
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.