Repository navigation
Conversation
719f8ce to
66bb6a5
Compare
|
/ok to test 66bb6a5 |
|
/claude review |
|
SHIP — clean, well-scoped, well-tested. This PR decomposes proof_judge's zero-rewards into a named Reward math is unchanged. The refactor Request contract — Response schema — Tests — good coverage: parametrized cases assert reward + One NOTE inline re: the "422 if empty" comment being slightly inaccurate ( |
|
|
||
| class ProofWithJudgeVerifyRequest(BaseVerifyRequest): | ||
| problem: str = "" | ||
| # Force a 422 error if the problem is empty. |
There was a problem hiding this comment.
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.
|
/ok to test 7307b03 |
|
/claude review |
|
SHIP — no reliability concerns. Reviewed
No async/HTTP-client, public-API, dependency, or config-convention issues. Reward aggregation math is untouched. |
There was a problem hiding this comment.
I think this is not needed anymore, now that we set problem: str = Field(min_length=1)
There was a problem hiding this comment.
Oops. I knee-jerk addressed the claude review without thinking. Fixed!
|
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. |
…ard (NVIDIA-NeMo#2611) Closes NVIDIA-NeMo#2608 `BaseVerifyResponse` carries a single scalar for the outcome, so an environment that *knows* it failed — lost session, unavailable judge, OOM-killed container, reset timeout — can only return `0.0`, which is indistinguishable from a policy that genuinely scored zero. The concept is not new to this repo. It exists in four private locations: - `mask_sample: bool = False` on `SWEBenchWrapperInstanceConfig` (`responses_api_agents/swe_agents/app.py:272`), also `anyterminal_agent/app.py:108` and `anyswe_agent/app.py:180`, documented at `swe_agents/README.md:670`. - `conversational_tool_use/simulation/app.py:112` keeps its own `{"mask_sample": ...}` dict. - `nemo_gym/token_id_capture/delivery.py:49` already defines `MASK_SAMPLE_KEY = "mask_sample"` as a **top-level** rollout field, described there as what "a consumer reads to exclude a rollout from the loss". - NeMo-RL consumes only the first one, through `full_result["instance_config"]["mask_sample"]` (`nemo_rl/experience/rollouts.py:229-241`), which zeroes `loss_multiplier` in `nemo_rl/algorithms/grpo.py:2104`. So core already agrees what the key is called and what it means; it is reachable only if your environment happens to be SWE-shaped or if token capture produced it. verl gets nothing. This is the same objection raised on NVIDIA-NeMo#2384 — that a fix "should be applied uniformly, to other benchmarks as well" rather than to one harness. Putting the field on the contract is what makes it uniform. ## What this changes **1. The contract** (`nemo_gym/base_resources_server.py`) ```python class BaseVerifyResponse(BaseVerifyRequest): reward: float mask_sample: bool = False # is this reward a valid measurement failure_kind: Optional[str] = None # which kind of failure, from NVIDIA-NeMo#3179's vocabulary failure_reason: Optional[str] = None # what happened, for a person ``` The three are orthogonal. `mask_sample` decides usability, `failure_kind` groups in logs and metrics, `failure_reason` explains one occurrence. A sample that degraded but was still measured validly names a kind and stays unmasked. `failure_kind` validates against `nemo_gym.failure_kinds` and warns rather than rejects — an unregistered name is a migration signal, and failing the response over it would replace a visible wrong label with an invisible lost failure. An environment that needs something the shared set should not grow uses `<server>:<kind>`. Gym states the fact and stops there. Masking, resampling, excluding from group statistics or dropping the group stays the training framework's decision — the three frameworks we checked genuinely differ. `swe_agents` and `anyswe_agent` mirror their instance-config flag onto the contract field and keep the old location for one release. `anyterminal_agent` already surfaces it through `TerminalBenchMetrics`. **2. Something that reads it** (`nemo_gym/reward_profile.py`, `nemo_gym/rollout_collection.py`) A declaration nothing consumes is not worth much, and the consumer that matters is the one that publishes the score. `compute_aggregate_metrics()` computes quality from the scored subset: the profiler input, a custom `compute_metrics()`, and key-metric selection all skip masked samples. Masked rows stay in the input and are reported as coverage instead — `coverage/measured_rollouts|masked_rollouts` and `coverage/measured_tasks|fully_masked_tasks`. A run where every sample is masked publishes coverage rather than inventing a zero, and a fully masked task is counted without contributing a group. `mask_sample` is stripped before profiling, so it is no longer averaged as though the flag were a measurement. `perf_summary` deliberately keeps using every response, masked included: a masked sample still executed and still reported its latency, so observability coverage should not shrink because a rollout was excluded from scoring. Progress telemetry gets the same split while a run is still going, over the results that reach the main rollout output: - `progress/<agent>/reward` is unchanged — it still averages over every rollout, so an existing dashboard reads the number it read before. - `progress/<agent>/reward_unmasked` is that same average with the masked rollouts removed. - `progress/<agent>/masked_pct` is how many were removed. - `progress/<agent>/failed` and `/omitted` count the attempts that never reach the main output at all, so a sidecar failure is never folded into a quality average as a reward of zero. The gap between the two reward series is the score a run lost to its own infrastructure rather than to the policy. On the run that motivated this, 1172 of 1280 rollouts across steps 61–80 failed in session reset and entered GRPO as legitimate zeros; nothing in the metrics said so. Every new key appears only once something is actually masked, failed or omitted, so a healthy run publishes exactly what it published before. ## Scope Run-level reconciliation is no longer in this PR. NVIDIA-NeMo#3302 implements it for NVIDIA-NeMo#2135, using the materialized inventory and attempt journal to account for omitted and unknown work offline — neither of which this contract can see. What remains here is the per-sample half. ## Relationship to the other failure-handling work - **NVIDIA-NeMo#2552** (merged) landed `failure_reason` and its comment already points here: *"Machine-readable handling belongs to `mask_sample`/`failure_kind`."* This PR is that half. - **NVIDIA-NeMo#2728** owns `failure_kind` and the shared registry, and already reserves `session_lost` with `source="NVIDIA-NeMo#2611"`. No overlap — this PR does not touch `failure_kind`. - **NVIDIA-NeMo#2750** lists this under *Failure fields and artifact integrity*. The design document's rule — *"the producer returns the real result with `mask_sample=True`, a stable `failure_kind`, and a human-readable `failure_reason`"* — is exactly what the three fields together express once this lands. ## Compatibility Defaults are inert; an unmodified environment behaves identically, and a run that masks nothing publishes exactly the keys it published before. One inheritance detail worth naming: `AnySweVerifyResponse` inherits `mask_sample` from both `SWEBenchMetrics` and `BaseVerifyResponse`, and the metrics model wins the MRO, so the contract field resolved to `Optional[bool] = None` with no description on that response. It is restated on the subclass so the schema keeps the contract's type, default and description. ## Tests - `tests/unit_tests/test_base_resources_server.py` — defaults, round trip, that a plain `reward=0.0` is *not* implicitly masked, and that a degraded-but-scored rollout stays unmasked. - `tests/unit_tests/test_aggregate_metrics.py` — a masked zero does not halve the score, the flag is not published as a quality metric, a run that masks nothing is byte-identical, a fully masked run reports coverage instead of a zero, a fully masked task is counted but not scored, custom `compute_metrics()` sees only scored samples, and a fully masked run still reports observability coverage. - `tests/unit_tests/test_rollout_collection.py` — the disposition account closes for every combination and the residual never goes negative; a healthy run adds no keys; a partially masked agent reports its share and the score without it; a fully masked agent publishes no average; failed and omitted attempts are counted, never averaged. - `responses_api_agents/anyswe_agent/tests/test_app.py` — an end-to-end `/run` that constructs and serializes the response. Reverting the fix makes it fail with `TypeError: got multiple values for keyword argument 'mask_sample'`. `uv run --extra dev pytest tests/unit_tests -q` → 3383 passed. Two failures on this branch, `test_e2b_provider` and `test_enroot_provider`, reproduce on a clean `upstream/main` and are unrelated. `pre-commit` clean. --------- Signed-off-by: waple0820 <232305951+waple0820@users.noreply.github.com> Co-authored-by: waple0820 <232305951+waple0820@users.noreply.github.com>
569a6cf to
3806d0f
Compare
|
/ok to test 3806d0f |
@ananthsub this has been updated as requested |
|
@ananthsub could you PTAL? |
|
@oyilmaz-nvidia can you help review since its related to failure handling ? Thanks |
|
@tdene could you rebase? The conflicts are import moves only. Please also update |
|
/review |
| SimpleResourcesServer, | ||
| ) | ||
| from nemo_gym.config_types import ModelServerRef | ||
| from nemo_gym.failure_kinds import JUDGE_UNPARSEABLE |
There was a problem hiding this comment.
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.
| class ProofWithJudgeVerifyRequest(BaseVerifyRequest): | ||
| problem: str = "" | ||
| # Force a 422 error if the problem is missing or empty. | ||
| problem: str = Field(min_length=1) |
There was a problem hiding this comment.
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 declaresproblemwithdefault=""and says it is optional and that an empty problem raises at verify time. A missing or emptyproblemnow 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
problemnow gets a 422 instead of a score.
Smaller: the # Force a 422 error... comment above this line restates the code; I would drop it.
| "verifier_response": verifier_response, | ||
| } | ||
| if r_y_score is None: | ||
| details |= _unparseable_verdict("verifier", verifier_response, mask_sample=True) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
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.
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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.pyline 18: RISK: Keep the task-data schema aligned with the required problem field.TaskDatastill 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 theconsumed_byannotation, 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
TaskDataandProofWithJudgeVerifyRequest; assert aValidationErrorspecifically atproblem, withmissingandstring_too_shortrespectively. 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 <teodord.ene@gmail.com>
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
3806d0f to
4f72c88
Compare
|
/ok to test 4f72c88 |
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
|
/ok to test 9db4bdd |
|
Rollout evidence (real servers,
Using a real live model as the external judge, 40 rollouts per tree:
Using real live models for both the prover and the judge, 40 rollouts of easy proof tasks:
|
A zero reward from a judge model has three distinct causes that are currently indistinguishable:
The middle case leads to severe training run degradation, should the judge model become corrupted - which is not uncommon.
What changed
mask_sample=true, reward 0,failure_kind=judge_unparseableand afailure_reasonthat names the judge and quotes the first 200 characters of its reply. The meta-verifier is only called whenbeta != 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 hasr_y == 0. A row masked for its meta-verifier reply still counts with its verifier score.problemis required and nonempty, on the verify request and in the task-data schema.Compatibility
problem, or with an empty one, now gets a 422. Before, it was judged against an empty problem, or raised whenzero_reward_incorrect_groupswas on. Dataset validation now rejects such rows too. Every row shipped indata/carriesproblem.mask_sample.