Skip to content

feat(eval): count expected, failed and missing rollouts in the run health summary - #4788

Merged
AdamRajfer merged 7 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:feat/eval-run-health
Oct 22, 2026
Merged

AdamRajfer merged 7 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:feat/eval-run-health

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

quality_summary.json only checked each rollout on its own, so a run could lose rollouts or fail most of them and still look fine, and a run that Slurm stopped (scancel, time limit, preemption) wrote no summary at all. Anyone gating on the summary had no way to tell whether a score covers the whole run.

Changes:

  • run.artifacts counts the run against its <output stem>_materialized_inputs.jsonl inventory:

    Field Meaning
    expected rollouts the run owed
    failed rollouts whose last attempt failed and that never landed: total, final (not retried by a resume), not_final (still retryable), by_class; the split is by retry only and does not say whether the model or the infrastructure caused a failure; null without a failures sidecar
    missing owed rollouts with neither a record nor a failure row
    healthy, unhealthy_reasons false with one reason per cause: a missing rollout, two records sharing a rollout identity, or final or not final failures reaching a configured limit as a share of expected. The failure limits are unset by default, so failures are counted but do not make the run unhealthy until a limit is set; null without an inventory
    partial true only on the provisional summary written after SIGTERM
    limits the limits the run was judged by (max_not_final_failure_fraction, max_final_failure_fraction, null for no limit) and, in source, where each limit came from: config, persisted when gym eval health-check reused it, or override when its own flag replaced or removed it

    The limits are health_check_max_not_final_failure_fraction and health_check_max_final_failure_fraction, or the --health-max-not-final-failure-fraction and --health-max-final-failure-fraction flags of gym eval run and gym eval aggregate. gym eval health-check judges a run again by the limits its quality_summary.json recorded; each of the same two flags there overrides only its own limit, none removes it, and a limit whose flag is not given keeps its recorded value.

  • The summary is also written when collection fails. A run stopped by SIGTERM unwinds like Ctrl-C and writes a provisional summary from the keys collection holds in memory, without reading rollouts.jsonl, so it finishes well within Slurm's KillWait even on very large runs; gym eval health-check writes the full one later. The provisional summary has no run.verdicts and no rollout_verdicts.jsonl. It evaluates only run_excessive_failures, lists the other checks in run.artifacts.not_evaluated, and its healthy is null unless the accounting already has a reason. A run with a custom rollout_collection_driver keeps no landed keys, so if it is stopped it gets the full check instead.

  • A run or resume deletes the previous job's quality_summary.json and rollout_verdicts.jsonl when it starts, so an old report never stands for a new run.

  • gym eval aggregate counts the failures and inventories next to each shard.

  • The failure limits are judged by a new run-scope health check, run_excessive_failures: one finding per group that reaches its limit in run.findings, a count in run.issues and coverage in run.artifacts.coverage. It is unobserved when no limit is set or there is no inventory. --health-check-ignore run_excessive_failures turns it off and keeps the counts.

  • The rollout health and CLI docs describe the new fields and flags.

Behaviour to note:

  • No score, metric or rollout changes, and the existing summary fields keep their meaning; run.issues and run.artifacts.coverage gain a run_excessive_failures entry. A reader that ignores the new keys sees no difference.
  • After SIGTERM the run exits with status 143, or with status 1 (EVAL FAILED) when require_complete is on, which gym eval submit sets; gym eval run --no-serve exits with 143 either way. Before, the process died by the signal.

Tested with unit tests in test_rollout_health.py, test_rollout_collection.py and test_cli_main.py (864 pass), including a subprocess test that sends SIGTERM mid-collection with an unreadable rollouts file and checks the provisional summary and exit status 143.

🤖 Generated with Claude Code

…alth summary

quality_summary.json only checked each rollout on its own, so a run could
lose rollouts or fail most of them and still look fine, and a run that
Slurm stopped (scancel, time limit, preemption) wrote no summary at all.

- run.artifacts counts the run against its _materialized_inputs.jsonl
  inventory: expected; failed from the _failures.jsonl sidecar (the last
  attempt of each owed rollout that never landed, split into final and
  not final by is_terminal_failure, with counts by class); missing; and
  a healthy verdict with unhealthy_reasons. A run is unhealthy when a
  rollout is missing, two records share a rollout identity, or final or
  non-final failures reach their limit, 2% of expected by default
  (health_check_max_infra_failure_fraction and
  health_check_max_final_failure_fraction, or the matching
  --health-max-*-failure-fraction flags).
- The summary is also written when collection fails. A run stopped by
  SIGTERM unwinds like Ctrl-C and writes a provisional summary from the
  keys collection holds in memory, without reading rollouts.jsonl, so it
  finishes well within Slurm's KillWait; gym eval health-check writes the
  full one later.
- A run or resume deletes the previous job's quality_summary.json and
  rollout_verdicts.jsonl when it starts.
- gym eval aggregate counts the failures and inventories next to each
  shard.
- After SIGTERM the run exits with status 143, or 1 (EVAL FAILED) when
  require_complete is on.

No score, metric or rollout changes; the existing summary fields are
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

@yaoyu-33 yaoyu-33 added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 20, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 21, 2026
@giuliolovisotto
giuliolovisotto self-requested a review October 21, 2026 18:00
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 21, 2026

@giuliolovisotto giuliolovisotto left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes I'd like here:

  1. Make this part of the health-check suite, with a run-level check ID such as run_excessive_failures, the usual findings/coverage, and support for ignoring the check. Keep the fast provisional shutdown path: it can evaluate this check from the inventory, failures and saved-result IDs while marking the other checks as not evaluated. The counts should remain available independently of the check. Consumers can still consume an acceptance verdict derived from the configured checks.

  2. Put the acceptance thresholds and their defaults in shared Gym health-check config. Keep separate configurable ratios for infrastructure failures and other failures, each over expected rollouts. I see the two config fields and run/aggregate flags already exist; please make the shared config the source of truth for defaults, and use the same configuration for normal reporting, provisional reporting and gym eval health-check. The standalone command currently falls back to the 2% function defaults, so rechecking the same artifacts can change the verdict. Persist the effective thresholds so the decision is reproducible.

For the two failure groups, please keep cause separate from retry eligibility: _ng_failure_terminal alone does not establish infrastructure versus other/model failure. #4834 illustrates this: an authentication error can be terminal, while a service error is retryable.

AdamRajfer and others added 4 commits October 21, 2026 23:11
Review feedback on NVIDIA-NeMo#4788. Both failure limits defaulted to 2% of expected rollouts, so any run with two failed rollouts in a hundred was reported unhealthy, whatever the benchmark. They are now unset by default: the run accounting still writes expected, failed (final and not final, by class) and missing, and a failure limit judges the run only when one is configured. Missing rollouts and duplicated records still make the run unhealthy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
…sist them

Review feedback on NVIDIA-NeMo#4788. The limits were declared twice, on the collection and the aggregation configs, and gym eval health-check had none, so rechecking a run fell back to the function defaults and could flip its verdict. RunHealthConfig now declares the limit settings once for both configs, and RunHealthLimits carries them to gym eval run, gym eval aggregate, the provisional summary after SIGTERM and gym eval health-check. quality_summary.json records the effective limits and their source (config, persisted or override). gym eval health-check judges a run by the limits its summary recorded; its new limit flags override them, and the summary says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
…heck

Review feedback on NVIDIA-NeMo#4788. The failure limits were applied inside the run accounting, outside the health-check suite, so they had no findings, no coverage and no way to be ignored. They are now the run-scope check run_excessive_failures: one finding per group of failed rollouts that reaches its limit (in run.findings and run.issues), coverage like the other checks (unobserved with no limit or no inventory), and health_check_ignored_checks can exclude it. The accounting counts stay in run.artifacts whatever the check does. The provisional summary after SIGTERM evaluates only this check, from the inventory, the failures sidecar and the saved-record identities, and lists the other checks in not_evaluated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Review feedback on NVIDIA-NeMo#4788. The failure groups are split by is_terminal_failure, which says whether a resume retries a failure, not who caused it, yet the not-final group was called infra and the final group model-caused. The limit setting, its CLI flag, the check's finding group and the unhealthy reason now say not final (retryable) and final (not retried): health_check_max_infra_failure_fraction becomes health_check_max_not_final_failure_fraction and --health-max-infra-failure-fraction becomes --health-max-not-final-failure-fraction. The docs state that the split carries no cause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 21, 2026 21:16
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

Thanks for the review. All of it is in four commits; here is what changed and what did not.

1. Part of the health-check suite (7d2495d). run_excessive_failures is a run-scope check. It writes findings to run.findings and run.issues, reports coverage like the other checks, and health_check_ignored_checks can exclude it. It is unobserved when no limit is set or there is no inventory. The provisional summary after SIGTERM still takes the fast path: it evaluates only this check, from the inventory, the failures and the saved result IDs, and lists the other checks under not_evaluated. The counts (expected, failed by group and by class, missing) are written whether or not the check runs.

2. One shared config for the limits (52f019c). RunHealthConfig declares the two limits once, and RunHealthLimits carries them to gym eval run, gym eval aggregate, the provisional summary and gym eval health-check. quality_summary.json records the effective limits and their source (config, persisted or override). gym eval health-check judges a run by the limits its summary recorded, so rechecking the same artifacts gives the same verdict. Its --health-max-final-failure-fraction and --health-max-not-final-failure-fraction flags override them, and the summary records the override. One choice to flag: passing either flag replaces both recorded limits, and a limit you leave out is unset, so the recorded source stays a single value. If you prefer each flag to override only its own limit, I can change that.

Defaults (37ce73a). As we agreed, both limits are unset by default, so failures alone do not make a run unhealthy until a limit is configured. Missing rollouts and duplicated records still do.

3. Cause kept separate from retry eligibility (98d1aba). Agreed: _ng_failure_terminal does not establish the cause. The two groups are now named for what they are, final (not retried) and not final (retryable). That covers the config (health_check_max_final_failure_fraction, health_check_max_not_final_failure_fraction), the flags, the findings and the reason text. The docs say the split carries no cause. The old infra names are renamed without an alias, since this PR has not merged.

Not in this PR:

Each commit adds tests that fail without it. The full unit suite has the same failures as before these commits, none new.

@giuliolovisotto giuliolovisotto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer each flag to override only its own limit, I can change that.

I would prefer that.

gym eval health-check replaced both persisted run-health limits when either limit flag was given, so a limit left out became no limit. Each flag now overrides only its own limit, and a limit whose flag is not given keeps the value the run's quality_summary.json recorded. Without a flag the behaviour is unchanged.

The limits block in quality_summary.json now records its source per limit, as a map from limit name to config, persisted or override, so a recheck shows which limit was overridden and the verdict stays reproducible. Every path that writes limits uses the same shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

Done in 65c1388. Each flag now overrides only its own limit. A limit whose flag is not given keeps the value the run's quality_summary.json recorded.

limits.source is now recorded per limit, for example {"max_not_final_failure_fraction": "persisted", "max_final_failure_fraction": "override"}. A recheck therefore shows which limit was overridden, and the verdict stays reproducible. Every path that writes limits uses the same shape, and summaries written before this commit still read back.

One consequence: gym eval health-check can no longer remove a recorded limit. Passing 1.0 is the closest to "no limit". If you want an explicit "no limit" value for the flags, I can add it.

New tests: TestPerFlagLimitOverride covers only the final flag, only the not-final flag, both flags and neither flag, plus test_quality_summary_records_the_source_of_each_limit. All of them fail without this commit and pass with it.

Since each limit flag of gym eval health-check overrides only its own limit, a recheck could no longer remove a recorded limit. A flag value of none, in any case, now removes that one limit; any other value must still be a fraction in [0, 1]. A flag that is not given still keeps its persisted value: the flags default to argparse.SUPPRESS, so an absent flag and none stay distinct.

In the Python API, a limit set explicitly on RunHealthLimits overrides the persisted one, and None removes it; a limit that is not set keeps its persisted value (model_fields_set). A removed limit is recorded as null with source override, and a later recheck keeps it removed. gym eval run and gym eval aggregate define their limit flags separately and do not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

AdamRajfer commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Added the explicit no-limit value in 7e915d4.

  • --health-max-final-failure-fraction none or --health-max-not-final-failure-fraction none removes that limit. none is accepted in any case.
  • A removed limit is recorded as override with a null value, and later rechecks keep it removed.
  • A flag that is not given still keeps its recorded value.
  • In the Python API, a limit set explicitly to None on RunHealthLimits removes it, and a limit that is not set keeps it.

New tests are in TestNoLimitValue. Its 9 behaviour cases fail without this commit and pass with it. 6 more check that an invalid value (nil, an empty string, 1.5, -0.1, nan, inf) is still an argparse error.

@AdamRajfer
AdamRajfer added this pull request to the merge queue Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39766335753

Merged via the queue into NVIDIA-NeMo:main with commit 5456cbb Oct 22, 2026
48 of 53 checks passed
@AdamRajfer
AdamRajfer deleted the feat/eval-run-health branch October 22, 2026 11:15
AdamRajfer added a commit to AdamRajfer/Gym that referenced this pull request Oct 22, 2026
Brings in the run health counts (NVIDIA-NeMo#4788) and the exporter changes (NVIDIA-NeMo#4852, NVIDIA-NeMo#4873), which the time-limit diagnostics now build on. No conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
AdamRajfer added a commit to AdamRajfer/Gym that referenced this pull request Oct 24, 2026
…ting does

`gym eval aggregate` merges runs from different environment servers, and
each numbers its tasks from 0. The duplicate check grouped records by task
and rollout index alone, so two such runs flagged every overlapping rollout
as a duplicate. Since the run verdict counts duplicates (NVIDIA-NeMo#4788), the whole
run was then reported unhealthy.

The run accounting already keys rollouts by input; the check now does the
same. A duplicate inside one input is still flagged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
aroshanghias-nvd pushed a commit to aroshanghias-nvd/Gym that referenced this pull request Oct 26, 2026
…eMo#4996)

* fix(health): recheck a merged run directory from its shards

`gym eval aggregate` checks the health of the shards it reads: each
shard's rows, its failure sidecar and its materialized inputs. The
merged rollouts.jsonl holds only the rows, so `gym eval health-check`
of the merged directory checked those rows alone. Every failure and
every inventory was lost, and the recheck overwrote the aggregation's
quality summary with one that counted none of them.

Aggregation now lists the shards it merged, in its order, in
rollouts_sources.json next to the merged file, with the merged file's
size. A recheck of that directory without --rollouts-file reads the
listed shards, as the aggregation did, so it counts the same rollouts.
It refuses when a shard is gone or the merged file is not the one the
aggregation wrote. An explicit --rollouts-file still checks that file
alone.

The shards are listed relative to the merged directory, so the tree can
move as a whole. The merged file is written aside and moved into place
after the list, so it never stands without one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): name the merged contents by hash and keep shard file names

Two gaps in the shard list, found in review:

- Equal sizes do not make equal contents. A second aggregation into the
  same directory that stopped before its merged file took its place
  could leave a list whose size matched the first merged file. A
  recheck would then read the second aggregation's shards for the first
  one's rows. The list now records the merged file's SHA-256 as well,
  and the recheck checks it after the size.
- A shard reached through a file link was recorded by its target. A
  recheck then looked for the sidecars beside the target, while the
  aggregation had read the ones beside the link. Only the directories
  are resolved now, and each shard keeps its file name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): verify each shard and drop stale shard lists

Review of the shard list found four gaps:

- A run that writes an output an aggregation merged into left the list
  behind: a fresh or resumed `gym eval run`, `gym eval reverify`, and
  the GDPval multistage driver. A recheck of that directory then
  refused the run's own rollouts. Each now removes the list when it
  takes over the output.
- A shard changed after the aggregation, for example by a resume, was
  read as it is now, while the merged rows and metrics hold what it
  held then. The list now records each shard's size and SHA-256 from
  the read the merge makes anyway, and a recheck refuses a changed
  shard.
- Merging onto one of several shards replaced a shard the merge had
  read and listed the merged file as that shard, so a recheck counted
  its rows twice. That is now refused before anything is written. A
  single run merged onto itself, the in-place metrics repair, still
  works and needs no list.
- The merged file replaced a symlinked output instead of writing
  through it as before. The temporary file now sits beside the link's
  target and replaces the target.

The docs and help now say that --rollouts-file checks that file alone,
so a merged file not named rollouts.jsonl is rechecked shard by shard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): keep the shard list until a run writes to the merged output

Review found two gaps in when the shard list goes:
- A run that takes over a merged output dropped the list before its own
  validation. A run that then stopped, for example on a missing input or
  batch manifest, left the merged rows unchanged but without their
  shards' failures and inventories. `gym eval run`, `gym eval reverify`,
  recovery seeding and the GDPval multistage driver now drop the list
  where they start writing. A fresh run still drops it with the output
  it deletes, and the GDPval driver sets it aside with the output it
  quarantines.
- A run merged onto itself kept a list that an earlier aggregation into
  it left. A recheck then followed shards that the merge did not read,
  or refused the re-sorted file. The merge now drops that list once the
  merged rows are in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): count duplicate rollouts within one input, as the accounting does

`gym eval aggregate` merges runs from different environment servers, and
each numbers its tasks from 0. The duplicate check grouped records by task
and rollout index alone, so two such runs flagged every overlapping rollout
as a duplicate. Since the run verdict counts duplicates (NVIDIA-NeMo#4788), the whole
run was then reported unhealthy.

The run accounting already keys rollouts by input; the check now does the
same. A duplicate inside one input is still flagged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): drop the shard list with the first row a run writes, and keep the merged file's mode

Review of the shard list found three more gaps:
- A run dropped the list when it opened the output, before it wrote
  anything. A resume with nothing left to run, a fully cached
  reverification, or a GDPval batch of rows that are not persisted
  therefore lost a list that still described the merged rows.
  Collection and reverification now drop it with the first row they
  persist (for ATIF, its kill-shaped diagnostics too). GDPval drops it
  only for a batch that holds a persistable row.
- GDPval also rewrites the output without routing rows: when it prunes
  rows after a restart stage, and when it publishes the final rollouts.
  Each rewrite now drops the list once it succeeds; a prune that removes
  nothing keeps it.
- Aggregation replaced the merged file through a new file and reset its
  mode to the umask default, so a 0600 output became 0644. The merged
  file now keeps the existing output's mode, as GDPval's rollout writer
  already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): keep merged rows private while staged, and keep the shard list's checks

Three gaps in how an aggregated output and its shard list are handled:

- The merged rows were staged in a new file with the default mode and
  given the output's mode only after they were written, so a 0600
  output's rows were briefly readable by others. The staging file is
  now created exclusively, under an unguessable name, and owner-only
  when it replaces an existing output.
- GDPval dropped the shard list before it opened its output files, so a
  run that could not open them lost the list without writing a row. It
  now drops the list just before its first write.
- A collection resume with nothing left writes no row, so the
  aggregation still owns the output, yet its own health check read the
  run's inventory beside the output and overwrote the shard-backed
  reports. It now checks the listed shards, as a recheck does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(health): resolve the shard list off the collector's event loop

Resolving an aggregated output's shard list hashes the merged file and
every listed shard. The collector's health check did that on the event
loop, so a large run or slow storage stalled every coroutine. It now
runs in a worker thread, like the collector's other artifact scans.

The staging-mode test now records the mode when the staging file is
opened, instead of mapping descriptors through /proc, so it also runs
where procfs is absent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

* fix(eval): preserve shard accounting across resume summaries

Reject in-place file aliases whose sidecars live beside another name.
Use source shards for the post-run health report and avoid replacing
shard-backed accounting with a single-file provisional report on stop.
Document the supported in-place path and cover the affected boundaries.

Signed-off-by: Adam Rajfer <[email protected]>

---------

Signed-off-by: Adam Rajfer <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 7e915d4e Deployed Oct 22, 2026 by copy-pr-bot[bot] via release / finalize / notify #6587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants