Skip to content

feat(eval): count a rollout that produced no row as zero - #3559

Merged
yuhezhang-ai merged 17 commits into
mainfrom
feat/count-missing-rollouts-as-zero
Oct 2, 2026
Merged

yuhezhang-ai merged 17 commits into
mainfrom
feat/count-missing-rollouts-as-zero

Conversation

@jubick1337

@jubick1337 jubick1337 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

A run scored only what it produced. A rollout that vanished, killed partway or dispatched and never heard from again, leaves no row in the rollouts jsonl and none in the failures sidecar. So it fell out of the denominator too, and the score went up when more of the run broke.

count_missing_rollouts_as_zero counts those from the run's materialized inputs. Off by default. A rollout that is in the sidecar is never counted here, whatever its class, so this does not override count_failure_classes_as_zero. Imputed rows are reported separately as coverage/imputed.

The Harbor agent also gets a compute_metrics, so its runs get pass@k from Gym instead of from a script next to it.

Known limitation, tracked in #3593: some benchmark metric hooks cannot score a row that carries only identity and a reward, and a few score it as a measurement. That is already true on main for count_failure_classes_as_zero, so it is not fixed here.

Validation

  • pytest tests/unit_tests/test_rollout_collection.py, 206 pass
  • pytest tests/unit_tests/, run twice, once with these changes stashed: 48 failures both times, same set, none in the files this PR touches
  • each review fix reverted on its own, to check a test fails without it
  • pre-commit run --all-files
  • pytest responses_api_agents/harbor_agent_general/tests/test_app.py, 17 pass

Rollouts

No new rollouts were collected for this. The numbers below come from runs we already had.

Five of our BioMysteryBench and BiomniBench runs had rollouts that reached neither file. The clearest is a 360-rollout BioMysteryBench run that lost its allocation partway: 312 scored, 2 in the sidecar, 46 gone.

scored over mean reward
what survived, 312 0.1891
plus the sidecar, 314, which is what count_failure_classes_as_zero gives today 0.1879
what the run owed, 360 0.1639

The existing option barely moves the score there, because only 2 of the lost rollouts were in the sidecar. This one covers the other 46.

This does not show up on GPQA. In all four of our GPQA runs the materialized inputs match rollouts plus sidecar exactly, so the option would change nothing.

Compatibility and benchmark impact

Off by default, so no existing run changes. Turned on, a score can only go down, never up: it only adds zeros. Numbers from before will look higher on runs that lost rollouts, and that is the bug.

It needs the run's materialized inputs. A shard without them gets a warning and is skipped, instead of quietly counting for nothing.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header. (No new files, everything is a change to an existing one.)
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

@copy-pr-bot

copy-pr-bot Bot commented Sep 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@jubick1337
jubick1337 requested review from ananthsub and bxyu-nvidia and removed request for bxyu-nvidia September 19, 2026 20:38
A rollout that fails and says so leaves a sidecar row, and
`count_failure_classes_as_zero` can pull it back into the denominator. A rollout
killed mid-flight leaves nothing in either file, so no failure class reaches it
and it leaves the denominator as well as the numerator -- the score then reads
higher the more of the run went missing.

The materialized inputs are the record of what the run was owed, and rollout
collection already reads them to print its coverage line.
`count_missing_rollouts_as_zero` feeds that same difference into the metrics
instead: off by default, so no existing number moves, and available on the
offline `gym eval aggregate` path too, where each shard carries its own
materialized file.

Measured on a 198-task GPQA run with 8 repeats, 1483 rollouts and 101 failures:
scoring the successes alone reports pass@1 0.8489 over 195 tasks, because three
tasks failed every attempt and vanished. Counting them puts it at 0.8119 over
198, which is what the run earned.

Signed-off-by: Matvei Novikov <[email protected]>
`harbor_agent_general` inherited `compute_metrics` from `AggregateMetricsMixin`
and returned an empty dict, so every benchmark running through it reported only
the RewardProfiler baseline -- mean, min, max -- and no pass@k at all. Anyone
wanting pass@k computed it outside the run, from the rollouts file, with the
task count supplied by hand.

`compute_pass_majority_metrics` already does this for five resource servers, so
the override is the same three lines they use. `answer_key` is left unset
because Harbor reports a score rather than an extracted answer, which leaves
majority@k with nothing to take a majority of.

On the GPQA run above the resulting pass@1 and pass@8 match, to four decimal
places, what an external script produced from the same rollouts.

Signed-off-by: Matvei Novikov <[email protected]>
@jubick1337
jubick1337 force-pushed the feat/count-missing-rollouts-as-zero branch from 6dbd2b7 to 5129ee8 Compare September 19, 2026 20:41
@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 Sep 19, 2026
bxyu-nvidia
bxyu-nvidia previously approved these changes Sep 21, 2026
@yuhezhang-ai

yuhezhang-ai commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Please address these aggregation issues before merging:

  1. Preserve failure-class selection. With count_missing_rollouts_as_zero=true, sidecar failures outside count_failure_classes_as_zero are reintroduced as synthetic zeros. In both collection and offline aggregation, one success, one excluded HTTP 503 failure, and one genuinely missing rollout produce a mean of 1/3 instead of 1/2. Missing detection should exclude all recorded failure keys while retaining the separate opt-in failure-scoring policy.

  2. Define which metrics support missing-as-zero and protect unsupported hooks. The five-field synthetic row is passed to existing benchmark hooks: tau2 raises KeyError('config'), VLMEvalKit raises KeyError('benchmark_name'), and SciCode rejects the mixed token-accounting versions. math_with_judge omits the placeholder from symbolic scoring, reporting 100% symbolic pass@1 for one successful task and one missing task while mean/reward becomes 0.5. That score difference can be intentional if the option applies only to general reward statistics, but the different denominators need to be explicit.

    This does not require updating every benchmark calculator. Either scope the option to general reward statistics, keep placeholders out of custom hooks, and clearly label which scores include missing attempts; or support benchmark-specific scores through explicit declarations that their calculators handle missing-as-zero. I would prefer explicit support declarations with a runtime check and a clear error for unsupported use, but either scoped approach is acceptable. Please add regression tests using actual metric hooks for the chosen behavior, including how unsupported hooks are handled.

  3. Restore rollout ordering before aggregation. Appending zeros after completed results puts missing early repeats at the end of each task. Two tasks succeeding on opposite repeats produce per-sample scores [100, 0] instead of [50, 50], and across-run standard deviation 70.71 instead of 0. Sort the combined metric input by task and rollout index in both paths.

Please also warn or fail when the flag is enabled but a shard's materialized inventory is unavailable, and distinguish completed/measured outcomes from imputed zeros in reporting. The flag's default, required artifacts, and interaction with failure-class selection should be documented alongside the validation evidence.

For coordination, my #3302 also changes these aggregation paths. It introduces attempt-aware accounting that distinguishes completed, masked, failed, intentionally omitted, and unknown outcomes. This PR does not need to depend on it, but whichever merges second should reconcile the shared paths so optional zero imputation preserves those distinctions and uses the selected latest attempts.

@jubick1337

Copy link
Copy Markdown
Contributor Author

Please address these aggregation issues before merging:

  1. Preserve failure-class selection. With count_missing_rollouts_as_zero=true, sidecar failures outside count_failure_classes_as_zero are reintroduced as synthetic zeros. In both collection and offline aggregation, one success, one excluded HTTP 503 failure, and one genuinely missing rollout produce a mean of 1/3 instead of 1/2. Missing detection should exclude all recorded failure keys while retaining the separate opt-in failure-scoring policy.
  2. Define which metrics support missing-as-zero and protect unsupported hooks. The five-field synthetic row is passed to existing benchmark hooks: tau2 raises KeyError('config'), VLMEvalKit raises KeyError('benchmark_name'), and SciCode rejects the mixed token-accounting versions. math_with_judge omits the placeholder from symbolic scoring, reporting 100% symbolic pass@1 for one successful task and one missing task while mean/reward becomes 0.5. That score difference can be intentional if the option applies only to general reward statistics, but the different denominators need to be explicit.
    This does not require updating every benchmark calculator. Either scope the option to general reward statistics, keep placeholders out of custom hooks, and clearly label which scores include missing attempts; or support benchmark-specific scores through explicit declarations that their calculators handle missing-as-zero. I would prefer explicit support declarations with a runtime check and a clear error for unsupported use, but either scoped approach is acceptable. Please add regression tests using actual metric hooks for the chosen behavior, including how unsupported hooks are handled.
  3. Restore rollout ordering before aggregation. Appending zeros after completed results puts missing early repeats at the end of each task. Two tasks succeeding on opposite repeats produce per-sample scores [100, 0] instead of [50, 50], and across-run standard deviation 70.71 instead of 0. Sort the combined metric input by task and rollout index in both paths.

Please also warn or fail when the flag is enabled but a shard's materialized inventory is unavailable, and distinguish completed/measured outcomes from imputed zeros in reporting. The flag's default, required artifacts, and interaction with failure-class selection should be documented alongside the validation evidence.

For coordination, my #3302 also changes these aggregation paths. It introduces attempt-aware accounting that distinguishes completed, masked, failed, intentionally omitted, and unknown outcomes. This PR does not need to depend on it, but whichever merges second should reconcile the shared paths so optional zero imputation preserves those distinctions and uses the selected latest attempts.

Thanks for the review!
The first and third were real bugs, and worse than they looked. With the flag on, count_failure_classes_as_zero had no effect at all, including under its default, and the resurrected rows also silenced the coverage line. Both are fixed, along with the warning on a missing inventory, a separate coverage/imputed count, and the docs. Each fix is pinned by a test that fails without it.

On the metric hooks: your four reproduce, but I think the scope is wider than this PR. _failure_rows_counted_as_zero on main already builds a thinner row than this one and it has no task_name so count_failure_classes_as_zero=['agent_run_error'], the value its own docstring suggests, already raises KeyError('config') on tau2 and KeyError('benchmark_name') on VLMEvalKit.

There is also no row that satisfies all of them. tau2 wants a termination_reason that immediately becomes a named counter, SciCode a token-accounting version for a rollout that produced no tokens, math_with_judge two verifier verdicts. Anything we put there invents an outcome and which the neighboring function documents itself as refusing to do. And the crashes are the visible half: around a dozen hooks accept the row and count it as a measurement, so simpleqa reports an abstention, omniscience a hallucination, and asr_with_pc scores an error rate where a zero reads as perfect.

I'd put a shared guard in compute_aggregate_metrics, or refuse at config time on benchmarks known not to tolerate an identity-only row and that covers both flags instead of one, and it belongs against main either way.

On #3302, assuming this lands first: this PR's headline test uses _ng_no_persist as its "produced no row" fixture, which becomes an intentional omission under yours, so it will need a genuinely unknown one. And materialized_path_for now lives in nemo_gym/path_utils.py and rollout_journal.py defines its own copy, worth importing instead.

Three defects found in review, all on the same path.

A rollout recorded in the failures sidecar looked missing whenever its class was not
selected, so the option scored exactly what the selection excluded -- with the flag on,
count_failure_classes_as_zero had no effect at all, including under its default. The
sidecar is read here now rather than trusted from the caller, which also restores the
coverage line that the resurrected rows silenced.

Imputed rows were appended after the rows that landed, leaving a missing early repeat
behind its own task's later ones. pass@k reads a task's repeats positionally, so the
per-sample scores and the spread across runs were wrong. Both paths order rows before
aggregation; the inline path reorders its two lists together, since the aggregator zips
them positionally.

A shard whose materialized inventory is absent is now reported instead of silently
contributing nothing, and imputed rows are counted separately from measured ones as
coverage/imputed.

Signed-off-by: Matvei Novikov <[email protected]>
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Sep 21, 2026
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks for the fixes and the additional investigation. I agree that point 2 is a shared problem affecting both flags, and that filling in missing fields could invent measurements.

A shared safeguard covering both options makes sense. I’d prefer benchmarks to explicitly declare support for imputed zeros, with an enforced check and a clear error for unsupported use. A separate fix against main is fine with me. Are you planning to add that safeguard here or in a companion PR? We can keep point 2 open until that protection is in place.

I also found one regression in the latest commit: with disable_aggregation=True and a metrics exporter enabled, collection raises UnboundLocalError at "coverage/imputed": len(missing). missing is initialized only inside the aggregation branch, but the export runs outside it. I reproduced this using the changed aggregation/coverage block. Initializing missing alongside counted, before the branch, should address it.

`disable_aggregation` skips the branch that counts the imputed rows, but the metrics
export runs outside it, so a run with an exporter configured raised UnboundLocalError
on coverage/imputed. Initialized next to `counted`, before the branch, and covered by a
test that exercises the export with aggregation disabled.

Reported in review.

Signed-off-by: Matvei Novikov <[email protected]>
@jubick1337

Copy link
Copy Markdown
Contributor Author

Thanks for the fixes and the additional investigation. I agree that point 2 is a shared problem affecting both flags, and that filling in missing fields could invent measurements.

A shared safeguard covering both options makes sense. I’d prefer benchmarks to explicitly declare support for imputed zeros, with an enforced check and a clear error for unsupported use. A separate fix against main is fine with me. Are you planning to add that safeguard here or in a companion PR? We can keep point 2 open until that protection is in place.

I also found one regression in the latest commit: with disable_aggregation=True and a metrics exporter enabled, collection raises UnboundLocalError at "coverage/imputed": len(missing). missing is initialized only inside the aggregation branch, but the export runs outside it. I reproduced this using the changed aggregation/coverage block. Initializing missing alongside counted, before the branch, should address it.

@yuhezhang-ai
Thanks for catching that!
Fixed and pushed, with a test that runs the export with aggregation disabled.

The safeguard makes more sense against main as its own change and it covers both flags and touches every benchmark's metrics hook. I'm not planning to pick that one up.

Does point 2 staying open block this PR, or can it merge while that lands separately?

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks, I confirmed the exporter fix on 5f508c70620919ba4345142081897c9af42e5005. Eight focused repository tests pass, along with our earlier failure-selection and Harbor-ordering regression checks.

Point 2 is non-blocking for this PR. I agree that the existing metric-hook compatibility issue can be handled in a separate fix against main covering both flags. Please document the current limitation and link a follow-up issue so it remains tracked; the shared safeguard does not need to be implemented here.

I have no further blocking code findings on this revision. Before merge, please use a Conventional Commit title and complete the PR description with the validation performed, the GPQA rollout evidence, and the scoring impact/known limitation. The full CI checks and final approval are still pending. I’m authorizing CI for this commit below.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test 5f508c7

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team September 22, 2026 03:36
@jubick1337

Copy link
Copy Markdown
Contributor Author

@giuliolovisotto thanks for review, addressed both comments!
@yuhezhang-ai ok to test now?

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test cf86513

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

CI is running for cf86513. I verified both fixes from Giulio’s review; 386 focused repository tests pass, plus two additional checks with in-memory result retention disabled.

One interaction with the newly merged dispatch budget needs clarification. Adding count_missing_rollouts_as_zero=True to test_a_run_that_drained_everything_says_so makes it stop raising: with dispatch_budget_s=0 and disable_aggregation=True, no attempts start and no score is produced, but collection now succeeds.

Could we preserve the empty-run error when aggregation is disabled and add a regression test for that combination? Also, should this option intentionally count budget-deferred attempts as zero when aggregation is enabled? If yes, please document that explicitly.

The previously agreed metric-hook follow-up remains non-blocking. Once this interaction is settled, @giuliolovisotto could you recheck your two fixes and update your review?

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test fba554b

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 2, 2026 13:46
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

@yuhezhang-ai yuhezhang-ai 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.

Reviewed fba554b. The empty-run guard is fixed and the policy for budget-deferred attempts is documented and covered by regression tests. Current CI passes, including core/sandbox coverage and all eight server-test groups, and Giulio has approved this revision. No blocking findings remain. The minor empty-aggregation/head-server edge case can be handled separately.

@yuhezhang-ai
yuhezhang-ai added this pull request to the merge queue Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit 73c9c04 Oct 2, 2026
44 checks passed
@yuhezhang-ai
yuhezhang-ai deleted the feat/count-missing-rollouts-as-zero branch October 2, 2026 14:52

This branch was previously deployed

1 inactive deployment
public — fba554bd Deployed Oct 2, 2026 by copy-pr-bot[bot] via release / finalize / notify #4189
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 sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants