Repository navigation
fix(rollouts): retry masked infrastructure faults and report unsettled masked rows - #6070
Conversation
A masked row whose failure_kind is namespaced (<env>:<reason>) was never retried, even when its environment recorded failure_outcome_action=retry, because only registered kinds were accepted. Accept a namespaced kind when the retry action is recorded. Rows without that declaration keep the masked result as before. Signed-off-by: Adam Rajfer <[email protected]>
…ranscript A masked row whose agent stage failed with the retry action keeps the partial transcript of the failed attempt, which the saved-answer rule treated as an answer, so it was never retried. Read the stage from the failure events and do not treat that transcript as an answer. Verification-stage masks keep their saved answer. Signed-off-by: Adam Rajfer <[email protected]>
…tled A result masked by an evaluation-side failure kind that used every attempt of its cap stayed a settled masked success and coverage reported complete=true. Report it as masked_exhausted and leave it out of the settled count, so a strict run is incomplete until a recovery with --extend-attempts measures it. Signed-off-by: Adam Rajfer <[email protected]>
A masked result whose producer recorded failure_outcome_action=fail (a defect in the task data) already stops recovery, but coverage still counted it as settled. Report it under masked_failed and masked_failed_kinds and leave it out of the settled count, so the run is not complete. Rows without the action are unchanged. Signed-off-by: Adam Rajfer <[email protected]>
… model A namespaced failure kind with the retry action was retried whatever its attribution. A model-attributed failure is scored, not retried, so retry a namespaced kind only when its owner recorded retry and did not attribute the failure to the model. A missing attribution is handled as for a registered kind: the owner's retry decides. Signed-off-by: Adam Rajfer <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE — Two RISK findings remain: a valid namespace still bypasses the new retry support, and the saved-completion gate can accept unsettled masks when intentional omissions are present.
I inspected all six changed files and traced retry admission, selected-attempt accounting, strict completion, and aggregation. This was a static review; I didn't execute tests.
Inline comments (escaped v1):
-
nemo_gym/rollouts/rollout_recovery.pyline 464: RISK — Restrict the transport exclusion to built-in transport kinds.The new namespaced-kind admission is still defeated when an environment's namespace starts with
transport_. For example, save{"reward":0,"mask_sample":true,"failure_kind":"transport_demo:time_cap","failure_outcome_action":"retry","failure_outcome_attribution":"evaluation"}without a response. This is valid under the namespace grammar, but this prefix check rejects it. Consequently, the Store keeps the masked result instead of scheduling another attempt. The newly supported contract should honor that environment's explicit retry declaration.Could you replace this condition with:
or (not is_namespaced(kind) and kind.startswith("transport_"))This preserves the built-in transport exclusion and leaves the saved-answer protection intact.
Proposed acceptance checks: add
transport_demo:time_capto the namespaced retry test, expecting pending attempt(1, 1),masked_retryable=1, and aresubmitdecision for every attribution. Withoutretry, or withretryplus a completed saved answer, the same namespace must remain kept with no pending attempt. Built-intransport_timeoutmust remain excluded from agent reruns, and saved verification answers must retain their re-verification behavior. These checks are proposed, not executed. -
nemo_gym/cli/eval.pyline 821: RISK — Apply the new settled count to the saved-completion gate too.For a stored inventory containing one measured result, one producer-failed mask, and one intentional omission, coverage now reports
expected=3,successful=2,masked_failed=1,intentionally_omitted=1, andcomplete=false. This branch nevertheless returns successfully because it tests2 + 1 == 3. The same problem affectsmasked_exhausted. A custom collection driver that returns normally reaches this final strict check, so intentional omissions can hide the newly unsettled results and let an incomplete strict run exit successfully.Could you calculate
completed = _settled_count(report)inside this branch, pass it tohas_only_intentional_gaps, and use it in the rejection message? Also change the helper's final term tocoverage.get("final_zeros", 0): this file-based gate accepts older/minimal coverage reports without that field, as covered by the existing saved-completion test. The invariant is that an omission may fill an intentional gap, but cannot make an unsettled mask count as completed.Proposed acceptance checks: write the coverage above and call
_check_saved_completion; expectIncompleteEvaluationErrorwith1/3, not a normal return. Repeat withmasked_exhausted=1. Preserve acceptance of measured results plus intentional omissions, legacy masks without an action plus omissions, and settled final zeros plus omissions. Preserve rejection of an all-omitted run and compatibility with reports missing the newer counters. These checks are proposed, not executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
oyilmaz-nvidia
left a comment
There was a problem hiding this comment.
Review comments below.
| if self.disposition(identity) == "success" | ||
| ) | ||
| settled = counts["success"] - masked_retryable + final_zeros | ||
| # Masked by infrastructure at its attempt cap: a final failure, never measured, so the run is not complete |
There was a problem hiding this comment.
A masked result can be counted as both masked_exhausted and masked_failed, so settled subtracts it twice. masked_exhausted needs masked_infrastructure and a spent attempt cap; masked_failed_kind needs only mask_sample, failure_outcome_action == 'fail' and _ng_failure_class is None. A row with a registered evaluation-side kind (e.g. session_lost) and fail can satisfy both, and settled = successful - masked_exhausted - masked_failed.total() + final_zeros removes it twice. completion_fraction comes out too low, and the completed figure in IncompleteEvaluationError and has_only_intentional_gaps is wrong. Could you make the two categories mutually exclusive, and add a test for the overlap?
There was a problem hiding this comment.
Thanks. As the code stands I could not construct the overlap: a row with failure_outcome_action == fail never qualifies as masked_infrastructure, because _masked_evaluation_side_kind rejects fail first. You are right that nothing enforced it structurally, though, so masked_failed now skips any row already counted as retryable or exhausted, and each unsettled rollout is subtracted once. Added a test that forces the overlap (it fails without the change). Fixed in 5b3719d.
| and (_holds_saved_answer(row) or has_recorded_grade(row) or keeps_partial_response(row)), | ||
| masked_infrastructure=masked_infrastructure, | ||
| rerun_approved=rerun_approved, | ||
| masked_failed_kind=( |
There was a problem hiding this comment.
A masked fail row now makes the whole run permanently incomplete, but this path doesn't set retryable=False or name the cause. _settled_rejection picks its guidance from retryable, and the fallback text blames "terminal failures, omissions and exhausted budgets" without mentioning a masked fail. Strict runs and CI that passed with masked results before will now raise IncompleteEvaluationError with a message that doesn't point at masked_failed_kinds. Could the message name it?
There was a problem hiding this comment.
Agreed that the message should name the cause. Both rejections (collector and the strict-run re-check in the CLI) now append the masked_failed_kinds with counts. One difference from the suggestion: I did not describe a masked fail as retryable. It is final by the producer's decision, so --extend-attempts does not reopen it and the message says to fix or drop those rows. The infrastructure-masked results that spent their budget are named separately, and that message points at --extend-attempts. Test added. 5b3719d.
| model-class kind, no kind, an unregistered or namespaced kind, and the kinds whose saved answer is graded again | ||
| (``_MASKED_REGRADE_KINDS``, including a ``transport_*`` verify call) keep the masked row as the result. So does a | ||
| saved answer (``_keeps_saved_answer``): it is never sampled again, whatever its verifier could grade of it. | ||
| model-class kind, no kind, an unregistered kind, a namespaced kind without a recorded ``retry`` or attributed to the model, and the kinds |
There was a problem hiding this comment.
The docstring says an owner's retry is "honored whatever the attribution", but namespaced_retry requires failure_outcome_attribution != MODEL. A namespaced retry attributed to the model is kept, while a registered retry attributed to the model is retried. Either the docstring or the namespaced behavior should change so the two kinds are treated consistently.
There was a problem hiding this comment.
The behavior is intentional: a registered kind's recorded retry is honored whatever the attribution, while a namespaced kind has no registry entry to vouch for it, so a model-attributed namespaced retry is kept. The docstrings were wrong, not the code; both now say exactly that. 5b3719d.
| flag = row.get("_ng_collected_saved_answer") | ||
| if isinstance(flag, bool): | ||
| return flag | ||
| if failure_stage(row) == "agent" and row.get("failure_outcome_action") == OutcomeAction.RETRY: |
There was a problem hiding this comment.
This returns False for any agent-stage retry when _ng_collected_saved_answer isn't set, even if the row holds a complete, graded saved answer. It then becomes masked_retryable and is sampled again, overwriting that answer. The result also differs depending on whether the collector projected the flag (flag wins) or not (this branch wins). Is discarding a graded answer intended here? If so, a comment and a test would help.
There was a problem hiding this comment.
Good catch, this was a bug. A graded answer must never be re-sampled. _keeps_saved_answer now returns True for any row with a recorded grade (evaluation_completed) before looking at the collector flag or the agent-stage rule, so the flag and the no-flag path agree. Test covers both. 5b3719d.
| is masked by the Environment Server that graded it, is no failure row, omitted stand-in or re-judgment, and its | ||
| ``failure_kind`` is registered, evaluation-side through the shared classifier, not one whose saved answer is graded | ||
| again (``_MASKED_REGRADE_KINDS``) and not a ``transport_*`` verify call. | ||
| ``failure_kind`` is registered (or namespaced, with the ``retry`` action its owner recorded and no model attribution), evaluation-side through |
There was a problem hiding this comment.
This docstring line is well over the repo's 119-character limit (ruff format doesn't rewrap docstrings). The masked_infrastructure_kind docstring has one too.
There was a problem hiding this comment.
Rewrapped both docstrings (this one and masked_infrastructure_kind). 5b3719d.
| expected=completion["expected"], | ||
| results=persisted_results, | ||
| completed=completion["successful"] - completion.get("masked_retryable", 0) + completion["final_zeros"], | ||
| completed=completion["successful"] |
There was a problem hiding this comment.
The completed-count arithmetic is repeated inline here instead of calling _settled_count from nemo_gym/cli/eval.py. The next masked bucket then has to be added in three places (coverage(), _settled_count, this expression), and if one is missed the CLI and the collector disagree on whether a run is complete. Could the helper move to a shared module, or coverage() return a settled field?
There was a problem hiding this comment.
Went with your second option: coverage() now returns a settled field, and the collector and both CLI uses read it. _settled_count is gone, so a new masked bucket only has to be added in coverage(). Documented in resume.mdx. 5b3719d.
| "failure_budget_exhausted": sum(c["failure_budget_exhausted"] for c in components) | ||
| if inventory_known | ||
| else None, | ||
| "masked_exhausted": sum(c.get("masked_exhausted", 0) for c in components) if inventory_known else None, |
There was a problem hiding this comment.
The aggregated coverage now adds masked_exhausted, masked_failed and masked_failed_kinds. Do the aggregated settled and completion totals use them too? If they still compute successful - masked_retryable + final_zeros, a multi-benchmark run could report complete while the per-component stores say it isn't. I didn't trace this in the diff, so this is a question.
There was a problem hiding this comment.
The aggregated report does not compute a settled total at all. complete is all(c["complete"] for c in components), so every shard's own coverage() verdict (which includes the masked buckets) decides, and a multi-benchmark run cannot report complete while a component says it is not. masked_exhausted, masked_failed and masked_failed_kinds are summed only for display. No change.
| _rejudge_saved_judge_failures(global_config_dict, output, config) | ||
|
|
||
|
|
||
| def _settled_count(coverage: dict) -> int: |
There was a problem hiding this comment.
_settled_count(coverage: dict) has an untyped dict parameter; Mapping[str, Any] would fit, since it's read with both [] and .get. The docstring only says masked results that are retryable or exhausted aren't settled, but masked_failed is excluded too. Please mention it, and keep the line within 119 characters.
There was a problem hiding this comment.
The helper was removed by the change above, so the typing and docstring points no longer apply. 5b3719d.
- Count a masked result once in the settled arithmetic: masked_failed no longer includes a row already counted as retryable or exhausted. - Report settled in the coverage and read it from the collector and the CLI instead of repeating the arithmetic. - Keep a graded saved answer (evaluation_completed) for a masked agent-stage retry, with or without the collector's saved-answer flag. - Name masked_failed_kinds and the exhausted masked results, and what reopens them, in the incomplete-run messages. - Align the retry-attribution docstrings with the behavior and wrap over-long docstring lines. Signed-off-by: Adam Rajfer <[email protected]>
…omission The strict saved-completion gate compared the completed count with the omissions, so an omission could hide an exhausted or producer-failed masked result and an incomplete strict run passed. It now uses the settled count of the coverage report and names the unsettled masked results in its message. Signed-off-by: Adam Rajfer <[email protected]>
The transport_ exclusion is for the built-in verify-call kinds. A namespaced kind such as transport_demo:time_cap is valid, so it now follows the retry action its owner recorded. Signed-off-by: Adam Rajfer <[email protected]>
|
Two more fixes, both also flagged in the automated review: Follow-up, found while tracing the CI review, rollout_recovery.py ~464 ( |
|
🤖 Adam’s AI assistant @oyilmaz-nvidia thanks for the review. Your points are addressed in ec6fcba, with a reply on each thread. The required checks pass. The two red checks are the non-blocking harness-conformance job, which fails the same way on main right now. Could you take another look when you have a moment? |
Signed-off-by: Adam Rajfer <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
giuliolovisotto
left a comment
There was a problem hiding this comment.
Reviewed dba8cf3f990b3e691a25b64b9dbc87b1b5207aa3 against efd41fa1612f7138b8bfd4c8d9d9bc559503a4c3 with ponytail-review. No blocking findings in the final diff.
Traced masked retry admission through the Store and recovery planner, saved-answer/grade protection, attempt exhaustion and extension, both strict-completion paths, and shard aggregation. The final code preserves graded answers, retries eligible namespaced faults, and keeps exhausted infrastructure masks unsettled.
Validation: 502 tests passed using an isolated cache:
XDG_CACHE_HOME=<temporary-cache> PYTHONPATH=. python -m pytest -n 4 -q -o addopts='' tests/unit_tests/orchestration/test_masked_infrastructure_recovery.py tests/unit_tests/rollouts/test_rollout_store.py tests/unit_tests/rollouts/test_saved_generation_admission.py tests/unit_tests/rollouts/test_recovery_review.py tests/unit_tests/cli/test_cli_eval.py
No new model rollout was needed for this persisted-state accounting change.
Scope checked: this final diff adds masked_exhausted; producer-declared fail masks retain main's existing completion behavior. I checked the earlier review threads against the current implementation; this approval does not resolve those threads on the original reviewer's behalf.
Reconcile the latest parent recovery policy while preserving unanswered allocation retries. Honor saved legacy timeout retries without reopening producer stops or retained results, and cover requeue manifest admission. Refs #6064, #6070 Signed-off-by: Giulio Lovisotto <[email protected]>
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43858474696 |
ba032ec
Match main's masked_exhausted coverage (#6070), so no completion file is written while such a rollout is unmeasured. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]>
… are settled (NVIDIA-NeMo#5386) * feat(eval): write a completion file per agent as soon as its rollouts are scored Signed-off-by: Frankie Siino <[email protected]> * docs(eval): document the per-agent completion file Signed-off-by: Frankie Siino <[email protected]> * fix(eval): keep a failed completion-file write from failing the run Signed-off-by: Frankie Siino <[email protected]> * fix(eval): aggregate a completion file's rollouts in rollout order Signed-off-by: Frankie Siino <[email protected]> * fix(benchmarks): restore the Core and SWE batch repeat counts after NVIDIA-NeMo#5042 Since NVIDIA-NeMo#5042, data preparation writes each task once whenever a run-level num_repeats is set, so the run-level value replaces each dataset's own. The Core recipe listed only APEX (16) and LMArena (3) with a default of 1, so every other member dropped from 8, 10 or 16 attempts per task to 1 (23,801 rollouts before, 9,427 now). The SWE recipe's run-level 1 did the same to its 3 attempts (2,400 rollouts before, 800 now). List every Core member's intended count in the run-level num_repeats, set num_repeats: 3 in swe.yaml, and update the matching expectations in test_super35_batch_launcher.py. num_repeats_add_seed is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * docs(benchmarks): update the batch README for run-level repeat counts Signed-off-by: Frankie Siino <[email protected]> * fix(eval): group completion files by scoring environment and skip unscored agents Signed-off-by: Frankie Siino <[email protected]> * fix(eval): keep completion filenames distinct for distinct agent names Replacing every character outside letters, digits and . _ - with an underscore made names such as 'alpha beta' and 'alpha_beta' share one completion file, so the later write silently replaced the earlier agent's file. Percent-encode the name instead, which keeps ordinary names unchanged, keeps distinct names distinct, and cannot leave the completion directory. Document the encoding for consumers that build the filename, and note how the completion label differs from the run-wide label for an agent behind several environment servers. Signed-off-by: Frankie Siino <[email protected]> * revert(benchmarks): move the Core and SWE repeat-count restore to its own PR Reverts the repeats parts of 6abbf26 and 174c5e6 Signed-off-by: Frankie Siino <[email protected]> * fix(eval): keep an agent pending while a masked rollout awaits its rerun A success masked by infrastructure stays retryable: coverage reports it as masked_retryable and a resume runs it again. The completion code counted it as done, so the agent's file was written from the masked row and went stale once the resume reran it. A masked retryable success now stays pending, during the run and when a resume rebuilds the pending set, so the file is written after the rerun and equals the run-wide entry. The rule moves into RolloutRecords.masked_retryable, which coverage now uses too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * fix(eval): complete an agent once every rollout is settled, including final failures Only successes left the pending set, so one failure no resume would retry blocked its agent's completion file for the rest of the job. A rollout now leaves it once its outcome is settled (RolloutRecords.settled, the complement of pending): a success no resume reruns, or a failure or omission none retries. The early aggregate adds the failures the run counts as zero, with the same helpers as the end of the run, so it still equals the run-wide entry, and the file gains failed_rollouts. A failure a resume will retry still keeps the agent pending, so the file never goes stale. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * refactor(eval): share record reads and server labels with the completion files Read an agent's records through one handle per file (read_record_rows, also used by RolloutRecords.selected) instead of one open per record. Derive the agent that labels each environment server's entry in one helper (_server_agents) for both the run-wide aggregate and the completion files, and test two environment servers fronting one agent. Make the rollout-order test hand records back out of order, so only the completion file's sort keeps it green. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * docs(eval): say the run-wide aggregate wins over a stale completion file gym eval aggregate repairs the run-wide aggregate in place but leaves the completion files, so one that recorded an aggregation error can be stale after a repair. Document that the run-wide entry is authoritative once it exists. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * docs(eval): give per-agent completion files their own section with every field List every field of a completion file and the complete/error values, state when an agent is complete, that a fresh run deletes the directory and a resume rewrites completed_at, and give gym eval aggregate +merge_shards=false as the fallback for a job killed before its run-wide aggregate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * docs(eval): note the run-level health summary on the first run-wide entry After a run, Gym attaches _ng_run_health_metrics, a run-level health summary, to the first entry of the run-wide aggregate. A completion file's aggregate equals its run-wide entry apart from that key, so say so where the docs promise equality. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * fix(eval): bound and clean up early agent aggregation A resume deletes the completion file of an agent it still runs. The early /aggregate_metrics call gives up after 30 minutes and records an aggregation error, so a hung server cannot hold the run-wide aggregate. A run that stops early cancels and waits for its completion tasks and their in-flight requests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * fix(eval): refresh completion files after the saved-answer re-judge pass The re-judge pass at the end of gym eval run grades judge failures again and recomputes the run-wide aggregate, which left completion files written during collection with the old scores. Each file now takes its agent's recomputed entry and rollout counts; if the metrics or the files cannot be refreshed, the files are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * fix(eval): keep completion files in step with every in-place re-judge The judge-only recovery job recomputes the run-wide metrics in place and now refreshes the completion files, or removes them when it cannot. A strict run that the re-judge pass leaves incomplete gets no recomputed metrics, so its completion files are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * fix(rollouts): treat a masked rollout at its attempt cap as unsettled Match main's masked_exhausted coverage (NVIDIA-NeMo#6070), so no completion file is written while such a rollout is unmeasured. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]> * Lint Signed-off-by: Frankie Siino <[email protected]> --------- Signed-off-by: Frankie Siino <[email protected]> Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Masked rollouts whose environment declared
retryfor a namespaced failure kind, or whose agent stage failed with a partial transcript, were never retried, and masked rows that had used all their attempts still counted as settled, so the run looked complete. Retry now follows the recorded action for namespaced kinds (not for one attributed to the model), a graded answer is never sampled again, an agent-stage fault no longer keeps its partial transcript as the answer, and exhausted masked rows are reported asmasked_exhaustedand count as unsettled.coverage()returns thesettledcount, which the collector and the strict completion check now read instead of computing it. Unit tests drive the real store and recovery planner with stored rows. No live rollout was involved, since this is accounting over stored rows.