Skip to content

feat: judge failure handling - #2384

Merged
oyilmaz-nvidia merged 6 commits into
NVIDIA-NeMo:mainfrom
tdene:tde/proof_judge_metrics
Nov 30, 2026
Merged

oyilmaz-nvidia merged 6 commits into
NVIDIA-NeMo:mainfrom
tdene:tde/proof_judge_metrics

Conversation

@tdene

@tdene tdene commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

A zero reward from a judge model has three distinct causes that are currently indistinguishable:

  • The response was malformatted, and thus never judged.
  • The judge's judging response was itself malformatted.
  • The judge genuinely provided a score of 0.

The middle case leads to severe training run degradation, should the judge model become corrupted - which is not uncommon.

What changed

  • Verifier or meta-verifier reply without a parseable score. The row is returned with mask_sample=true, reward 0, failure_kind=judge_unparseable and a failure_reason that names the judge and quotes the first 200 characters of its reply. The meta-verifier is only called when beta != 0.
  • zero_reward_incorrect_groups. A proof the verifier did not score is not evidence. The group is zeroed only if at least one proof was scored and every scored proof has r_y == 0. A row masked for its meta-verifier reply still counts with its verifier score.
  • problem is required and nonempty, on the verify request and in the task-data schema.
  • A malformatted policy response and a judged 0 are unchanged: reward 0, unmasked, no failure fields.

Compatibility

  • A verify request without a top-level problem, or with an empty one, now gets a 422. Before, it was judged against an empty problem, or raised when zero_reward_incorrect_groups was on. Dataset validation now rejects such rows too. Every row shipped in data/ carries problem.
  • Rows with an unparseable verifier reply are now masked, so they leave evaluation scores and the loss of a trainer that honors mask_sample.

@tdene
tdene force-pushed the tde/proof_judge_metrics branch from 719f8ce to 66bb6a5 Compare August 6, 2026 16:11
@tdene

tdene commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 66bb6a5

@tdene

tdene commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

SHIP — clean, well-scoped, well-tested.

This PR decomposes proof_judge's zero-rewards into a named failure_reason so training pipelines can distinguish policy-format failures (automatic 0) from judge-unparseable failures (judge itself broke). Reviewed for scoring correctness, request-contract compatibility, and test coverage.

Reward math is unchanged. The refactor extract_boxed_score(...) or 0.0 → score if score is not None else 0.0 is numerically identical: extract_boxed_score only ever returns {0, 0.5, 1, None}, and 0.0 or 0.0 == 0.0. The change only adds the judge_unparseable signal on top — no reward drift into RLHF signal. Verified for both beta==0 and beta!=0 paths, including the r_meta_score is None case.

Request contract — problem now required (was problem: str = ""). A missing problem now 422s instead of silently verifying against an empty problem string, which is the correct fail-loud behavior for a verifier — an empty problem would have produced a garbage judge prompt and a meaningless score. Confirmed all in-repo datasets carry a top-level problem (data/example.jsonl, rollouts, and materialized inputs all 5/5), and prepare_data.py always emits it. The group-zeroing path (_maybe_zero_incorrect_group_reward) preserves details["reason"] via spread, so failure_reason survives that branch. Operational note for the author: any external caller or cached/replayed verify request lacking a top-level problem will now 422 where it previously scored 0 — intended, but worth a heads-up if such callers exist outside this repo.

Response schema — failure_reason: Optional[str] = None is an additive optional field; backward compatible with existing consumers.

Tests — good coverage: parametrized cases assert reward + failure_reason + judge call-count for genuine-verdict / judge-unparseable / policy-format-failure, plus a required-problem rejection test. asyncio_mode = "auto" is set, so the async tests execute.

One NOTE inline re: the "422 if empty" comment being slightly inaccurate (str rejects missing, not empty). Author's call.

Comment thread resources_servers/proof_judge/app.py Outdated

class ProofWithJudgeVerifyRequest(BaseVerifyRequest):
problem: str = ""
# Force a 422 error if the problem is empty.

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.

NOTE: The comment says "Force a 422 error if the problem is empty," but problem: str only rejects a missing field — an empty string "" still validates. If you actually want to reject empty problems, use problem: str = Field(min_length=1). Otherwise reword the comment to "if the problem is missing." Not a correctness issue given all in-repo datasets supply a non-empty problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thank you!

@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Aug 7, 2026
@tdene

tdene commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7307b03

@tdene

tdene commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

SHIP — no reliability concerns.

Reviewed resources_servers/proof_judge/app.py and its tests.

  • Correctness fix (the point of the PR): replacing extract_boxed_score(...) or 0.0 with an explicit None check correctly separates a genuine 0.0 judge verdict from an unparseable/refused judge response. Reward values are numerically unchanged; the new judge_unparseable → failure_reason signal is what lets downstream training/eval distinguish "judge said 0" from "judge failed to answer." This was a real latent conflation. Both beta == 0 and beta != 0 paths handle it, and the meta-verifier path checks both r_y and r_meta.
  • problem: str = Field(min_length=1): now returns 422 on missing/empty problem instead of silently defaulting to "". Deliberate and documented; the dataset carries problem at top level, and an empty problem would previously have produced a meaningless verifier prompt — failing loud is the better behavior.
  • Tests: cover the three zero-reward branches (judged verdict, judge-unparseable, format failure) and assert judge call counts to confirm the judge isn't consulted on format failures. asyncio_mode = auto is set, so the async tests execute.

No async/HTTP-client, public-API, dependency, or config-convention issues. Reward aggregation math is untouched.

@anwithk
anwithk requested a review from e-dobrowolska August 12, 2026 16:40
Comment thread resources_servers/proof_judge/app.py Outdated
Comment on lines 288 to 289

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 think this is not needed anymore, now that we set problem: str = Field(min_length=1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops. I knee-jerk addressed the claude review without thinking. Fixed!

@e-dobrowolska

Copy link
Copy Markdown
Contributor

This PR looks correct in a sense that it will do its job without breaking anything else. However, the previous PR #2113 introduced a unification on how we handle judge failures, so making changes just to one harness does not seem right.

As for now, the unified approach assumes that unparsable responses are not judge failures. This means that the judge had a fair chance of giving a verdict (i.e. we received a response from the API) and it just happened to be not what we expected. It was not considered a judge failure because judge failures currently mean the call itself failed (eg. due to rate limiting, auth issues, timeouts, HTTP errors) so we never got a verdict at all. We could change this approach to include unparsable responses as judge failures but this change should be applied uniformly, to other benchmarks as well.

@tdene

tdene commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

This proof-judge-specific work now belongs under #3180. The common contract distinguishes a valid wrong answer, a completed result whose reward should be masked (#2608), and a judge call that produced no usable result (#2135). Please keep proof-judge metrics and tests, but avoid introducing a second failure shape or reward-zero sentinel; also resolve the current blocked check before landing.

@ananthsub this has been updated as requested

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 20, 2026
@adil-a

adil-a commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

@ananthsub could you PTAL?

@athitten

Copy link
Copy Markdown
Contributor

@oyilmaz-nvidia can you help review since its related to failure handling ? Thanks

@athitten

Copy link
Copy Markdown
Contributor

@tdene could you rebase? The conflicts are import moves only. Please also update proof_judge/task_data.py now that problem is required, and mention the new 422 for a missing problem in the description.

@oyilmaz-nvidia

Copy link
Copy Markdown
Contributor

/review

Comment thread resources_servers/proof_judge/app.py Outdated
SimpleResourcesServer,
)
from nemo_gym.config_types import ModelServerRef
from nemo_gym.failure_kinds import JUDGE_UNPARSEABLE

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: this PR conflicts with main (merge state DIRTY), and the conflicts are more than import moves. main moved nemo_gym.failure_kinds to nemo_gym.core.failure_kinds and nemo_gym.judge to nemo_gym.verification, and proof_judge there now has its own pyproject.toml and uv.lock in place of requirements.txt. Please rebase and import from the defining modules, as AGENTS.md asks for code inside nemo_gym/ and its tests, and from the package public API for server code. Please also re-run the proof_judge tests after the rebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

class ProofWithJudgeVerifyRequest(BaseVerifyRequest):
problem: str = ""
# Force a 422 error if the problem is missing or empty.
problem: str = Field(min_length=1)

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: making problem required changes the request contract, but two things still describe the old one.

  • resources_servers/proof_judge/task_data.py (not in this diff) still declares problem with default="" and says it is optional and that an empty problem raises at verify time. A missing or empty problem now returns a 422 instead. Please update the schema and its description.
  • The PR description does not mention the new 422, the masking, the meta-verifier behavior or the group-zeroing change. Please add them, since a caller replaying a request without a top-level problem now gets a 422 instead of a score.

Smaller: the # Force a 422 error... comment above this line restates the code; I would drop it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Comment thread resources_servers/proof_judge/app.py Outdated
"verifier_response": verifier_response,
}
if r_y_score is None:
details |= _unparseable_verdict("verifier", verifier_response, mask_sample=True)

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: should every unparseable primary verdict be masked immediately, with no retry and no way to choose?

As written, one malformed judge reply masks the sample, and an evaluation drops it from the score. A judge that refuses or mis-formats mostly on weak proofs would therefore inflate the evaluation score. opencode_search handles the same event differently: it retries the judge, then follows unparseable_verdict_policy. By default it scores 0, unmasked, as a counted 0 (failure_outcome_action=COUNT_AS_ZERO), and a training run opts into masking (resources_servers/opencode_search/app.py).

A bounded judge retry plus a policy with the same two values would keep proof_judge consistent with that contract and make masking a training-time choice. The masked row is also not marked evaluation_completed=False, as the opencode_search row is. I'd like to hear whether always masking is intended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I strongly disagree with this: zero reward for a reply the judge never scored is exactly the issue this PR fixes. Retries were observed to fail when the cause of failure is load, so a retry would not help.

#6675 and #6673 are also making the same choice as I am making here.

meta_response, meta_generated_tokens = meta_result
r_meta = extract_boxed_score(meta_response) or 0.0
r_meta_score = extract_boxed_score(meta_response)
r_meta = r_meta_score if r_meta_score is not None else 0.0

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: when the meta-verifier reply is unparseable, r_meta becomes 0.0 here, and the reward flows on unmasked (see the elif r_meta_score is None branch below). The reward is then wrong, not just degraded: with alpha=beta=0.5, r_y=1 and a parseable meta score of 1, the reward is 1.0, and a missing one yields 0.5, which is exactly what test_meta_verifier_degrades_without_masking asserts. That 0.5 measures the judge's failure, not the policy, and training sees it as a valid sample.

The row also carries failure_kind=judge_unparseable while unmasked, so recovery counts it as a judge fault yet keeps its reward.

I'd either mask this case as well (the reward is not a valid measurement), or retry only the meta call and mask if it still fails. If you keep it unmasked, please state in the code and the PR description why a biased reward is acceptable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, fixed!

@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

The inline RISK covers task-data validation accepting inputs that the changed verification endpoint rejects.

RISK: Provide representative real-rollout evidence

The supplied PR description and discussion contain no representative model-rollout evidence for this change. The new verification tests mock the judge, and the committed rollout artifacts are unchanged from base. This change affects which rewards count as measurements, so those artifacts do not validate the new behavior. AGENTS.md requires representative real smoke rollouts for behavior-changing environment work.

Could you run a representative policy-and-judge smoke test on the final head and record its configuration, model identifiers, artifact location, completed/failed/masked counts, and inspected outcomes in the PR description? Preserve genuine judged zeroes and policy-format failures as unmasked measurements. Separately label any controlled replay used to demonstrate that an unparseable primary verdict is masked and named. If grouping is enabled, verify that a measured pass prevents group zeroing and an entirely masked group is not classified as all-incorrect. Acceptance is evidence tied to the reviewed code showing those outcomes through the real verification path; no implementation patch is indicated by this evidence gap.

I inspected both changed files and traced their affected validation, response-consumer, and group-aggregation paths. This was a static review; I did not execute tests or model rollouts.


Inline comments (escaped v1):

  • resources_servers/proof_judge/task_data.py line 18: RISK: Keep the task-data schema aligned with the required problem field.

    TaskData still accepts both {} and {"problem": ""}, while the changed request model rejects them. TaskDataValidator validates against this schema, so malformed rows can pass dataset validation and reach /verify, where they now fail with 422 instead of being caught before rollout generation. The schema matched the optional field in base; making the request field required introduces this drift.

    Could you replace default="" here with the same nonempty constraint?

            min_length=1,
    

    Also update this module's docstring and field description, which still describe an optional problem and a group-only empty-value error. Keep extra="allow" and the consumed_by annotation, and keep this schema dependency-light rather than importing the server implementation. The invariant is that dataset validation and the runtime request agree on requiredness and minimum length.

    Proposed acceptance checks, not executed: validate missing and empty problems through both TaskData and ProofWithJudgeVerifyRequest; assert a ValidationError specifically at problem, with missing and string_too_short respectively. Assert that {"problem": "Prove P."} still validates, that allowed extra task fields survive schema parsing, and that the committed example rows remain valid. Add a schema/request parity regression for these cases so either declaration drifting fails a test. Tighten the existing required-problem test from catching any exception to checking those specific validation errors.

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

Signed-off-by: Teodor-Dumitru Ene <[email protected]>
Signed-off-by: Teodor-Dumitru Ene <[email protected]>
Signed-off-by: Teodor-Dumitru Ene <[email protected]>
Signed-off-by: Teodor-Dumitru Ene <[email protected]>
Signed-off-by: Teodor-Dumitru Ene <[email protected]>
@tdene
tdene force-pushed the tde/proof_judge_metrics branch from 3806d0f to 4f72c88 Compare November 26, 2026 06:37
@tdene

tdene commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4f72c88

Signed-off-by: Teodor-Dumitru Ene <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Nov 26, 2026
@tdene

tdene commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9db4bdd

@tdene

tdene commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Rollout evidence (real servers, beta=0.5):
Using scripted prover and judges, group zeroing on, 20 rollouts per case:

Verifier / meta-verifier reply Before Now
1 / 1 reward 1.5 reward 1.5
1 / no score reward 1.0, unmasked masked, reward 0, judge_unparseable
no score / 1 reward 0, unmasked, group zeroed masked, reward 0, group not zeroed
0 / no score reward 0, unmasked, group zeroed masked, reward 0, group zeroed
0 / 1 reward 0, group zeroed reward 0, group zeroed
no score / no score reward 0, unmasked, group zeroed masked, reward 0, group not zeroed

Using a real live model as the external judge, 40 rollouts per tree:

  • On the run done on main, 6 rollouts had no boxed verifier score and were counted as 0, unmasked.
  • On the run done on this PR, 7 rollouts had no boxed verifier score and are now masked.

Using real live models for both the prover and the judge, 40 rollouts of easy proof tasks:

  • Both before and after, 13 rollouts had incorrect prover format and were correctly given 0 unmasked reward.
  • Both before and after, 14 rollouts had correct judge formatting and were given a normal reward (1.5).
  • Both before and after, 13 rollouts had incorrect judge formatting; before this PR, 6 were given unmasked reward 1.0 and 7 were given unmasked reward 0.0; after this PR, all 13 rewards were masked.

@oyilmaz-nvidia oyilmaz-nvidia 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.

LGTM, thanks!

@oyilmaz-nvidia
oyilmaz-nvidia added this pull request to the merge queue Nov 30, 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/46513485049

Merged via the queue into NVIDIA-NeMo:main with commit 8b0a2d0 Nov 30, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants