Repository navigation
fix(nemo-gym): read first-class sample mask flags - #4435
Conversation
linj-glitch
left a comment
There was a problem hiding this comment.
Team review covered RL correctness, an independent bug/API scan, test/design perspective, existing discussion, and an independent devil’s-advocate challenge. Reviewed first-class mask_sample consumption and the legacy extras fallback; no blocking findings remain on the final reviewed head.
The additive main merge preserves all author commits.
Validation: 1 focused CPU tests passed. All formatting, lint, TOML, and recipe-minimization hooks passed. The pinned pyrefly0.24.2 check reports the same 34 diagnostics on main and this branch, from unavailable optional/native dependencies; there are no new diagnostics. No local GPU/model run was performed. Required repository CI remains the merge gate.
|
/ok to test f0a65f4 |
|
/ok to test 18d8a52 |
linj-glitch
left a comment
There was a problem hiding this comment.
Rechecked the final head after updating against main f04e61b. Author history is preserved by additive main merges. No blocking logical issues remain in the reviewed changes.
Local validation: (3 durations < 0.005s hidden. Use -vv to show these durations.)
=========================== short test summary info ============================
PASSED tests/unit/experience/test_rollouts.py::test_mask_sample_flags_read_the_first_class_field_with_the_extras_fallback
1 passed, 53 deselected, 24 warnings in 7.50s
. Formatting, lint, TOML, and recipe-minimization hooks passed. Pinned pyrefly has the same 13 diagnostics as current main in this local environment, with no introduced diagnostics. No fresh GPU/model training was run. Required repository CI is awaiting test-environment approval; this approval does not bypass that merge gate.
|
Reviewed head 37398b1. The first-class and legacy nested mask flags are correctly OR-ed across batched rollouts, SingleController payloads, and capture finalization. The opt-out strips both forms without mutating the original results, preserving the flagged-rate metrics. Local CPU validation passed: 24 focused repository tests, 30 additional boundary probes, and 90 related tests (with some overlap); no fresh GPU training. No blocking findings in this diff. This PR fixes mask-field ingestion; excluding masked rewards from siblings’ baseline/std and advantages is already tracked in #4061 and addressed by the open draft PRs #4490 and #4160. Our local estimator reproduction confirms that existing issue. It is not a new finding or a blocker introduced by this PR. Those estimator fixes complement this PR’s ingestion changes. |
37398b1 to
93c1fae
Compare
|
/ok to test 93c1fae |
NeMo-Gym's BaseVerifyResponse now carries mask_sample as a first-class typed field, and Gym-side evaluation aggregation reads it there. The rollout paths read only the response-extras mapping instance_config.mask_sample, so an environment that sets the first-class field is silently trained on. All three readers now prefer the first-class field with the instance_config mapping as the fallback: _mask_sample_flags on the rollout path, and the mask-gate drop plus the sibling-seal read in the rollout manager. The gate tests carry both forms and a new unit test pins the precedence. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: alexandery <[email protected]> (cherry picked from commit 079b9f5f3699c5649bbc7a532d231f6c17937c29)
…s when the gate is off With env.should_mask_flagged_samples: false the single-controller path popped the flag out of each result's full_result before the per-agent metrics were computed, so <agent>/mask_sample/* and the flag's column in the full_result table disappeared exactly in the mode that exists to watch a flag too coarse to honor; the batched path kept them. The gate now works on copies handed to the completions, and _compute_rollout_metrics aggregates the results the caller still holds (full_results), so the completions carry no flag while the metrics still report the flagged rate. From review as well: the docstring and the flag test described a precedence between the first-class field and instance_config.mask_sample that the code never implemented. Both reads are OR-ed on purpose, because Gym serializes mask_sample: false on every response, so a nested-only environment carries a false first-class field beside the true nested one; the test now carries that row. The receipt fixture carries both forms so the receipt branch's handling of the first-class field is observed, and the capture-manager helper can spread verify-response fields, so the sibling-seal read is pinned with the first-class form and the disagreeing row. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test e488c1b |
93c1fae to
e488c1b
Compare
…-truncated-by-status RL #4435 merged on main as c30bbd4 and appended a test to the rollouts unit-test file where this branch had appended its own; both sides stay. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…failures-and-redispatch RL #4435 merged on main as c30bbd4 and appended a test to the rollouts unit-test file where this branch had appended its own; both sides stay. Two redispatch tests stubbed `_compute_rollout_metrics` with a positional-only lambda; main's #4435 passes the aligned Gym results to it by keyword (`full_results`), so the stubs now accept keyword arguments. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…roups-distinct-first-prompts RL #4435 merged on main as c30bbd4 and appended a test to the rollouts unit-test file where this branch had appended its own; both sides stay. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ta-step-metrics RL #4435 merged on main as c30bbd4 and appended a test to the rollouts unit-test file where this branch had appended its own; both sides stay. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection Brings #4446's merge of main after RL #4435's squash (c30bbd4): main's appended rollouts test and this stack's appended tests both stay, and the redispatch tests' metric stubs accept the keyword argument main now passes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…xandery/gym-rollout-metrics-hook Brings the stack's merge of main after RL #4435's squash (c30bbd4). In _compute_rollout_metrics main now builds the per-agent rows from the full Gym results when the loop passes them, so the mask flag the completion conversion drops is still reported; those rows feed this branch's shared per_agent_result_metrics helper, which keeps the union of keys and the masked-row exclusion. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
…s rollout metrics Main now passes full_results to _compute_rollout_metrics and computes per-group reward diagnostics from each result's full_result (#4435). This test predates that and still stubbed the old signature and built results without full_result, so it failed in CI's Nemo Gym unit lane after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
What does this PR do?
NeMo-Gym's
BaseVerifyResponsecarriesmask_sampleas a first-class typed field, and Gym-side evaluation aggregation reads it there. The rollout paths in NeMo-RL read only the response-extras mappinginstance_config.mask_sample, so an environment that sets the first-class field is silently trained on.All three readers now consult both forms:
_mask_sample_flagson the rollout path (nemo_rl/experience/rollouts.py), and the mask-gate drop plus the sibling-seal read in the rollout manager (nemo_rl/experience/rollout_manager.py). The two reads are OR-ed rather than ordered, because Gym serializesmask_sample: falseon every response, so an environment that flags onlyinstance_config.mask_samplecarries a false first-class field beside the true nested one. Withenv.should_mask_flagged_samples: false, the single-controller path drops both forms from the completions it builds (on copies of the results) while its per-agent metrics still report the flagged rate from the results themselves, as the batched path does. No configuration change; an environment emitting either form is masked.Issue
No issue filed; found while training with a Gym resources server that sets the first-class field (its verifier masks rollouts whose evaluation infrastructure failed).
Validation
tests/unit/experience/test_rollouts.py,tests/unit/experience/test_rollout_manager.py,tests/unit/experience/test_reward_penalties.py,tests/unit/test_effort_shaping.py: 173 passed on this branch. The flag test carries the disagreeing row (mask_sample: falsebeside a true nested flag) and asserts it is flagged. The gate tests carry both forms on the token fixture and on the receipt fixture; a gate-off test asserts that the completion carries no flag whileagent/mask_sample/meanis still reported; the finalization-request test passes the first-class form and the disagreeing row and expects both flagged.🤖 Generated with Claude Code
Maintainer validation
Team review covered RL correctness, an independent bug/API scan, test/design perspective, existing discussion, and an independent devil’s-advocate challenge. Reviewed first-class mask_sample consumption and the legacy extras fallback; no blocking findings remain on the final reviewed head.
The additive main merge preserves all author commits.
Validation: 1 focused CPU tests passed. All formatting, lint, TOML, and recipe-minimization hooks passed. The pinned pyrefly0.24.2 check reports the same 34 diagnostics on main and this branch, from unavailable optional/native dependencies; there are no new diagnostics. No local GPU/model run was performed. Required repository CI remains the merge gate.