Skip to content

fix(newton_bench): mask a judge outage instead of scoring it as not equivalent - #5678

Open
yaoyu-33 wants to merge 2 commits into
mainfrom
fix/newton-bench-judge-outage
Open

yaoyu-33 wants to merge 2 commits into
mainfrom
fix/newton-bench-judge-outage

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What

  • newton_bench now refuses to start when NewtonBench has no API key for its symbolic judge (gpt41). The check calls NewtonBench's own key lookup (utils.call_llm_api.keys). That lookup reads the environment and NewtonBench's .env file, so a key kept in .env still works. This replaces two logging.warning calls.
  • verify records each API attempt of the judge. It does this by wrapping the call_llm_api that modules.common.evaluation calls. If the judge's last attempt raised, the judge gave no verdict. verify then raises a JudgeError, and judge_failsafe masks the sample (mask_sample: true, failure_kind: judge_failed) instead of scoring R_symbolic = -1.
  • tests/conftest.py gains an autouse fixture. It gives the judge a placeholder key and makes requests.post fail at once. Tests that build the app with setup_webserver can then start the server, and no test reaches a real API.
  • The README describes the startup check and the masking.

Why

NewtonBench's llm_symbolic_equivalence_judge catches every error of its API call. After three attempts it returns False, which is also its "not equivalent" verdict. So a missing judge key or a sustained 429 set R_symbolic to -1, and an exact law with RMSLE 0 scored 0.4 instead of 1.0. An outage is not a wrong answer.

weijiac0619 raised this on #5485 (comment). No separate issue was filed; this PR is the fix.

Why the last attempt decides: the judge returns as soon as a reply carries a verdict. So if its last API attempt raised, none of the earlier attempts gave a verdict either.

  • A reply the judge cannot parse still counts as a reply. Gym's judge boundary scores a received-but-unparseable reply as a wrong answer.
  • If one attempt fails and a later one gives a verdict, that verdict is scored.

Interaction with #5485

#5485 (typed resources sessions) adds a verify-result cache. For the retry window, it answers a resent verify with the stored outcome. Without this fix, that cache would also replay the 0.4 an outage produced. With this fix:

  • The JudgeError propagates before the cache stores anything.
  • verify still releases the session, so a resent verify is masked as session_lost.

Merging with #5485's head (800cb4e) gives two conflicts, and both are resolved by keeping both sides:

  • app.py: adjacent import lines.
  • tests/test_app.py: both branches append to the end of the file.

#5485's setup_webserver-based tests need the new conftest fixture once this lands. On the merged tree, all 96 newton_bench tests pass.

Compatibility and benchmark impact

  • The server no longer starts without a judge key. Before, it started and every verification lost its symbolic credit. The first launch still clones NewtonBench before it stops.
  • Rows whose judge never answered now go to the judge-failures sidecar instead of the scored results. Runs that hit judge outages before this fix reported scores that were too low.

Validation

  • pytest resources_servers/newton_bench/tests in the server's venv, with NewtonBench at upstream HEAD 912a4ba: 66 passed.
  • Three new tests fail against origin/main's app.py:
    • test_setup_webserver_refuses_to_start_without_judge_key: DID NOT RAISE.
    • test_verify_masks_judge_without_key: the exact law came back as a scored 0.4 row.
    • test_verify_masks_judge_rate_limited_on_every_attempt: the exact law came back as a scored 0.4 row.
  • Two new tests pass both with and without the fix. They check that the fix does not mask too much:
    • test_setup_webserver_starts_with_judge_key
    • test_verify_scores_judge_verdict_after_rate_limit
  • The new verify tests run NewtonBench's real evaluate_law and judge. They patch only the key dict and requests.post.
  • Scratch merge with feat(newton_bench): serve the typed resources sessions API #5485's head 800cb4e: 96 passed, ruff clean.
  • tests/unit_tests/test_public_api_facades.py and tests/unit_tests/tooling/test_migrate_imports.py: 870 passed.
  • pre-commit run --files on the changed files: passed.

Rollout evidence

N/A for model rollouts. The change is in how the verifier handles judge API failures, and no model or judge endpoint is configured where this change was made.

Instead, a scripted probe (no real model, no real judge) ran through TestClient on #5485's typed sessions:

  1. Seed a session.
  2. Verify the exact law while the judge's HTTP call fails.
  3. Resend the same verify.
First verify Resent verify
#5485 alone reward 0.4, not masked (rmsle 0.0, symbolic_equivalent false) reward 0.4, replayed from the cache
#5485 + this fix masked, judge_failed masked, session_lost

🤖 Generated with Claude Code

yaoyu-33 and others added 2 commits November 5, 2026 09:07
…quivalent

NewtonBench's symbolic judge catches every API error and, after three failed
attempts, returns False: the same value as a "not equivalent" verdict. A
missing judge key or a sustained 429 therefore set R_symbolic to -1, so an
exact law with RMSLE 0 scored 0.4 instead of 1.0.

- Refuse to start when NewtonBench cannot resolve an API key for its judge
  model, using NewtonBench's own key lookup (environment and its .env file).
- Record each judge API attempt during verify. When the last attempt raised,
  the judge gave no verdict, so verify raises a JudgeError and judge_failsafe
  masks the sample (mask_sample, failure_kind judge_failed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…the network

The server now refuses to start without a judge key, so tests that build the
app with setup_webserver need one. The placeholder comes with a requests.post
that fails at once, so a test that reaches the judge never calls a real API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33 yaoyu-33 added bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 5, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 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.

@yaoyu-33

yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ed7f893

@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

RISK — Add the required real smoke-rollout evidence

The validation describes unit tests and a scripted probe with no real model or judge endpoint. That leaves the changed startup and verification path without the representative model rollout required by protected AGENTS.md. The tests provide useful fault-injection coverage, but don't show that a model-generated law reaches a working judge and remains an ordinary scored result.

Correction: Could you run a representative rollout with a real model and a working gpt41 judge, inspect the agent, tool, and verifier behavior, and record the command, model and judge identities, selected task, artifact location, and result in the PR's validation section? No source patch is indicated by this evidence gap. The configuration declares training data; a full evaluation or reward profile isn't required for training environments, but the real smoke rollout is (CONTRIBUTING.md).

Preservation and acceptance: The proposed smoke check should start successfully with a supported judge key, exercise the public rollout/verification workflow, and produce an unmasked result whose reward agrees with the returned symbolic verdict and RMSLE. Retain the existing regression assertions: missing credentials reject startup; missing credentials during verification and sustained 429s produce mask_sample: true and failure_kind: judge_failed; a recovered judge verdict scores the exact law with RMSLE 0.0 and reward 1.0.

I completed the static review of all four changed files and the directly affected masking, routing, and cleanup contracts. I found no additional source-proven defect. I didn't execute tests. The runtime-cloned NewtonBench dependency isn't present in either immutable tree, so I couldn't independently verify its key resolver or the upstream parsing/retry assumptions behind the last-attempt rule.

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

@kajalj22
kajalj22 removed request for a team November 6, 2026 22:49

This branch was previously deployed

1 inactive deployment
public — ed7f8938 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10385
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 bug Something isn't working 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.

2 participants