Repository navigation
feat(single_controller): support group length penalties - #5206
Conversation
0029e2f to
10ea96d
Compare
10ea96d to
85ed9ab
Compare
|
/ok to test 85ed9ab |
|
/ok to test 481eb39 |
85ed9ab to
481eb39
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
One test-contract bug needs fixing before merge.
- (C1) The new capture regression test reads length metrics from the wrong output dictionary, so both parameter cases fail instead of checking metric parity.
The review covered all 18 changed files and their affected setup, rollout, Forest, checkpoint, and metric paths. One delegated reviewer finished without a delivered report; I inspected that topic directly. Validation was static only: tests and linters weren’t executed, and CI results weren’t available.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for reusing the existing group length-adjustment algorithms across the SingleController rollout paths.
The reported 100-step ordinary/capture on/off runs and independent reward/advantage comparisons make the adjustment mechanism clear.
CI is red. The redispatch unit test fails on the new _length_penalty_config read because its fixture bypasses the constructor; initialize impl._length_penalty_config = None in test_rollout_generation_failures.py:558–588. Other failed jobs include Ray startup, vLLM initialization and GPU-test timeouts; these do not establish additional length-penalty regressions.
Scope: group length penalties across ordinary, capture, Forest and checkpoint paths, at 481eb39.
Checked:
- Traced ordinary and capture reward ordering, low-effort bypass and Forest metadata preparation through publication.
- Confirmed the capture adapter reuses the shared adjustment algorithm with separately supplied lengths.
length_penalty.py:429–468 - Confirmed the current loader accepts version-1 and version-2 reward settings.
reward_penalties.py:330–355 - Inspected checkpoint comparison and existing coverage statically; no tests were run on this host.
Remaining comments are on:
- Defer Forest support: reject Forest plus length penalties at setup and remove this PR's Forest-specific support; preserve the metadata-loss diagnosis for the follow-up.
- Write the missing ordinary low-effort marker so reward behavior agrees with capture.
- Unify length and effort checkpoint representations, exclude logging-only settings from compatibility checks, and consistently write v2 while retaining v1 loading.
- Add or update an enabled nightly and cover changed coefficients and absent-to-enabled checkpoint settings.
- Simplify the reward-evidence dataclasses, share profile-field extraction, and remove the unreachable fallback.
nit
- Complete public-interface docstrings, shorten the added function-body comments and qualify the PPO-only diagnostic.
- Optional, nonblocking follow-up: let the adjustment core consume typed inputs directly, with the legacy dictionary entry point as its wrapper.
Generated by Codex (#4999 version)
|
/ok to test cd2118a |
cd2118a to
b1f5792
Compare
|
/ok to test b1f5792 |
1 similar comment
|
/ok to test b1f5792 |
b1f5792 to
fabab92
Compare
Address review on #5206: - Keep length-penalty metrics out of token_metrics; read the pooled finalize/length_penalty/*_sum in the data-plane reassembler test. - Reject token_capture.forest_training together with grpo.length_penalty at config validation, drop the Forest-specific length aggregation/broadcast, remove the Forest length-penalty test and add a config-rejection test, and update docs. Forest length penalties are deferred to a follow-up. Signed-off-by: ruit <[email protected]>
fabab92 to
03a6ec1
Compare
…tation Address review on #5206 (checkpoint representation): - Store length-penalty checkpoint settings in a frozen LengthRewardSettings dataclass (like effort), holding the exclude_unset reward rules and excluding the logging-only verbose flag, so a logging change no longer blocks resume. - Always write version 2 (with a null length_penalty when none) and keep backward-compatible version-1 loading; compare the normalized projection. - Cover changed coefficients, absent-to-enabled and logging-only changes; update the single-controller guide. Signed-off-by: ruit <[email protected]>
…ction Address review on #5206: extract the task-data merge and the three profile-field reads into a shared length_profile_fields helper, used by both the SingleController prepare_length_penalty_input path and the legacy rollout path, so the outer-field precedence and missing-to-None rules live in one place. Signed-off-by: ruit <[email protected]>
Address review on #5206: _apply_effort_shaping classified low effort but never wrote result["low_effort_applied"], so the group length penalty could not bypass low-effort rollouts on the ordinary and legacy paths the way the capture path does (it reads RewardChecks.low_effort). Record the classification per rollout before the missing-length guard, and cover the marker for low/high effort and disabled shaping. Signed-off-by: ruit <[email protected]>
- Keep length-penalty metrics out of token_metrics; read the pooled finalize/length_penalty/*_sum in the data-plane reassembler test (C1). - Defer Forest length penalties: reject token_capture.forest_training together with grpo.length_penalty at setup, drop the Forest-specific aggregation and test, and add a config-rejection test. - Unify the length-penalty checkpoint representation with a frozen LengthRewardSettings projection that excludes the logging-only verbose flag, always write version 2 with backward-compatible version-1 loading, and cover changed/absent/logging-only compatibility. - Share the profile-field extraction via length_profile_fields across the SingleController and legacy rollout paths. - Write the ordinary low-effort marker so the group length penalty bypasses the same rollouts as the capture path. - Nits and dead code: remove the unreachable chars fallback, complete public docstrings, shorten an over-long comment, and qualify the PPO-only diagnostic. Signed-off-by: ruit <[email protected]>
0f98f6a to
5a816da
Compare
… post-init checks Address review on #5206: remove the construct-time type checks on RewardChecks and LengthPenaltyInput, and RewardChecks.from_state. Rebuild the saved reward checks (and their optional LengthPenaltyInput) directly at the recovery restore site instead. Signed-off-by: ruit <[email protected]>
- Keep length-penalty metrics out of token_metrics; read the pooled finalize/length_penalty/*_sum in the data-plane reassembler test (C1). - Defer Forest length penalties: reject token_capture.forest_training together with grpo.length_penalty at setup, drop the Forest-specific aggregation and test, and add a config-rejection test. - Unify the length-penalty checkpoint representation with a frozen LengthRewardSettings projection that excludes the logging-only verbose flag, always write version 2 with backward-compatible version-1 loading, and cover changed/absent/logging-only compatibility. - Share the profile-field extraction via length_profile_fields across the SingleController and legacy rollout paths. - Write the ordinary low-effort marker so the group length penalty bypasses the same rollouts as the capture path. - Drop the construct-time type checks on RewardChecks and LengthPenaltyInput and RewardChecks.from_state; rebuild saved reward checks at the recovery site. - Nits and dead code: remove the unreachable chars fallback, complete public docstrings, shorten an over-long comment, and qualify the PPO-only diagnostic. Signed-off-by: ruit <[email protected]>
5bb0e2d to
d0e227f
Compare
- Keep length-penalty metrics out of token_metrics; read the pooled finalize/length_penalty/*_sum in the data-plane reassembler test (C1). - Defer Forest length penalties: reject token_capture.forest_training together with grpo.length_penalty at setup, drop the Forest-specific aggregation and test, and add a config-rejection test. - Unify the length-penalty checkpoint representation with a frozen LengthRewardSettings projection that excludes the logging-only verbose flag, always write version 2 with backward-compatible version-1 loading, and cover changed/absent/logging-only compatibility. - Share the profile-field extraction via length_profile_fields across the SingleController and legacy rollout paths. - Write the ordinary low-effort marker so the group length penalty bypasses the same rollouts as the capture path. - Drop the construct-time type checks on RewardChecks and LengthPenaltyInput and RewardChecks.from_state; rebuild saved reward checks at the recovery site. - Nits and dead code: remove the unreachable chars fallback, complete public docstrings, shorten an over-long comment, and qualify the PPO-only diagnostic. Signed-off-by: ruit <[email protected]>
Address review on #5206: the unsupported-feature entry read "length_penalty", so the error named the bare key. Use "ppo.length_penalty" so the message points at the exact config path the run must disable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
- Bootstrap restart: _normalize_capture_reward_config now drops the length-penalty verbose flag from the bootstrap identity, so a verbose-only change no longer rejects the restart before the sidecar compare. Extend test_capture_bootstrap_uses_semantic_reward_settings to cover it. - Drop test_restore_rejects_malformed_reward_checks: the decoder no longer validates the raw record, so the test's expectation was stale. - Move the length projection onto LengthRewardSettings.from_configs, narrow the capture factory's length input to LengthPenaltyConfig | None, and rebuild the saved length config via LengthPenaltyConfig.model_validate in from_state. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
e79b1e6 to
b3f7694
Compare
|
/ok to test b3f7694 |
|
/ok to test 1d13e96 |
Signed-off-by: ruit <[email protected]>
- Keep length-penalty metrics out of token_metrics; read the pooled finalize/length_penalty/*_sum in the data-plane reassembler test (C1). - Defer Forest length penalties: reject token_capture.forest_training together with grpo.length_penalty at setup, drop the Forest-specific aggregation and test, and add a config-rejection test. - Unify the length-penalty checkpoint representation with a frozen LengthRewardSettings projection that excludes the logging-only verbose flag, always write version 2 with backward-compatible version-1 loading, and cover changed/absent/logging-only compatibility. - Share the profile-field extraction via length_profile_fields across the SingleController and legacy rollout paths. - Write the ordinary low-effort marker so the group length penalty bypasses the same rollouts as the capture path. - Drop the construct-time type checks on RewardChecks and LengthPenaltyInput and RewardChecks.from_state; rebuild saved reward checks at the recovery site. - Nits and dead code: remove the unreachable chars fallback, complete public docstrings, shorten an over-long comment, and qualify the PPO-only diagnostic. Signed-off-by: ruit <[email protected]>
Add a 1n8g Qwen3-1.7B SingleController Gym recipe that turns grpo.length_penalty on, plus its nightly driver and nightly.txt entry. length_penalty requires env.should_use_nemo_gym=true on SC (config.py) but not token capture, so this runs the workplace_assistant Gym env with capture off; the penalty is applied on the no-receipt rollout path (rollout_manager.py). vLLM generates, Megatron trains. Thresholds come from a measured 100-step run: gen_kl_error median 0.0017, reward mean 0.15, adjusted_frac peaked at 0.375, reward_delta_mean at machine epsilon (zero-centred), and the vLLM decode length fell from 35 to 3 tokens. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
Address review on #5206: the unsupported-feature entry read "length_penalty", so the error named the bare key. Use "ppo.length_penalty" so the message points at the exact config path the run must disable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
Strip the keys that already equal the inherited base (token_capture off, data_plane block, generation backend/vllm defaults, tp/pp sizes) so the recipe passes configs-minimize-check. The resolved config is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
- Bootstrap restart: _normalize_capture_reward_config now drops the length-penalty verbose flag from the bootstrap identity, so a verbose-only change no longer rejects the restart before the sidecar compare. Extend test_capture_bootstrap_uses_semantic_reward_settings to cover it. - Drop test_restore_rejects_malformed_reward_checks: the decoder no longer validates the raw record, so the test's expectation was stale. - Move the length projection onto LengthRewardSettings.from_configs, narrow the capture factory's length input to LengthPenaltyConfig | None, and rebuild the saved length config via LengthPenaltyConfig.model_validate in from_state. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
test_length_penalty_metadata_survives_sealed_attempt_restore seals a receipt with attempted call IDs, which reaches the optional nemo_gym staging import in _receipt_staging_keys. Every other _forest_sealed_ledger caller carries the marker; add it so the test runs in the nemo_gym shard instead of L0 Other. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
The recipe pinned env.nemo_gym to 10000-10999, which test_example_service_port_ ranges_are_isolated rejects (gym ports must stay in the below-9000 layout, 5000- 5999 by default). Drop the override so the recipe inherits the isolated default. Signed-off-by: ruit <[email protected]>
1d13e96 to
673d462
Compare
|
/ok to test 673d462 |
… richer gates Extend the windowed/ready_first dynamic-sampling nightlies from a 10-step smoke to a 100-step convergence run (one job, no checkpoint chaining) and gate on the same shape as the dapo-nanov3.5 SC nightly, calibrated to this llama3.1-8b run: all-steps-reached, finite loss/token_mult_prob_error, median and final-step token_mult_prob_error < 1.05, grad_norm still positive, an unfiltered_reward floor, a zero_variance_groups_total floor that proves dynamic sampling actually filtered, no skipped steps or dropped prompt groups, and a step-time perf guard. No max(token_mult_prob_error) gate: a single ready_first step spikes the ratio, which median and all_finite tolerate. Bump the nightly GPU-hour cap to 5400 to fit the two 100-step runs (32 GPU-hrs each) on top of the current baseline and #5206's length-penalty nightly, which merges first. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
… richer gates Extend the windowed/ready_first dynamic-sampling nightlies from a 10-step smoke to a 100-step convergence run (one job, no checkpoint chaining) and gate on the same shape as the dapo-nanov3.5 SC nightly, calibrated to this llama3.1-8b run: all-steps-reached, finite loss/token_mult_prob_error, median and final-step token_mult_prob_error < 1.05, grad_norm still positive, an unfiltered_reward floor, a zero_variance_groups_total floor that proves dynamic sampling actually filtered, no skipped steps or dropped prompt groups, and a step-time perf guard. No max(token_mult_prob_error) gate: a single ready_first step spikes the ratio, which median and all_finite tolerate. Bump the nightly GPU-hour cap to 5400 to fit the two 100-step runs (32 GPU-hrs each) on top of the current baseline and #5206's length-penalty nightly, which merges first. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
…warning Since #4429 a materialized task row carries no agent_ref, so the warning, which read row["agent_ref"]["name"], raised KeyError for a group of such rows whose first prompts differ. It now reads the attribution key that _postprocess_single_nemo_gym_group stamps on every result (the agent of a flat row, the taskset of a materialized task), reports once per key, and says "attribution key(s)" in the message. The test covers a group of materialized task rows. Two tests that main added (#4500, #5206) run _run_rollouts on results that carry tokens with no tokenizer. The diagnostic pads the first prompts with the tokenizer's pad id, so both tests get the tokenizer stand-in that the other tests of this path use. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ecks main's #5206 added RewardChecks.length_penalty after this branch was cut. _reward_checks_state listed the three boolean fields by hand, so a checkpoint written with it dropped the length-penalty input and a resumed run restored that attempt without its length penalty. Copy the field the way dataclasses.asdict does. Cover a real LengthPenaltyInput in the projection, capture and restore tests, and expect the multi_harness_routes key main's #5158 added to the recovery state. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
What
Adds per-prompt-group length penalties for GRPO on the SingleController path
(both the ordinary and the token-capture rollout paths). It rewards conciseness
among correct generations: a group-relative, zero-centered reward adjustment
that shortens correct rollouts while never lifting or sign-flipping a wrong
one, and never touches non-binary / multi-component reward groups.
Channels (all per-agent configurable,
grpo.length_penalty):tokens/chars/all_generated_tokensHow it integrates
token-capture path discards the response envelope) and threads it through the
capture/reassembly pipeline on the existing
RewardChecks/CaptureRewardSettingscarriers (capture sidecar bumped v1→v2,backward-compatible, checked on resume via
require_compatible).(
apply_group_length_penalties/apply_group_length_penalties_from_inputs).Verification
apply_group_length_penaltiesto ~2e-16 across mixed-reward topologies(all-correct, mixed, all-wrong, <2-positive early return).
with a 0/1 reward decorrelated from length, per-rollout reward and GRPO
advantage match the independent mixed-reward oracle to <1e-7; correct
rollouts are shortened while wrong rollouts stay at exactly 0; the
capture/finalizer path is healthy. This validates the mechanism
(reward-gating + advantage consumption), not task-quality gains.
E2E experiment config
Reuses the 1-node / 2-GPU Qwen3-0.6B NeMo-Gym functional-test topology (1 trainer,
1 generator). A test-only verifier returns reward = parity of
sha256(answer_text)→{0, 1}(~50% positive, decorrelated from length), sothe length signal is isolated from task correctness while the env reward genuinely
varies. Auxiliary reward terms are disabled so the advantage is a transparent
function of the length penalty.
Qwen/Qwen3-0.6B, NeMo-Gym single-tool-call, test verifier abovemax_num_steps=100,num_prompts_per_step=4,num_generations_per_prompt=4adv_estimator=grpo,normalize_rewards=false,use_leave_one_out_baseline=false, no advantage cliplength_type=all_generated_tokens,group_total_length_penalty_coeff=0.2train_global_batch_size=16,micro=1,max_total_sequence_length=1024,max_new_tokens=256, constantlr=2e-6reference_policy_kl_penalty=0,positive_example_nll_weight=0,use_importance_sampling_correction=falseasync_rl.log_full_train_data=true(per-sample JSONL the oracle checks)W&B runs (
nvidia/nemo-rl-sc-length-penalty)Penalty on, measured on this PR's
main-based branch:Control arms with the penalty off (same verifier): generation length is not
systematically reduced and the adjusted reward equals the raw
{0, 1}env reward(reward/advantage error exactly 0). Across on-runs the
<2-positiveearly-returnpath is exercised ~120×/run, and
length_penalty/skipped_non_binary_frac == 0.ordinary path
Token capture path
Nightly result
Notes
main; no dependency on fix(single_controller): drop the slot of a below-threshold finalizer group #4958.🤖 Generated with Claude Code
Validation
Ran the shipped length-penalty nightly end to end on 1n8g (Qwen3-1.7B, vLLM gym, capture off). All metric gates pass; the group length penalty rewrites rewards (adjusted_frac peaks at 0.375), stays zero-centred (reward_delta_mean at machine epsilon), and the vLLM decode length falls from 35 to 3 tokens over 100 steps.
W&B run: https://forge.coreweave.com/wandb/nvidia/nemo-rl-sc-length-penalty/runs/r6103tcc