Skip to content

feat(eval): rescore selected answers from resumed runs - #3879

Merged
AdamRajfer merged 152 commits into
mainfrom
yuhez/2135-judge-recovery
Nov 5, 2026
Merged

AdamRajfer merged 152 commits into
mainfrom
yuhez/2135-judge-recovery

Conversation

@yuhezhang-ai

@yuhezhang-ai yuhezhang-ai commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Ordinary gym eval reverify can now re-score the currently selected completed answers from a resumed run directly into a separate output. Previously it refused a history containing replaced outcomes, including a judge failure settled by #5343, and required an exported projection first.

For example, when an initial attempt fails and its retry succeeds, re-scoring uses the retry's saved answer once. If a newer attempt failed or was interrupted, an older success is excluded. The policy model is not called.

Stacked on #3881 in Adam's failure and recovery stack, above #5443/#5343/#5072. Follow-up to #3302 for #2135. Judge-only recovery and its admission/budget policy are provided by #5343.

Separate outputs carry _ng_reverification_source_run_id as provenance without claiming ownership of the source run's recovery history. Successful rows seeded during judge recovery also use the selected history and retain that provenance. Partial re-scoring can resume from its separate output. Malformed verifier completions are rejected before being saved as successes; declared failures and omissions keep their existing handling. Source-artifact protections remain enforced.

Validation

Python 3.13.14, Linux, dedicated CPU allocation. The final combined tree passed 2,335 tests, plus 24 subtests:

python -m pytest -q -o addopts='' -o log_cli=false --tb=short \
  tests/unit_tests/{test_journal_health,test_rollout_health,test_health_timeouts,test_recovery_health_binding,test_evaluation_health,test_rollout_records,test_rollout_store,test_rollout_collection,test_recovery_review,test_eval_recovery_gate,test_aggregate_metrics,test_fern_docs_links,test_journal_reverification,test_rejudge_saved_judge_failures,test_rejudge_queued_snapshot,test_rejudge_before_strict_rejection,test_rollout_reverification}.py \
  tests/unit_tests/trajectory/test_atif_reverification.py \
  tests/unit_tests/{test_cli_eval,test_rejudge_cli_exit,test_slurm_rejudge}.py
pre-commit run --all-files
cd fern && npm run check
  • All 14 new re-scoring regressions fail against the unchanged parent-stack production module. They cover newer success/failure/interruption, aliases, settled judge failures, selected-success seeding, provenance, resume and malformed replies. Existing judge-recovery and ATIF tests pass.
  • All-files hooks passed; private guardwords catalog unavailable. Fern: zero errors, one warning.
  • Fresh CPU Qwen2.5-0.5B smoke through actual Gym HTTP model/agent/FrontierScience services: three real answers generated; one saved judge failure settled through feat(eval): recover from saved evidence with explicit gate results #5343 on its original attempt; a separate interrupted attempt excluded; two selected answers re-scored with six total judge calls and zero additional policy calls. Repeating re-scoring with resume made no new judge calls, source artifacts stayed unchanged, and standalone health checked the two selected completions.
  • FrontierScience declares ordinary re-scoring UNKNOWN, so the controlled mechanics smoke explicitly used --force and produced the documented unsafe_ output. This does not validate judge accuracy, production workloads, native session restoration or training-token capture.

Full sandbox/server CI remains pending for this rewritten head.

Compatibility and scope

Ordinary re-scoring always writes separately and can use a different verifier configuration. It does not update source outcomes, attempt reservations or retry budgets. Managed judge settlement retains #5343's original-attempt identity and admission-before-dispatch behavior. Legacy JSONL, legacy append and ATIF retain their existing contracts.

Checklist

  • Focused scope, documentation and behavioral regressions.
  • Local tests, all-files pre-commit and docs checks passed; full CI pending.
  • Real-model integration evidence with limitations recorded.
  • SPDX headers and DCO sign-off included.

@yuhezhang-ai yuhezhang-ai added feature New capabilities, enhancements, or enablement work area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters labels Oct 1, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 1, 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.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test 94f086c

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

@yuhezhang-ai
yuhezhang-ai force-pushed the yuhez/2135-judge-recovery branch from 94f086c to 99c41e0 Compare October 6, 2026 16:22
@yuhezhang-ai yuhezhang-ai changed the title feat(eval): recover saved answers after judge failures feat(eval): recover saved answers with shared run state Oct 6, 2026
@yuhezhang-ai
yuhezhang-ai force-pushed the yuhez/2135-judge-recovery branch from 99c41e0 to 0914103 Compare October 6, 2026 18:46
Base automatically changed from yuhez/2135-rollout-recovery to main October 30, 2026 23:52
@yuhezhang-ai
yuhezhang-ai force-pushed the yuhez/2135-judge-recovery branch from 0914103 to a575f9e Compare November 1, 2026 16:43
@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test a575f9e

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE — one RISK.

A bounded managed-source re-score can fail on an unrequested completion because the iterator fingerprints the next answer before checking --limit.

The earlier stale-cache and eager-materialization findings are fixed: cache validation rejects changed source bindings, and selected answers are loaded lazily.

I completed the broad review across all five changed files and their affected selection, persistence, verifier, settlement and aggregation paths. Tests were inspected, not executed in this read-only review.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/eval/rollout_reverification.py Outdated
with open(rollouts_jsonl_fpath) as r_f:
with nullcontext(selected_rollouts) if selected_rollouts is not None else open(rollouts_jsonl_fpath) as r_f:
for line in tqdm(r_f, desc="Reading rollouts"): # never holds the whole file
if limit is not None and n_yielded >= limit:

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.

RISK — Check the limit before requesting the next selected row

Failure: Save two selected managed results: task 0 with response={} and a numeric reward, followed by task 1 without response. Run ordinary re-scoring with limit=1. This loop requests task 1 before checking the limit. The new _selected_rescoring_rows fingerprints it before yielding, so _rollout_response raises and task 0 never reaches /verify. Native completions without a response are supported saved results; a row outside the requested limit shouldn't invalidate task 0. The previous file iterator checked the limit before interpreting the next row.

Correction: Could you check the yielded-pair count before advancing the iterator? In _yield_inputs_and_rollouts_paired, replace the for header and its limit check with the following, leaving the remaining pairing body unchanged:

rows = iter(tqdm(r_f, desc="Reading rollouts"))
while limit is None or n_yielded < limit:
    try:
        line = next(rows)
    except StopIteration:
        break

This suggested replacement needs author verification. It keeps the limit counted after the predicate and prevents decoding or fingerprinting an unrequested selected row.

Preservation: Keep latest-attempt selection, aliases, missing-input errors for requested rows, and unlimited iteration. Requested rows without a response must still raise the existing explanatory error. Predicate-rejected rows must not consume the limit.

Acceptance — proposed, not executed: Add the two-result setup above. With limit=1, only task 0 must be verified successfully; without a limit, task 1 must still raise the missing-response error. Retain the predicate-limit assertion yielding tasks 0 and 2. Update the lazy-loading regression to expect exactly [0] decoded with limit=1, all six without a limit, and unchanged source bytes.

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.

Already fixed at this head: the limit is checked before the next row is read. test_rescore_limit_does_not_interpret_unrequested_completion covers the response-less second row.

AdamRajfer and others added 4 commits November 4, 2026 15:27
…e shard

A recorded shard prefixes each row's rollout id with its run id, after
removing the prefix an earlier shard put on a row it returned. A row fed back
as `<earlier run>.0` and a new row whose own id is `0` therefore both became
`<this run>.0` in the same call. They would then share capture files and one
manifest identity. A training framework hits this when a step resubmits a
returned row next to fresh rows whose numbering restarted.

run_examples now refuses such a call before dispatch, and before the
existing shard is replaced. The error names both rows and both of their own
ids, so the caller can give each row a distinct _ng_rollout_id or distinct
task and rollout indices.

Test: `<earlier run>.0` beside `0` is refused with both ids named, nothing
is dispatched and the existing shard is kept. `<earlier run>.0` beside `1`
still dispatches, as `<run>.0` and `<run>.1`. It fails without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
The capture key, a rollout id with its attempt suffix, also names the model
server's capture files. The longest of them is `<key>.capture.incomplete`,
and a file name holds at most 255 bytes. A recorded shard adds a 33-character
run-id prefix to each row's id, so a long explicit id could pass that limit
and fail only when the first model call was captured, mid-rollout.

A shared check, check_rollout_id_length in nemo_gym.core.episode_context,
allows a rollout id of up to 230 bytes. That leaves room for attempt
suffixes up to -a9999 and the longest capture file suffix, and also keeps a
key under a 256-character id limit. run_examples applies it to each
recorded row's id after the prefix is added, before dispatch and before the
existing shard is replaced. The error names the id, its length and the
limit.

Test: an id one byte over the limit, after the prefix, is refused with
nothing dispatched and no shard written. The longest id that fits
dispatches, and its capture file name at attempt 9999 is exactly 255 bytes.
It fails without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
The library reference page generated from the judge_profile module failed
to parse: its module docstring wrote the pool node variable as
``${GYM_POOL_<POOL>_NODES}``, and the generated MDX read `<POOL>` as a tag.
The docs preview of any change that rebuilds the full reference failed on
it.

The docstring now names the variable as ``GYM_POOL_*_NODES``. No other
docstring combines a ${...} reference with an angle-bracket placeholder,
and the other pages built from docstrings parsed in the same build.

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

The library reference page for the judge_profile module failed to parse.
The page generator writes each field's default into an MDX attribute as
its Python repr, and JudgeExecutionProfile.qos_source defaulted to the
string "the partition's default". Because of the apostrophe, the repr is
double-quoted, so the generated line was

  <ParamField path="qos_source" type="str = "the partition's default"">

and MDX stopped at the `'` ("Unexpected character `'` in attribute name").

The default is now the module constant PARTITION_DEFAULT_QOS, with the same
text, so the page shows `str = PARTITION_DEFAULT_QOS`, as it does for
`kind: str = CPU_PROFILE`. The two other places that set the same source
use the constant too. The text in the operator's log does not change. No
other plain string default in nemo_gym contains an apostrophe.

Verified by generating the page locally with the docs CLI and compiling it
with MDX 3: the old page fails with the error above, the new one compiles.
The judge profile tests pass unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
A selected-row iterator fingerprints its answer while advancing. Check the
post-predicate limit before requesting another row so an unrequested
completion without a response cannot reject a bounded rescoring pass.

Keep unlimited iteration and missing-response errors for requested rows.
Test the boundary through direct and aliased managed sources, and require
exactly one decoded answer with limit=1.

Validation: 868 recovery/reverification tests and all-files pre-commit pass.
The three relevant boundary regressions fail against 3824557; unlimited
controls pass. The shared generated judge_profile docs issue is unchanged.

Signed-off-by: Yuhe Zhang <[email protected]>
@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test 0716472

@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

Rechecked 0716472dd against #3881. The earlier cache-binding, eager-loading and limit findings are addressed. Fresh regressions passed for superseded source attempts, unchanged partial resume, grade-only settlement, aliases and an unrequested completion without a response. No remaining code blockers were found in this pass.

Server CI passed; combined core coverage and the final test aggregate are still finishing. The docs-preview and nonblocking conformance failures match the shared failures on the base, including the library reference generated from main.

@AdamRajfer, this looks ready for your final code review while the remaining checks finish. Thanks!

@AdamRajfer AdamRajfer 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.

I ran this too. The re-scoring and reverify tests pass on this head (337 across the reverify, rejudge, CLI and ATIF files), 39 of the new ones fail against the previous layer's source, and the three tests for the newest commit fail without it. I also checked the limit change directly: with limit=2 the source iterator is advanced exactly twice, and with limit=0 not at all, so a bounded re-score no longer consumes a row it won't use. The health, store and records tests of the layer below still pass here (852).

The binding of each re-scored row to the saved answer it came from (run id, rollout id, attempt, answer hash) is a good way to make stale cache entries impossible. Two questions inline about how it fails.

Comment thread nemo_gym/eval/rollout_reverification.py Resolved
Comment thread nemo_gym/eval/rollout_reverification.py Resolved
AdamRajfer and others added 3 commits November 4, 2026 17:52
…recovery-health

Brings in the #5443 commits that landed after this branch last merged it, so the merge with main sees the shared history. No conflicts.

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

No conflicts; git merged every file on its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
…ez/2135-judge-recovery

No conflicts; git merged every file on its own.

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

Copy link
Copy Markdown
Contributor

/ok to test c444f4b

@AdamRajfer

Copy link
Copy Markdown
Contributor

Merged main after #5443 landed. The resolution kept main's manifest helpers and carried the digests: this PR's own diff against main is unchanged, and git merged every file on its own.

@AdamRajfer

Copy link
Copy Markdown
Contributor

/ok to test 6866cd6

AdamRajfer and others added 6 commits November 4, 2026 19:14
No conflicts; git merged every file on its own, following the test files #5589 moved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Main now mirrors nemo_gym's packages in tests/unit_tests (#5589). The
journal health test covers nemo_gym/rollouts/rollout_health.py, so it
moves to tests/unit_tests/rollouts/, and its import of the re-judge test
helpers follows that module to tests/unit_tests/eval/. Without the import
change the settled-judge-answer test fails with ModuleNotFoundError on the
merged tree.

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

No conflicts; git merged every file on its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
No conflicts; git merged every file on its own.

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

Main now mirrors nemo_gym's packages in tests/unit_tests (#5589). The
journal re-verification test covers nemo_gym/eval/rollout_reverification.py,
so it moves to tests/unit_tests/eval/, and its import of the re-judge test
helpers follows that module to the same folder. Without the import change
the settled-judge test fails with ModuleNotFoundError on the merged tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
One conflict, in fern/versions/latest/pages/evaluation/resume.mdx: the
sentence on aliases, which #3881 rewrote and this branch rewrote again on
top of #3881's version. Kept this branch's sentence; every other file merged
on its own.

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

Copy link
Copy Markdown
Contributor

/ok to test 7ea5bfd

@AdamRajfer

Copy link
Copy Markdown
Contributor

Merged main after #3881 landed (this PR now targets main). One docs conflict, the resume.mdx sentence on aliases: kept this branch's wording. Also, following #5589's test layout, test_journal_reverification.py moves to tests/unit_tests/eval/ and its import of the re-judge helpers now points there.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

This branch was previously deployed

1 inactive deployment
public — 7ea5bfd1 Deployed Nov 4, 2026 by copy-pr-bot[bot] via release / finalize / notify #10108
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 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.

4 participants