Repository navigation
Conversation
Forest training was GRPO-only. A PPO run now runs GAE on every physical row with that row's own critic values; the logical owner still decides validity, so a filtered segment masks all of its owner's rows. - ppo.adv_estimator.normalize_over: kept_rows (default) or all_rows, which also whitens over rows masked from the loss. Execution padding never counts. - The critic takes every Forest row as one optimizer step. - Forest row padding covers the critic's DP and microbatch sizes too. - The complete-group check now runs on the PPO path as well. - Forest requires ppo.value_training_mode=whole_batch: its row padding covers the whole step, while split mode shards each chunk on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…tics Execution padding and failed owners' borrowed inputs run through the model, so with expert-bias updates enabled their tokens count toward the router's expert loads. Forest keeps counting them by default, as ordinary training does. token_capture.exclude_padding_from_router_stats opts into masking them. The finalizer publishes router_excluded_rows for Forest rows; the policy and a PPO critic then fetch it, and the Megatron microbatch builder gives those rows no router-visible tokens in the existing padding mask, packed or not. The critic also masks sequence-packing padding. Both workers check the mask only with the option on, and raise an error naming it when the model cannot honour it, such as an expert-bias MoE with HybridBlock chunkwise context parallelism. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Forest pads every published group to the policy and critic row multiple. With one rollout per group, most rows a step trains on are then padding: a DP of 4 turns ~154 real rows into ~512. token_capture.forest_padding_scope: step pads each training batch once instead. Pad rows copy real rows under new sample IDs with no loss, borrowed-input tags, and router exclusion flags; token_capture.forest_pad_source picks row0 or cyclic copies. ppo.adv_estimator.whiten_execution_padding lets those copies join all_rows whitening. Defaults are unchanged. A rollout snapshot taken during a step accepts that step's padding copies (<sample_id>_padN) of replayed rows, and restore deletes them before checking the replay inventory. Full trainer checkpoints run after the step clears its padding and stay strict. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
SingleController PPO rejects a rollout-failure drop budget because the critic expected a full step. A Forest critic trains on the step's actual rows, so a short step fits and Forest PPO now accepts the budget. Streaming PPO selects chunks in multiples of whole prompt groups so the rows split evenly across the policy and critic data-parallel ranks. Forest groups vary in row count and execution padding already aligns each chunk to both models, so that alignment only held back ready groups, rejected some num_prompts_per_step values, and made the sampler raise once a dropped rollout shrank the step. Forest streaming PPO now selects any group count, as streaming GRPO does. With forest_padding_scope=step, each chunk is padded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Unit tests, as PPO counterparts of the Forest GRPO tests: - Full-batch PPO trains every segment row per epoch and the critic takes the step's rows (gbs = rows); streaming PPO steps the policy once and trains the critic on all chunks after the refit. - Invalid logical batches and all-invalid owners never train either model; a partial step trains the critic on the surviving rows. - Whole-owner overlong filtering; the GAE advantage stage is never sharded. - Forest PPO startup rejections, policy/critic padding validation order, checkpoint restore with a critic, the critic row multiple pinned in data-plane checkpoints, and value-loss equivalence across packing bins and segments. Functional tests, both in L1_Functional_Tests_SingleController_3: - ppo_async_gym_single_controller_context_compaction.sh: PPO (GAE, Megatron critic) on the context-compaction Forest rows, two steps with checkpoints, then a resume to step 4. Its config, examples/nemo_gym/ppo_qwen3_0_6b_single_controller.yaml, composes the PPO SingleController exemplar with the Gym GRPO config. - grpo_async_gym_single_controller_context_compaction_resume.sh: the same checkpoint/resume for Forest GRPO. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Forest training rejected reward penalties. They now run on Forest owners: rollout-scoped text checks and token checks run once on the scored segment, and the owner's rows share the resulting reward. token_capture.forest_penalty_scope chooses which segments the token checks cover: scored_segment (default) or all_segments, where a hit in any segment zeroes the owner's reward. Penalty counts ride the scored row so the finalizer metrics count each owner once. Forest results keep scalar fields only, so the duplicated-reasoning and empty-final-answer checks run on the agent's scored response when Gym post-processes the receipt, and are passed to compute_reward_checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…uo/forest-ppo-penalty
whiten_execution_padding only changes whitening under Forest step padding, normalize_over=all_rows only with normalize_advantages=true, and the legacy PPO entrypoint reads neither. Reject each of these at startup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…on note PPO advantages are per physical row, each row a GAE episode, and Forest PPO needs whole_batch critic training. Restore the truncation and unsupported-features paragraph, which also applies to PPO overlong filtering. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…ler exemplars Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…sets The critic's method also sets its router padding-mask flag, so call it configure_forest_router_padding; setup calls the policy's check and the critic's setup by their own names. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…loss With every microbatch size 1 the run never padded. A critic microbatch of 2 and step-scope padding pad steps with an odd row count, in the checkpointed run and the resumed one. The critic-loss check gets an upper bound. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Full-batch and streaming PPO: the padding copies reach the policy and the critic, the critic gbs counts them, and the step deletes them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Main moved rollout checkpointing into nemo_rl/algorithms/rollout_checkpointing (#5011). Step padding handling of the replay inventory check now lives in rollout_checkpointing.inventory.validate_replay_inventory, called from the restorer ("clear") and the snapshotter ("allow"). Forest's estimator check keeps main's new seq_logprob_error_in_loss rejection. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
The stage zeroed advantages outside the mask by multiplying with it, so a dataset loss weight of 0.5 scaled the stored advantage again on top of GAE and the loss. Zero the tokens outside the mask without rescaling the rest. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
The inventory exception for forest_padding_scope=step also applied to full trainer checkpoints, so an extra _pad row passed the save check and restore deleted it. A full checkpoint never owns a streamed step's rows, so gate the exception on a rollout snapshot on save and from_rollout_snapshot on restore. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
raw_reward reads neither normalize_over nor whiten_execution_padding, so setting them promised a whitening change that never happened. Fail at config validation instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
The PPO exemplar and three guide summaries said every logical rollout keeps one advantage, which only holds for GRPO. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
…uo/forest-ppo-penalty Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
- List token_capture.forest_penalty_scope in the single-controller exemplars. - Say text penalties read the scored response, not a segment. - Set scored_text_checks on both receipt paths and index it, so a missing key fails instead of silently recomputing. - Cover penalize_malformed_think_tag at Forest startup and pin once-per-owner penalty counts when two segments hit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
Add the continued_chains selection policy, which trains the scored chain and one continued chain per other root (for example, subagents), and token_capture.max_rows_per_rollout, which keeps the scored root plus the first N-1 other roots. Both non-default policies now name the scored call through resolve_scored_terminal: a witness first, else the parent-link heuristic. A rollout neither stage resolves, or whose declared terminal no witness confirms, is masked instead of failing the run. Receipts record the stage that named the scored call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
bg51717
left a comment
There was a problem hiding this comment.
Claude self-review of the continued_chains selection policy and max_rows_per_rollout.
The design fits the existing code:
resolve_scored_terminalis the right shared place to name the scored call;all_capturedandcontinued_chainsboth use it.- A new policy is one function plus one line in
SELECTION_POLICIES. cap_selected_rootsis a pure filter that runs after selection, with its own unit test.- The typed
TerminalNotIdentifiedkeeps "mask this rollout" apart from "crash the run". select_continued_chainsis a pure function and easy to test.
Comments:
- (C1) PR description: say that
finalize/terminal_selection_*shifts away fromdeclaredfor existing Forest runs. - (C2) Add one env-level test for
continued_chainswithmax_rows_per_rollout. - (C3) Mask the rollout, instead of crashing, on a Gym attribution method
_RECEIPT_METHODdoes not know; name the Gym source. - (C4) Clear
terminal_model_call_idwhen a declared terminal cannot be confirmed. - (C5) Use
_LENGTH_FINISH_REASONSinselect_all_capturedtoo. - (C6) Optional: reject
max_rows_per_rolloutunlessselection_policyiscontinued_chains. - (C7) PR description: list every setting the source recipe needs.
- (C8) Follow-up: count the chains that
continued_chainsand the cap drop.
Not blocking: please add a short continued_chains + max_rows_per_rollout: 16 run to the PR description, reporting rows per rollout, the heuristic fraction of terminal_selection, and the terminal_not_identified count.
Nothing was run locally for this review.
Generated by Claude Code
| elif self._max_rows_per_rollout is not None: | ||
| selected = cap_selected_roots( | ||
| selected, terminal_response_id, self._max_rows_per_rollout | ||
| ) |
There was a problem hiding this comment.
C2 · 1 action item (missing test).
TL;DR — No test runs this cap branch. Every env fixture sets _max_rows_per_rollout = None, so cap_selected_roots is only tested by calling it directly.
The fixtures that set it to None are at test_forest_dispatch.py#L59, test_logical_owner_finalization.py#L383 and test_nemo_gym_token_capture.py#L38. The direct test is test_cap_keeps_the_scored_root_first. Also, no continued_chains test through the env has an untrainable side call, and none stamps admitted_at in a different order from the manifest.
AI-1
Add one env-level test after test_cap_keeps_the_scored_root_first. It covers the cap, an untrainable side call and admission order in one rollout. It uses only helpers the file already imports, and copies the manifest override from test_selected_forest_boundaries.py#L519-L530. Not run. This can't be a suggestion block because the test goes in a different file from this anchor.
def test_continued_chains_cap_counts_roots_in_admission_order(forest):
# Main A -> scored B; worker C -> failed D; single-call workers E and F.
records, replies = forest.capture([None, 0, None, 2, None, None])
manifest = forest.harness.manifest("attempt").model_dump(mode="json")
# Admission order E, C, F differs from manifest order C, E, F.
for index, admitted_at in enumerate([1.0, 2.0, 4.0, 5.0, 3.0, 6.0]):
manifest["records"][index]["admitted_at"] = admitted_at
manifest["records"][3].update(response_status="failed", finish_reason="stop")
env = _env(forest.harness)
env._selection_policy = "continued_chains"
env._max_rows_per_rollout = 3
env._control = AsyncMock(return_value=manifest)
output = ordinary(replies[:2])
output["reward"] = 1.0
processed = asyncio.run(
env._postprocess_receipt_mode({"_ng_rollout_id": "attempt"}, output)
)
# The failed D ends C's chain without masking; the cap keeps the scored
# root plus the two earliest-admitted other roots (E, then C) and drops F.
assert processed["receipt"]["capture_poisoned"] is False
assert processed["logical_selection"].response_ids == tuple(
records[i].response_id for i in (0, 1, 4, 2)
)Why the expected selection is A, B, E, C
- Scored chain:
replies[1]attributes B by response id, so the chain is [A, B]. _trainabledrops the failed D. The other roots sort byadmitted_at: E (3.0), C (4.0), F (6.0). C has no trainable child, so its chain is [C].- The cap of 3 keeps root A plus the first two other roots, E and C, and drops F.
- If the sort ignored
admitted_at, C would come before E. If the cap branch did not run, F would stay. If D poisoned the owner,capture_poisonedwould be True. - Unchecked: whether Gym's manifest validation accepts a rewritten
admitted_at(aStrictFloatfield). Existing tests rewriteresponse_statusthe same way.
There was a problem hiding this comment.
Fixed in cd6a79f. Added test_continued_chains_cap_counts_roots_in_admission_order as suggested; it passes.
- Fail loudly on a Gym attribution method the receipt table does not know. - Clear terminal_model_call_id when the scored terminal is not identified. - Share LENGTH_FINISH_REASONS across call_selection.py and nemo_gym.py. - Require selection_policy=continued_chains for max_rows_per_rollout. - Test the row cap through the env, with admission order and a failed side call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: bg51717 <[email protected]>
|
/ok to test cd6a79f |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
Two selection-boundary bugs need fixes. There's also a non-blocking request for training evidence:
- (C9) Missing completion metadata is silently excluded instead of reaching validation.
- (C10) A settled cancellation on a root excluded by the cap still masks the rollout.
- (C11) The new training policy needs measured throughput and reward trade-offs.
The self-review fixes for clearing unattributed terminals and restricting the cap to its supported policy are present in the current source.
I inspected all 14 changed files across three review topics and traced the affected configuration, selection, receipt, row-planning, and cleanup paths. Validation was static only: I couldn't run tests or lint, and I haven't independently verified the reported test results or CI status. The mounted Gym submodule directory is empty, so I couldn't independently inspect its resolver implementation.
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.
|
|
||
| def _trainable(record: CallRecord) -> bool: | ||
| """Completed, or stopped by a length limit; anything else ends its chain.""" | ||
| return record.response_status == "completed" or ( |
There was a problem hiding this comment.
C9 · 1 action item (BUG; PR-introduced).
TL;DR — Missing completion metadata silently removes calls from training instead of raising a validation error.
In this predicate, a missing status returns false. For capture parents [None, 0, None], score call 1 and set independent call 2's status to None: the root filter drops call 2 before the adapter's completion checks see it. An incomplete call with no finish reason is hidden the same way. Missing evidence should remain an error, distinct from a known unsuccessful execution, as the existing missing-leaf-evidence regression establishes for the neighboring policy.
AI-1
Action: Reject missing completion metadata before deciding whether a call should end its chain. Replace the anchored return line with this insertion, keeping the remainder of the expression:
| return record.response_status == "completed" or ( | |
| if record.response_status is None: | |
| raise ValueError("Capture is missing completion metadata") | |
| if record.response_status == "incomplete" and not record.finish_reason: | |
| raise ValueError("Incomplete capture is missing its finish reason") | |
| return record.response_status == "completed" or ( |
Keep known failed, unknown, and non-length incomplete calls excluded. Completed and length-limited calls must remain eligible; failed scored calls and scored ancestors must still reach the adapter's masking checks.
Acceptance — proposed checks, not executed: Exercise missing status on an independent root and a side child; expect an error matching completion metadata. Repeat with incomplete status and a missing or empty finish reason; expect finish reason. Completed calls lacking output evidence must still raise. Retain the failed-call regression's selection [0, 1, 2], and check unknown and content-filtered calls end chains too. Each of the three supported length finish reasons must remain trainable. Retain the cap regression's unpoisoned receipt and order (0, 1, 4, 2). Verify the suggested code before adopting it.
| if any(f.model_call_id in selected_call_ids for f in parsed.failures): | ||
| capture_failed = True | ||
| selected = [] | ||
| elif self._max_rows_per_rollout is not None: |
There was a problem hiding this comment.
C10 · 1 action item (BUG; PR-introduced).
TL;DR — A settled cancellation on a root the cap would drop still masks the whole rollout.
The failure check runs before the cap. With two completed independent roots A and B, score A, set the cap to 1, and record a settled cancellation failure for B with no pending calls. Cancellation after a committed capture is an existing supported outcome. B is initially selected, so the failure check clears the selection and skips the cap; the receipt becomes capture_incomplete. A should remain trainable because B is outside the capped selection, matching the documented cancellation exception.
AI-1
Action: Apply the cap before checking failures against final selected membership in this block, then recompute the selected IDs. Keep the earlier global capture checks and selection validation unchanged: pending writes, missing captures, and other capture failures must mask regardless of the cap.
The reorder spans lines outside this comment's single-line anchor, so the complete replacement is shown as a diff:
- if any(f.model_call_id in selected_call_ids for f in parsed.failures):
- capture_failed = True
- selected = []
- elif self._max_rows_per_rollout is not None:
+ if self._max_rows_per_rollout is not None:
selected = cap_selected_roots(
selected, terminal_response_id, self._max_rows_per_rollout
)
+ selected_call_ids = {r.model_call_id for r in selected}
+ if any(f.model_call_id in selected_call_ids for f in parsed.failures):
+ capture_failed = True
+ selected = []Acceptance — proposed checks, not executed: Capture [None, None], score A, record the settled cancellation for B, and cap at 1. Expect an unpoisoned receipt, only A selected, one valid training row, and cleanup of both roots' staging. With cap 2 or no cap, expect masking because B remains selected. A cancellation on retained A must mask. Pending B, missing capture evidence for B, and a non-cancellation capture failure on B must still mask with cap 1. Retain the existing cap test's unpoisoned receipt and order (0, 1, 4, 2). Verify the patch before adopting it.
| forest_pad_source: Literal["row0", "cyclic"] = "row0" | ||
| # continued_chains only. Max rows per rollout: the scored chain plus the | ||
| # first N-1 other chains, in selection order. None keeps every chain. | ||
| max_rows_per_rollout: Optional[PositiveInt] = None |
There was a problem hiding this comment.
C11 · 1 action item (PERF-EVIDENCE; non-blocking validation gap).
TL;DR — The new training policy and row cap have unit-test results, but no measured training trade-offs.
The new settings change which sessions contribute loss. The supplied description and comments report unit-test counts, but no comparative throughput or reward results. The pinned review policy requires quantitative evidence for a new training feature.
AI-1
Action: Add a small comparison to the PR description on a representative subagent task: use the same model, hardware, seed, and training budget with the existing all-captured policy versus the continued-chain policy capped at 16. Report selected rows per rollout, training throughput or step time, and reward/evaluation results over a stated interval. Keep unrelated training settings fixed and leave the shipped defaults unchanged. This is an operational evidence request, not an in-place code edit, so it cannot be a suggestion block.
Acceptance: Include the commands or config differences, commits, hardware, and measured results for both runs, and explain the observed trade-off. Unit-test counts alone don't satisfy this check. These measurements weren't run in this review.
What does this PR do ?
Adds opt-in Forest row selection for rollouts that run independent sessions, such as subagents: a
continued_chainsselection policy that trains each session as its own row, andtoken_capture.max_rows_per_rolloutto cap rows per rollout. Training with the default policy is unchanged; one receipt metric shifts (see the last change below).The behaviour comes from Jiaqi Zeng's SWE PPO branch (fab3ba82d); its recipe corresponds to
selection_policy: continued_chains,max_rows_per_rollout: 16,forest_penalty_scope: all_segments(#5068) andmask_retried_roots: true(#5069).Stacked on #5068.
Changes
continued_chains. The scored chain comes first and holds only the scored call's ancestors; each other root descends to a unique leaf, preferring continued children. An ambiguous fork drops that root, a byte-identical retry is dropped, and a call that did not finish trainably ends its chain instead of masking the rollout.max_rows_per_rollout(continued_chainsonly). Keeps the scored chain plus the first N-1 other chains; other policies reject it at startup.terminal_response_idor the returned response),all_capturedandcontinued_chainsfall back to Gym'sselect_terminal_callparent-link heuristic; a rollout neither resolves is masked withfailure_reason: terminal_not_identified, and the receipt records which method named the terminal.finalize/terminal_selection_*shifts away fromdeclaredfor existing Forest runs.Usage
Testing
483689722: default lane 3146 passed, NeMo-Gym lane 769 passed.cd6a79f24:test_selected_forest_boundaries.py,test_logical_advantage.py,test_call_selection.pyandtest_nemo_gym_episode_collection.pyin both lanes (155 and 209 passed).Before your PR is "Ready for review"
Pre checks: