Skip to content

feat(grpo): add exclude_infra masked-reward policy for infra-masked rollouts - #4968

Merged
terrykong merged 16 commits into
mainfrom
yifuw/masked-failure-kind-advantages
Dec 1, 2026
Merged

terrykong merged 16 commits into
mainfrom
yifuw/masked-failure-kind-advantages

Conversation

@yfw

@yfw yfw commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What and why

Adds a third grpo.masked_reward_policy value, exclude_infra, and makes it the default. With it, a rollout that the environment masked for an infrastructure reason, or with no failure_kind at all, no longer moves the baseline and advantages of the valid rollouts in its group. This is the follow-up promised in #4160, which said that environment-masked rows would not count by default, except for failure kinds the policy caused. A recipe that wants the earlier behavior sets include.

Problem. #4160 added grpo.masked_reward_policy: include | exclude, with include as the default. Under include, a masked rollout is still part of its group's baseline and std. It never trains, but its reward still moves the advantages of its valid siblings, including when that reward measured nothing.

Example: an environment masks an evaluator error. Take a group with rewards [1, 1, 0], where the 0 is that evaluator error. Under include, the two valid rollouts get raw advantages [0.5, 0.5] instead of [0, 0].

exclude avoids this, but it also drops masks that the policy itself caused (timeouts, step limits, context overflow) and trainer-filtered rows. Those rewards are real measurements of the policy.

Change.

  • New value exclude_infra, now the default (it was include). A masked rollout still counts in its group's baseline and std only if its top-level failure_kind is in the new grpo.policy_failure_kinds. The default list is agent_timeout, agent_command_not_allowed, agent_limit, agent_invalid_output and model_context_limit.
  • The default follows Gym's shared kind list. It is the MODEL_FAULT_KINDS of nemo_gym/core/failure_kinds.py that a producer emits, without the model-call kinds model_request_error and model_policy_response_timeout. Gym's evaluation counts a failed or timed-out policy call as the model's result, but in training the policy server is part of the setup. RL cannot import the list at config time (the driver of a Gym run starts without the nemo_gym extra), so the default list is a copy in nemo_rl/experience/interfaces.py, next to the other copied Gym names, and a Gym-lane test fails when the two drift apart. Today's Gym main (d1f6955e4) gives the same five kinds. It has two kinds that are newer than RL's Gym pin, git_worktree_commit_rejected and model_server_queue_timeout, and both are infra kinds, so exclude_infra drops them from the statistics.
  • Every other masked rollout is treated as infra and leaves the statistics. That includes rollouts with no kind, kinds Gym adds later, and namespaced <server>:<kind> names. Only that rollout leaves; the rest of its group still trains.
  • Matching is by exact string, namespaced names included. A recipe that sets the list replaces it, because OmegaConf.merge replaces lists. So a recipe that adds a name must also list the defaults.
  • Names are checked at setup. Under exclude_infra, one Gym actor checks each name with Gym's require_failure_kind, so a misspelled kind stops the run instead of moving real policy rows out of the statistics. Any namespaced <server>:<kind> name passes.
  • Shipped configs keep the default kinds. test_shipped_config checks that every shipped config that sets grpo.policy_failure_kinds lists all the default kinds.
  • Loss masking does not change. Under every value, a masked rollout's loss weight stays 0 through mask_sample.
  • include and exclude behave exactly as before.
  • Opt-out still works. With env.should_mask_flagged_samples: false, nothing is masked, so nothing is treated as infra.
  • Validation rollouts are not affected.
Rollout include exclude_infra (default) exclude
Not masked counts counts counts
Trainer-filtered (overlong filtering, seq-logprob error) counts counts —
Env-masked, kind in policy_failure_kinds counts counts —
Env-masked, any other kind or no kind counts — —
Dataset weight 0 (over-length prompt) — — —

The guide section "Masked rewards in advantage statistics" in docs/guides/grpo.md and examples/configs/grpo_math_1B.yaml document the new value and key.

How it works

No new data-plane or trainer column is needed.

  • Ingestion: where RL reads the Gym result, an infra-masked rollout gets dataset weight 0 (loss_multiplier), the same as an unusable over-length prompt. The include population from feat(grpo): configurable masked-reward participation across the four trainers #4160 (_include_valid_mask) then leaves it out on all four trainers: legacy sync, async, TQ and SingleController.
  • grpo.py:
    • _votes_by_dataset_weight() is true for include and exclude_infra. The estimator, dynamic-sampling admission and the logprob mask use it.
    • exclude_infra_policy_kinds() returns the policy list only under exclude_infra.
  • Legacy, async and TQ paths: rollouts.infra_failure_flags() marks the rows. The group builder sets their loss_multiplier to 0 and logs infra_failure_sample_rate.
  • SingleController, native path: record_to_train_batch sets sample_mask to 0. TQReplayBuffer carries the policy list and logs infra_failure_sample_rate.
  • SingleController, token-capture path:
    • The rollout manager seals each attempt's raw failure_kind into the recovery ledger.
    • The ledger schema goes to v9 (main has v8) and still loads v2 to v8 ledgers, with no kind. The open feat(checkpoint): support typed Gym environment servers in turn/prefix recovery #5340 also writes v9, so whichever of the two lands second moves to v10.
    • At finalization, ReassemblyRequest.infra_failure makes finalize_group write sample_mask 0 and log infra_failure_sample_rate. With forest_training, every segment row of a flagged rollout gets the 0, and the rate counts rollouts, not rows.
  • SingleController advantage stage: the include path now also covers exclude_infra.
  • SingleController dynamic sampling: the zero-variance check (dynamic_sampling.voting_rewards) leaves the infra rows out too, so it sees the same voters as the advantage stage. The native path computes the flags in RolloutManager._voting_rewards; the token-capture path carries them as FinalizedGroup.reward_infra_failure.
  • Per-environment settings (grpo.agent_overrides, feat(grpo): per-environment GRPO settings (grpo.agent_overrides) #5321): they work with exclude_infra unchanged. Its voters do not depend on overlong_filtering, so the check for a per-environment overlong_filtering under dynamic sampling stays limited to exclude.

A search of nemo_rl/ found no other reader that treats loss_multiplier == 0 as "prompt too long".

Worked example (GRPO estimator, leave-one-out baseline, normalize_rewards: true)

The group has five rollouts:

  • A = 1, B = 1, C = 0 are valid.
  • D = 0 is masked with agent_timeout.
  • E is masked with no kind (an evaluator error), with reward 0 or 1.
Mode A, B if E=0 A, B if E=1 C if E=0 C if E=1
include +1.500 +0.866 −0.866 −1.500
exclude_infra +1.155 +1.155 −1.155 −1.155
exclude +0.707 +0.707 −1.000 −1.000
  • Under include, the valid rollouts' advantages depend on E, which measured nothing.
  • exclude_infra drops E and keeps D, because a timeout is a real failure of the policy.
What changes with the new default

Every recipe that does not set masked_reward_policy now uses exclude_infra. Training changes wherever a group contains masked rollouts without a policy kind; elsewhere it is the same as under include. A recipe that wants the earlier behavior sets include.

Known cases:

  • Judge failures: environments that mask judge failures without a kind no longer count those rows. The same goes for GenRM cohort failures, which carry failure_kind: judge_failed; their reward is a 0.0 placeholder.
  • SWE agents: at RL's Gym pin, swe_agents, anyswe and anyterminal tag limits and timeouts agent_timeout, agent_limit or model_context_limit, so those rows count under exclude_infra, as under include. Their sandbox failures and anyterminal's eval-command timeout (anyterminal_agent:eval_timeout) are infra.
  • Namespaced kinds: some are arguably policy-caused but default to infra, for example critpt_custom_grader:response_incomplete and partner_if:evidence_too_large. A recipe can list them in grpo.policy_failure_kinds, together with the defaults.
  • agent_timeout: listed as a policy kind, although wall time also includes slow model servers or VMs.

Usage

grpo:
  masked_reward_policy: exclude_infra   # the default; include keeps the earlier behavior
  policy_failure_kinds:                 # read only by exclude_infra; exact string match;
                                        # a recipe list replaces the defaults, so keep them
    - agent_timeout
    - agent_command_not_allowed
    - agent_limit
    - agent_invalid_output
    - model_context_limit

Issues

Related to #4061 and follows up on #4160. On the Gym side, NVIDIA-NeMo/Gym#4882 is adding failure_kind to masked results that lack one.

Convergence / perf / functionality proof

This PR changes training for every recipe that does not set masked_reward_policy and whose environment masks rollouts without a policy kind. The checks below show that it changes the advantages as intended. They do not show convergence.

Same-seed run for the new default (include against exclude_infra at 425888bc4): Qwen3-1.7B on GSM8K through Gym equivalence_llm_judge, which sends every answer to the judge. A proxy refuses a fixed 10% of judge prompts, so 9.9% of rows are masked as judge_failed. exclude_infra showed no regression: validation accuracy 0.777 against 0.758 at step 150 (ahead from step 50 on), higher train reward from step 26 on, and the same KL. One seed per arm. Details and the full table are in the C1 thread. Still open: @mehraakash and @aroshanghias-nvd, the #4160 reviewers, confirm the new default.

Training check (a small real run, with injected masks)

Two GRPO jobs ran this PR at dfe2133bd. Qwen3-0.6B trained on GSM8K through NeMo Gym's math_with_judge server, with the legacy sync trainer: 16 prompts × 8 samples, 5 steps, one GB200 node per job, the same seed and data. The jobs differ only in grpo.masked_reward_policy: include or exclude_infra (default policy_failure_kinds).

At RL's Gym pin at that time, no environment put a policy kind on a masked row. So a local test patch in math_with_judge (not part of this PR) masked about a third of the rows with a reward of 0. A hash of the prompt and the sample index picked the rows, so both jobs masked the same rows. The kinds took the normal Gym → RL path.

Step Masked Policy kind Infra kind No kind Left out of the statistics under exclude_infra infra_failure_sample_rate
1 43 24 13 6 19 of 128 0.148
2 44 18 20 6 26 0.203
3 42 17 20 5 25 0.195
4 44 19 19 6 25 0.195
5 40 16 18 6 24 0.188
  • In each job, the logged advantages match a separate recomputation from the dumped rewards under that job's own rule, within 3e-7. They do not match the other rules (differences up to 1.27). In each job, 41 to 72 of about 86 unmasked rows per step get a different advantage under the other rule.
  • No masked row carried any loss under either policy.
  • Step time and token_mult_prob_error (1.011 to 1.014) were about the same in both jobs.
  • Not shown: training quality, convergence or held-out accuracy; real environments that emit these kinds; the async, TransferQueue and SingleController paths (unit tests only). The two jobs sampled differently, so their reward curves are not a controlled comparison.

Local results (CPU workstation, at 425888bc4, merged with main in eb698bc62)

  • Unit tests, every touched test file plus related SingleController, advantage, PPO and config tests, from the repo root: 3,246 passed, 0 failed. The 1,687 skips are per-recipe checks in test_config_validation.py that do not apply to a given recipe.
  • Gym-only lane (--nemo-gym-only tests/unit): 1,377 passed and 19 errors. The 19 errors are environment errors on this workstation, in tests this PR does not change. 14 tests start Gym servers whose local venvs predate the current Gym pin, and this machine's uv is older than that pin requires. 5 tests start a real vLLM worker, whose local venv predates main's vLLM version. The tests for the default kinds against Gym's list and for the setup name check pass.
  • The repo pre-commit hooks (ruff, import order, ruff format, pyrefly) pass on the changed files.
  • Not run locally: GPU functional tests.
Tests added and mutation checks
  • test_trainers_infra_masked_reward_never_moves_valid_siblings:
    • A batch built by the real Gym ingestion code runs through grpo_train, async_grpo_train and grpo_train_sync under all three values.
    • Changing the masked evaluator-error reward from 0 to 1 moves the valid rows only under include.
  • test_advantage_stage_infra_masked_reward_never_moves_valid_siblings: the same check on the SingleController advantage stage, with the GRPO, GDPO and Reinforce++ estimators (9 cases).
  • Forwarding tests check that each trainer passes grpo.policy_failure_kinds on: legacy grpo_train, the async collector, the TQ sync actor, SingleController setup, RolloutManager, both places inside the rollout code, and the prompt-group seal.
  • Focused tests cover:
    • infra_failure_flags;
    • the builder setting dataset weights to 0, including with masking off;
    • the payload path, the finalizer (rows flagged and not flagged) and the receipt path;
    • infra_failure_sample_rate on the SingleController native and token-capture paths;
    • a ledger round trip and the load of a schema 8 ledger, which has no kind;
    • Forest segment rows taking their rollout's flag;
    • exclude_infra matching include on every row that is not infra;
    • SingleController dynamic sampling: a group with rewards [0 (infra), 1, 1] has no signal under exclude_infra, and the record and finalized adapters pick the same voters;
    • the default policy_failure_kinds matching Gym's shared kind list (Gym lane).
  • Mutation checks:
    • With the ingestion zeroing disabled, the three exclude_infra trainer cases and the ingestion test fail.
    • Removing any of the 8 forwarding arguments, the prompt-group seal's kind, the finalizer's row flag or either SingleController metric makes its new test fail.
    • Dropping the infra flags in the rollout manager, in voting_rewards, in the finalizer or in the finalized adapter makes a dynamic-sampling test fail. Removing a kind from the default fails the Gym-lane test.

Needs upstream changes

None. RL already reads the top-level failure_kind from Gym at its current pin. NVIDIA-NeMo/Gym#4882 gives more masked results a kind, but this PR does not need it. The same holds for the open NVIDIA-NeMo/Gym#6673 (stacked on NVIDIA-NeMo/Gym#6675), which gives judge replies with no verdict a kind. Those are infra kinds, so exclude_infra drops those rows.

PR commands and CI
  • CI label, exactly one:
    • CI:Lfast: the default for most PRs. Runs a fast test subset.
    • CI:L1: dependency or container changes (pyproject.toml, uv.lock, Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.
    • CI:docs: docs-only changes. Runs doc tests only.
  • /ok to test <full-commit-sha>: start CI for that commit. Post again after each push.
  • /review: automated review comments. Add mode=strict for a stricter review, reset=true for a fresh full review.
  • /resolve-conflict: Autobot merges main into this PR and resolves the conflicts. PRs from forks must allow edits by maintainers.
  • Locally: /review-pr-team <pr-number> for a team review before you ask for human review.
  • Contributor guidelines

🤖 Generated with Claude Code

… default

Add a third grpo.masked_reward_policy value, exclude_infra, and make it the
default. A rollout that the environment masked still votes in its group's
baseline and std only when its top-level failure_kind is listed in the new
grpo.policy_failure_kinds (default: agent_timeout, agent_command_not_allowed,
agent_limit, agent_invalid_output, model_context_limit). Any other masked
rollout, including one with no failure_kind, gets dataset weight 0 where RL
reads the Gym result, so the include population from #4160 leaves it out on
the legacy sync, async, TQ and SingleController trainers. include and
exclude behave as before.

The SingleController token-capture path carries the raw failure_kind
through the recovery ledger (schema v4) and ReassemblyRequest.infra_failure.
infra_failure_sample_rate reports the share of rollouts left out.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@copy-pr-bot

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

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 28, 2026
exclude_infra stays available as an opt-in value; the default stays include,
as in #4160. Update the config default, the example and reference configs,
the GRPO guide and the default test.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw yfw changed the title feat(grpo): keep infra-masked rollouts out of advantage statistics by default feat(grpo): add exclude_infra masked-reward policy for infra-masked rollouts Oct 28, 2026

@yfw yfw left a comment

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.

Self review of this draft, left as a comment. There are four inline comments:

  1. (C1) No test fails if a trainer stops passing grpo.policy_failure_kinds to its rollout code. Four trainer-level tests and small edits to existing rollout tests close the gap (test_grpo.py#L9586).
  2. (C2) The finalizer test has no row with flag False. One more parametrize case closes the gap (test_rollout_reassembler.py#L295).
  3. (C3) SingleController drops infrastructure-failed rows from the statistics but logs no infra_failure_sample_rate (payload.py#L184).
  4. (C4) The YAML comment says that names "may be added", but a recipe list replaces the five defaults (grpo_math_1B.yaml#L16-L17).

These parts are correct at head:

  • The worked-example table in the PR description matches a recomputation with the real calculate_baseline_and_std_per_prompt.
  • The include and exclude values of grpo.masked_reward_policy behave exactly as before.
  • The opt-out env.should_mask_flagged_samples: false holds on every path.
  • All tests in the 9 changed test files pass on CPU, except 3 existing tests that need a GPU, which this review did not run. The 22 unchanged test files that use a changed API also pass. Every new test runs in a CI lane.

Generated by Claude Code

Comment thread tests/unit/algorithms/test_grpo.py Resolved
Comment thread nemo_rl/experience/payload.py Resolved
Comment thread examples/configs/grpo_math_1B.yaml Resolved
…ind forwarding

- SingleController now logs infra_failure_sample_rate under exclude_infra:
  TQReplayBuffer.commit adds it to the rollout metrics on the native path, and
  finalize_group adds it to the finalizer metrics on the token-capture path.
  The guide now says that every trainer reports it.
- New tests check that each trainer passes grpo.policy_failure_kinds on:
  legacy grpo_train, the async collector, the TQ sync actor, SingleController
  setup (TQReplayBuffer and RolloutManager), the RolloutManager store, both
  places inside the rollout code, and the prompt-group seal.
- The finalizer test gets a row whose infra_failure flag is False.
- Comments, the guide and the example configurations now say that a recipe
  that sets grpo.policy_failure_kinds replaces the list (OmegaConf.merge
  replaces lists), so it must list the defaults with any new name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 23cf9bf

@yfw
yfw marked this pull request as ready for review October 29, 2026 19:05
@yfw yfw added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Oct 29, 2026
@yfw

yfw commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 23cf9bf

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

Static review of all 27 changed files and their affected trainer/data-plane paths found no demonstrated correctness regression. The current source addresses the earlier forwarding, finalizer False-row, SingleController metric, and list-replacement feedback.

Two nonblocking suggestions remain:

  1. (C5) Provide a controlled training comparison for the opt-in policy.
  2. (C6) Shorten repeated in-function policy explanations while retaining their invariants.

Tests and linters were not executed. Upstream Gym source was unavailable in the mount. Two child reports were unavailable despite terminal completion status; their assigned paths were inspected directly before consolidation.

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

Comment thread nemo_rl/algorithms/grpo.py Resolved
The full rule lives in docs/guides/grpo.md and in the
rollouts.infra_failure_flags docstring. The call sites now keep a short
pointer and their local invariant. Comments only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dfe2133

yfw added a commit to NVIDIA-NeMo/Gym that referenced this pull request Oct 29, 2026
…comparison

A failed judge comparison is still dropped. A rollout whose comparisons
all failed is now masked alone through the judge failsafe (reward 0.0,
mask_sample, failure_kind judge_failed), and its siblings keep their
scores. Before, it failed the whole group. The masked rollout is left out
of the group's length and style adjustments. When every rollout is left
uncovered, the whole group fails as a judge failure, as before.

- The server now waits for every comparison to finish or fail, within
  cohort_evaluation_timeout_s. A non-judge error still fails the group at
  once and cancels the comparisons still running.
- The fixed_baseline path follows the same rule. /compare has no
  per-response mask, so it still returns 503 when a response keeps no
  comparison.
- Checkpoints save and restore a member masked alone (masked_alone).
- New metric: genrm_masked_rollout_rate_per_group.

The masked rollout's reward is a placeholder, so a trainer must keep it
out of the group statistics: in NeMo RL, grpo.masked_reward_policy
exclude_infra (NVIDIA-NeMo/RL#4968) or exclude.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…kind-advantages

Main added rollout recovery schema v4 (token-capture receipts, #4124) and
v5 (logical_selection, #4200), so failure_kind moves to schema v6. The
ledger still loads v2 to v5, with failure_kind=None.

Conflicts kept both sides: failure_kind next to logical_selection in the
ledger, SiblingSealResult and both seal calls; infra_failure next to the
Forest fields in ReassemblyRequest; the infra metric next to the logical
owner counts; the infra sample_mask next to the sampler top-k copy.

Main moved row building into _publish_rows, so finalize_group now passes
infra_failure in. With forest_training, each segment row takes its
rollout's flag, and infra_failure_sample_rate counts rollouts.

Tests: the v3 load test is now a v5 load test; the finalizer test sets
capture_key, as main's receipts need; a new Forest test checks that the
segment rows of a flagged rollout get sample_mask 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ab0a647

@terrykong terrykong added CI:L1 Run doctests, unit tests, and functional tests CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) CI:L1 Run doctests, unit tests, and functional tests labels Nov 5, 2026
yfw and others added 2 commits November 16, 2026 16:26
…kind-advantages

Brings in main 939890a (94 commits). Conflicts, all keeping both sides:

- rollout_recovery.py: main's ledger is at schema 8 (6: turn-level
  recovery, 7: taskset attribution, 8: steps_allowed_short), so the
  sealed failure_kind moves from 6 to 9; schemas 2 to 8 still load,
  with failure_kind=None. The failure_kind check sits next to main's
  attribution_key check.
- rollout_manager.py: main's imports plus Collection; main's
  mask_sample_flagged() next to the failure_kind read.
- docs/guides/grpo.md: main unwrapped the guide's sentences (#5211);
  the exclude_infra text follows that style.
- test_grpo.py: main removed the masked_reward_policy default test
  under its testing rules (#5009); the exclude_infra behaviour tests
  stay.
- test_rollouts.py, test_single_controller_actor.py,
  test_rollout_reassembler_actor.py: both sides' tests and fields.
- test_rollout_manager.py: generate_for_finalization now returns
  (request, rollout_metrics).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…mpling under exclude_infra

main's SingleController dynamic sampling (#4588, #5202) decides whether
a group carries signal from its voting rewards (voting_rewards). It
treated exclude_infra like include, so an infrastructure-failed row
still voted there although the advantage stage leaves it out. With
rewards [0 (infra), 1, 1] the group was kept as mixed, and every row's
advantage was then 0.

voting_rewards now takes the exclude_infra flags
(rollouts.infra_failure_flags) and drops the flagged rows:
- native path: RolloutManager._voting_rewards computes them from the
  completions with grpo.policy_failure_kinds;
- token-capture path: the finalizer carries them per reward row as
  FinalizedGroup.reward_infra_failure.
Under include and exclude nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) label Nov 28, 2026

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of the exclude_infra follow-up to #4160: one point on the default for env-masked rows (C1), and seven smaller doc, config, test and placement fixes (C2–C8).

  1. (C1) Please make exclude_infra the default once a same-seed run on a recipe that masks samples shows no regression. This is what #4160 promised, and both #4160 reviewers should confirm.
  2. (C2) The guide and one test docstring say OSWorld masks evaluator errors with no failure_kind; at RL's Gym pin it tags them infrastructure_error. Wording only; training is unaffected.
  3. (C3) Please cut the long new comments and docstrings to 1–2 lines that point to the guide section.
  4. (C4) The infra_failure_sample_rate test cannot tell a per-row rate from the per-rollout rate; a one-row/two-row split fixes that.
  5. (C5) The policy_failure_kinds list in grpo_math_1B.yaml overrides the Python default for every recipe that inherits it, and no test ties the two together; please add a check over every shipped config in test_shipped_config.
  6. (C6) A misspelled name in policy_failure_kinds raises nothing and silently moves those rows out of the baseline; please check each name with Gym's require_failure_kind at setup.
  7. (C7) Please link the Gym source file from the comment above DEFAULT_POLICY_FAILURE_KINDS.
  8. (C8) Please move DEFAULT_POLICY_FAILURE_KINDS and FAILURE_KIND into nemo_rl/experience/interfaces.py, next to the other copied Gym names.

Please also correct the PR description's "Risk" bullet. It says swe_agents, anyswe and anyterminal mask limits and timeouts with no kind, so those rows are treated as infra under exclude_infra. At the Gym pin they tag them agent_timeout / agent_limit / model_context_limit (swe_agents/app.py#L359-L381, anyswe_agent/app.py#L160-L215, anyterminal_agent/app.py#L465-L470), so under exclude_infra those rows vote, as under include.

C-numbers here belong to this review; they are unrelated to the C1–C6 in earlier reviews on this PR.

The rest looks solid: the copied Gym kind list has a drift test that fails rather than skips, every mode check goes through one helper, and the trainer math did not change.

Background on how the setting works across the four trainers: https://terrykong.github.io/gh-pages-poc/terryk/pr-4160-who-votes.html

Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4968-who-votes-exclude-infra.html

Generated by Claude Code

Comment thread nemo_rl/algorithms/grpo.py Resolved
Comment thread docs/guides/grpo.md Resolved
Comment thread nemo_rl/experience/rollouts.py Resolved
Comment thread examples/configs/grpo_math_1B.yaml Resolved
Comment thread nemo_rl/algorithms/grpo.py Resolved
Comment thread nemo_rl/algorithms/grpo.py Resolved
Comment thread nemo_rl/algorithms/grpo.py Resolved
@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 2026
Review 5898906962 (terrykong):

- C1: grpo.masked_reward_policy now defaults to exclude_infra, in the field,
  grpo_math_1B.yaml, its reference copy and the guide. include keeps the
  earlier behavior. A same-seed run of both values follows.
- C2: the guide and two test docstrings no longer say OSWorld masks evaluator
  errors with no failure_kind (at the Gym pin it tags infrastructure_error).
- C3: long comments and docstrings cut to 1-2 lines that point to the guide.
- C4: the forest finalizer test gives its rollouts one and two rows, so a
  per-row infra_failure_sample_rate (2/3) differs from the per-rollout one.
- C5: test_shipped_config checks that every shipped config that sets
  grpo.policy_failure_kinds keeps all default kinds; the YAML links Gym's list.
- C6: under exclude_infra, setup asks one Gym actor to check each
  policy_failure_kinds name with Gym's require_failure_kind (legacy and
  SingleController setups), so a misspelled kind stops the run.
- C7/C8: DEFAULT_POLICY_FAILURE_KINDS and FAILURE_KIND move to
  nemo_rl/experience/interfaces.py, with a link to Gym's source file.

Setup tests stub the new check the way they stub the dataset coverage check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 425888b

…nd in-loss table

Review by aroshanghias-nvd on #4968: the advantage-estimator module docstring
still called include the default, and the in-loss filtering table in the GRPO
guide listed include as required although exclude_infra is also accepted
(setup rejects only exclude with seq_logprob_error_in_loss). The setup error
for exclude now names both values, and the test checks that exclude_infra
passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e997ead

terrykong
terrykong previously approved these changes Nov 30, 2026
@terrykong
terrykong enabled auto-merge (squash) November 30, 2026 22:05
@yfw

yfw commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/resolve-conflict

@yfw yfw added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L2 Run doctests, unit tests, functional tests, and convergence tests labels Dec 1, 2026
Signed-off-by: svcnemo-autobot <[email protected]>
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 3f9be6a

terrykong
terrykong previously approved these changes Dec 1, 2026
yfw added a commit to NVIDIA-NeMo/Gym that referenced this pull request Dec 1, 2026
…infra default

NVIDIA-NeMo/RL#4968 makes masked_reward_policy: exclude_infra the default.
Under it, a judge failure is not a policy fault, so a masked judge-failure
row leaves the group baseline, and its placeholder does not change the
other rollouts' advantages. The judge_failsafe docstring and the judge
guide said that the placeholder counts in the baseline under the default
include. They now say that it counts only under include, or when a
recipe adds the judge's failure kind to policy_failure_kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
yfw added a commit to NVIDIA-NeMo/Gym that referenced this pull request Dec 1, 2026
…der_reward() and the exclude_infra default

#6675 renamed the hook judge_failure_reward() to
judge_failure_placeholder_reward(). The lifecycle test reads the hook by
name, so it now looks up the new name, and the README names it too.

NVIDIA-NeMo/RL#4968 makes masked_reward_policy: exclude_infra the
default. The README said that include is the default and that exclude is
the setting to choose. It now says that the default exclude_infra keeps a
judge-failure row out of the group baseline, and that include is an
explicit choice that counts the placeholder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…masked_reward_policy

Main's #5098 added test_actor_forwards_the_token_capture_setting_to_the_gym_rollout
with a SimpleNamespace grpo config that has no masked_reward_policy. On this
branch rollout_to_tq passes exclude_infra_policy_kinds(cfg.grpo), which reads
that field, so the test raised AttributeError after the merge of main. Real
configs always carry it (GRPOConfig defaults it to exclude_infra), so the fake
config gets the field rather than the read getting a default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d45e5c5

@terrykong
terrykong disabled auto-merge December 1, 2026 10:02
@terrykong
terrykong enabled auto-merge (squash) December 1, 2026 10:36
@terrykong
terrykong merged commit 3678581 into main Dec 1, 2026
98 of 99 checks passed
@terrykong
terrykong deleted the yifuw/masked-failure-kind-advantages branch December 1, 2026 12:04
gwarmstrong pushed a commit to gwarmstrong/Gym that referenced this pull request Dec 1, 2026
…er choose its placeholder reward (NVIDIA-NeMo#6675)

* feat(verification): let a parser's JudgeError name judge_unparseable

A parser that finds no verdict in a judge reply can now raise
JudgeError(..., failure_kind="judge_unparseable"). judge_failsafe masks
the row under that kind and keeps the routing class judge_failed, so
recovery judges the row again from its saved answer. Before, every
JudgeError was recorded as judge_failed, so a judge that answered without
a verdict looked the same as a judge that did not answer.

is_judge_failure also accepts a resources server judge_unparseable event,
and judge_call_failed takes the kind. JudgeError refuses any other kind.
JudgeError without failure_kind still means judge_failed, so existing
servers do not change.

The judge guide now names this option for an unparseable verdict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* feat(verification): let a server choose the placeholder reward of a judge failure

judge_failsafe hard-coded the masked row's placeholder reward to 0.0. A
masked row does not train, but its placeholder still reaches reward
metrics. For a server whose scores sit around a neutral value other than 0,
a burst of judge failures then reads as a drop in the mean reward.

judge_failsafe takes a keyword-only placeholder_reward (default 0.0), and
SimpleResourcesServer passes judge_failure_reward(), which returns 0.0
unless a server overrides it. Every existing server keeps 0.0. Masking,
failure routing and the sidecar row are unchanged.

Tests: tests/unit_tests/verification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* test(server_runtime): check that /verify uses the server's placeholder reward

A SimpleResourcesServer whose verify raises JudgeError returns a masked
row with reward 0.0 by default, and with judge_failure_reward() when the
server overrides it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(eval): plan a re-judge for a judge failure that names its own kind

Collection saves a judge_failsafe row whose failure names its own kind
(judge_unparseable, or a provider stop) under that kind, and keeps the
producer's judge_failed only as _ng_failure_legacy_class. Recovery
planning matched only the exact class judge_failed, and the remote
evidence projection dropped the legacy class. So such a row ended as
stop/unknown, although gym eval reverify --judge-failed-only selects it.

Now:
- decide_recovery treats a row as a judge failure when its class or its
  legacy class is judge_failed, the predicate that the re-judge uses. This
  covers the sidecar row and the result-row check.
- The evidence projection keeps _ng_failure_legacy_class.
- The default recovery outcome policy verifies judge_unparseable, as it
  verifies judge_failed.

A provider stop saved through collection now gets its designed handling:
it waits for the quota reset, then its saved answer is judged again.

Tests: tests/unit_tests/eval/recovery/test_judge_failure_kind_recovery.py
runs judge_failsafe, collection and recovery planning for both
judge_unparseable forms, a plain judge failure and a quota stop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(rollouts): count a judge failure as 0 whatever placeholder it carries

count_failure_classes_as_zero promises zero-valued metric inputs. First
collection drops the reward from a judge-failure row, so it counts as 0.
But when the judge fails again in the end-of-run re-judge, the re-judge
saves the /verify reply, which carries the failsafe's placeholder reward.
_counted_failure_row kept that reward, so a server that overrides
judge_failure_reward() (genrm_compare returns 3.0) was counted at its
placeholder.

_counted_failure_row now counts a row whose class or legacy class is
judge_failed as 0.0. Every other class still counts as it stands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* docs(verification): describe the judge_unparseable kind and the placeholder reward

- The judge.py module docstring still told a parser to score an
  unparseable verdict and not raise. It now names
  JudgeError(..., failure_kind="judge_unparseable").
- The judge_failsafe docstring said the placeholder reaches reward metrics
  but no training signal. It now says what each side does: Gym leaves the
  row out of its aggregates, and a trainer that reads the /run reply gets
  the placeholder, which NeMo RL's default masked_reward_policy include
  counts in the group baseline.
- The judge guide names SimpleResourcesServer.judge_failure_reward().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* test: run judge_unparseable through collection, recovery and re-judge

- The saved-generation recovery test also runs for judge_unparseable and
  provider_credentials_rejected.
- The collection and re-judge test also runs a
  JudgeError(failure_kind="judge_unparseable") and a judge_unparseable
  event.
- The failsafe test asserts the kind on the selected failure event, which
  recovery reads first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* docs(verification): describe the placeholder under NeMo RL's exclude_infra default

NVIDIA-NeMo/RL#4968 makes masked_reward_policy: exclude_infra the default.
Under it, a judge failure is not a policy fault, so a masked judge-failure
row leaves the group baseline, and its placeholder does not change the
other rollouts' advantages. The judge_failsafe docstring and the judge
guide said that the placeholder counts in the baseline under the default
include. They now say that it counts only under include, or when a
recipe adds the judge's failure kind to policy_failure_kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* refactor(server_runtime): rename judge_failure_reward() to judge_failure_placeholder_reward()

The hook and the judge_failsafe argument named one concept twice. The hook
now carries the same name as the argument it supplies, placeholder_reward.
Both are new in this PR, so no alias is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

---------

Signed-off-by: Yi-Fu Wu <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Jiaqi Zeng <[email protected]>
katherineh123 pushed a commit to katherineh123/Gym that referenced this pull request Dec 2, 2026
…em 0 (NVIDIA-NeMo#6673)

* feat(verification): let a parser's JudgeError name judge_unparseable

A parser that finds no verdict in a judge reply can now raise
JudgeError(..., failure_kind="judge_unparseable"). judge_failsafe masks
the row under that kind and keeps the routing class judge_failed, so
recovery judges the row again from its saved answer. Before, every
JudgeError was recorded as judge_failed, so a judge that answered without
a verdict looked the same as a judge that did not answer.

is_judge_failure also accepts a resources server judge_unparseable event,
and judge_call_failed takes the kind. JudgeError refuses any other kind.
JudgeError without failure_kind still means judge_failed, so existing
servers do not change.

The judge guide now names this option for an unparseable verdict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(abstention): parse the judge grade explicitly; score an empty answer as incorrect

The fallback 'letter in text' matched any capital A, so "C: NOT_ATTEMPTED" graded CORRECT. A reply that is not a bare
letter is now read only from a leading letter, a stated grade, or the last label word. An empty final answer scores
incorrect without a judge call instead of likely earning the abstention reward.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(abstention): mask a judge reply without a grade instead of scoring it INCORRECT

Before: parse_judge_grade fell back to "B" (INCORRECT) for a judge reply with
no A/B/C grade it could read, so the row was trained at incorrect_reward (0.0).

Now: parse_judge_grade returns None for such a reply and verify raises
JudgeError(judge_unparseable); judge_failsafe turns it into a masked row routed
to the failures sidecar. An empty judge reply already masked (judge_failed)
and is unchanged; an empty policy answer still scores INCORRECT without a judge
call and stays trained.

Tests: resources_servers/abstention/tests (41 passed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(genrm_compare): give a cohort the judge could not score the neutral default_score

judge_failsafe hard-coded the masked row's placeholder reward to 0.0. For
genrm_compare, a cohort that exhausts its judge retries had every member logged
at reward 0 while a scored cohort averages around default_score (3.0), so a
burst of judge failures read as a drop in the mean GenRM reward although no
masked row trains.

judge_failsafe takes a keyword-only placeholder_reward (default 0.0, every
other server unchanged); SimpleResourcesServer passes judge_failure_reward(),
which genrm_compare overrides to config.default_score, the score an
unparseable verdict and a singleton cohort already get. Masking, failure
routing and the sidecar row are unchanged.

Tests: tests/unit_tests/verification (all pass) and
resources_servers/genrm_compare/tests (485 passed together).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(math_with_judge): mask judge replies without a verdict and math-verify failures

A judge reply that names neither [[A=B]] nor [[A!=B]] (only reasoning, a
refusal, empty or unlabelled text, no output) was scored as unequal, so the
row was trained as reward 0. A reply cut at the judge's own output limit was
parsed like a complete one. Both now raise JudgeError(judge_unparseable):
judge_failsafe masks the row and routes it to the failures sidecar, where
recovery re-judges it from the saved answer.

math-verify failures (the 10 s child-process deadline, a crashed child, an
exception or TimeoutException escaping math_metric, e.g. an expected answer
it cannot parse) returned (0.0, None). With should_use_judge the judge
already grades the answer in math-verify's place, which is unchanged; without
a judge the row was trained as 0 and is now masked as verifier_error.

Unchanged: no \boxed / no answer candidate and wrong answers are still
trained as 0. Subclasses that grade with their own _verify_answer
(physics_judge, ugphysics_judge, math_with_autograder) keep the 0.0 from
_verify_answer_with_library_async; polymath and math_tool_rewards inherit
the new behaviour.

Signed-off-by: Jiaqi Zeng <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(equivalence_llm_judge): mask judge replies cut off or without a verdict

A judge reply with no verdict label (no_verdict, unparseable_judge_output)
was treated as not equal: the row was trained as reward 0, or went to the
full-generation rescue pass. A reply cut at the judge's own output limit
(status incomplete) kept whatever label it held, and without one scored 0.
Every judge pass whose verdict the grade uses (first, rescue and swap passes)
now goes through _judge_verdict, which raises JudgeError(judge_unparseable)
for those replies: judge_failsafe masks the row and routes it to the
failures sidecar for re-judging. lc_judge runs on this server and gets the
same behaviour.

A row without its expected_answer was judged against an empty string and
trained as 0; it is now masked as verifier_error without calling the judge.

Unchanged: empty_final_answer and final_answer_too_long are still trained
as 0, and a parsed [[A!=B]] (or conflicting labels, last wins) still scores
0. _generate_judge_evaluation still returns its parse with diagnostics, so
subclasses that check it themselves (llm_judge_tool_rewards) keep their
own JudgeError.

Signed-off-by: Jiaqi Zeng <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(ether0): mask grader exceptions and rows without a usable solution

An exception raised by a reward function other than OracleError (a
malformed answer_info, a remote oracle client's transport error) was
logged and scored 0, so the row was trained as reward 0. The graders
score invalid and wrong answers 0 themselves (fuzzing them with
malformed SMILES, reactions and text raised nothing), so an exception
is the grader's own failure: it is now masked as verifier_error, like
the existing OracleError path.

A row whose solution string does not parse, or that names an eval
function the server does not have, has no usable expected-output spec;
it was scored 0 and is now masked as verifier_error.

Unchanged: no extractable answer, invalid molecules and wrong answers
are still trained as 0.

Signed-off-by: Jiaqi Zeng <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(jailbreak_detection): mask a judge failure instead of training it as the unclear reward

Before: _request_judge swallowed every judge transport, HTTP, JSON and schema
failure and returned (None, error); each verification path (policy-aware
verifiers, the legacy safety x quality flow, Nemotron mode) then scored the
row with its "unclear" reward (0.0 for safety_check in the live templates) and
it was trained. A judge reply with no message text (reasoning only, e.g. cut
at the judge's own max_output_tokens) took the same unclear path.

Now: _request_judge goes through call_judge, so 408/429/5xx replies, timeouts
and lost connections are retried and a call that still fails raises a
judge_failed event; a reply without message text, or a reply cut off
(incomplete_details set) before any label, raises JudgeError(judge_unparseable).
The base server's judge_failsafe turns both into a masked row
(mask_sample: true) routed to the failures sidecar.

Unchanged: an empty policy answer still scores 0 without a judge call, and a
complete judge reply that names neither label keeps the configured unclear
reward.

Tests: resources_servers/jailbreak_detection/tests (48 passed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(jailbreak_detection): mask a complete judge reply that names no verdict label

Before (after the previous jailbreak_detection commit): a complete, non-empty judge reply naming neither of
its labels still scored the "unclear" reward and was trained. That applied to
the policy-aware verifiers (rewards.unclear, 0.0 for safety_check), the legacy
safety judge (reward_if_unclear), the legacy quality judge (fell back to
reward_if_quality_low) and the Nemotron judge (no "Response harm:" verdict).

Now: every such reply raises JudgeError(judge_unparseable) on all three scoring
paths; judge_failsafe turns it into a masked row routed to the failures
sidecar. The failure reason says whether the judge's own output limit cut the
reply. The unreachable unclear branches in the legacy flow are removed;
reward_if_unclear stays a config field (no longer read) so existing configs
still validate.

Unchanged: an empty policy answer still scores 0 without a judge call and is
trained; parsed SAFE/UNSAFE and per-verifier labels score as before.

Tests: resources_servers/jailbreak_detection/tests (50 passed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(multichallenge): mask a judge reply without a verdict instead of defaulting it to NO

Before: _extract_verdict returned "NO" for a judge reply with neither
[[YES]] nor [[NO]], and its plain-text fallback matched "NO" as a substring of
the last line, so "NOT", "CANNOT", "UNKNOWN" or an empty reply (a judge cut
while reasoning) also read as NO. The row was trained, and every rubric item
whose pass criterion is NO passed on it.

Now: the fallback accepts only a last line that is the bare verdict
(optionally bracketed, emphasised or labelled, e.g. "**No**", "Verdict: yes");
any other reply raises JudgeError(judge_unparseable), which judge_failsafe
turns into a masked row. Judge transport failures already masked through
call_judge and are unchanged.

Also: an empty final answer (nothing left once reasoning is stripped) now
scores 0 without a judge call, as abstention and jailbreak_detection
already do. Judged, it passed NO-criterion items
(reward 1.0 on a single-item NO rubric). It stays trained (model's fault).

Tests: resources_servers/multichallenge/tests (22 passed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): mask a judge reply without a verdict by default

Before: _extract_verdict returned FAIL for a judge reply with no PASS/FAIL
verdict (prose, or an empty reply from a judge cut while reasoning), so the
criterion scored FAIL and the row was trained at that score.

Now: _extract_verdict returns no verdict for such a reply, and a new knob,
fail_on_unparseable_judge_response (default true), raises
JudgeError(failure_kind=judge_unparseable); judge_failsafe turns it into a
masked row routed to the failures sidecar. Setting the knob to false keeps
the old FAIL scoring. A parsed FAIL verdict is unchanged and still trained.

Also: an empty final answer (nothing left once reasoning is stripped) now
scores 0 without a judge call, as abstention and jailbreak_detection
already do; judged, it could pass criteria that only
forbid something. It stays trained (model's fault).

Tests: resources_servers/inverse_if/tests (25 passed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* feat(verification): let a server choose the placeholder reward of a judge failure

judge_failsafe hard-coded the masked row's placeholder reward to 0.0. A
masked row does not train, but its placeholder still reaches reward
metrics. For a server whose scores sit around a neutral value other than 0,
a burst of judge failures then reads as a drop in the mean reward.

judge_failsafe takes a keyword-only placeholder_reward (default 0.0), and
SimpleResourcesServer passes judge_failure_reward(), which returns 0.0
unless a server overrides it. Every existing server keeps 0.0. Masking,
failure routing and the sidecar row are unchanged.

Tests: tests/unit_tests/verification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* test(server_runtime): check that /verify uses the server's placeholder reward

A SimpleResourcesServer whose verify raises JudgeError returns a masked
row with reward 0.0 by default, and with judge_failure_reward() when the
server overrides it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(eval): plan a re-judge for a judge failure that names its own kind

Collection saves a judge_failsafe row whose failure names its own kind
(judge_unparseable, or a provider stop) under that kind, and keeps the
producer's judge_failed only as _ng_failure_legacy_class. Recovery
planning matched only the exact class judge_failed, and the remote
evidence projection dropped the legacy class. So such a row ended as
stop/unknown, although gym eval reverify --judge-failed-only selects it.

Now:
- decide_recovery treats a row as a judge failure when its class or its
  legacy class is judge_failed, the predicate that the re-judge uses. This
  covers the sidecar row and the result-row check.
- The evidence projection keeps _ng_failure_legacy_class.
- The default recovery outcome policy verifies judge_unparseable, as it
  verifies judge_failed.

A provider stop saved through collection now gets its designed handling:
it waits for the quota reset, then its saved answer is judged again.

Tests: tests/unit_tests/eval/recovery/test_judge_failure_kind_recovery.py
runs judge_failsafe, collection and recovery planning for both
judge_unparseable forms, a plain judge failure and a quota stop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* test(opencode_multimodal_benchmarks): expect a masked row for an unusable math-judge reply

math_tool_rewards inherits math_with_judge's judge parsing, which now raises
JudgeError for a judge reply that is cut off or names no verdict (NVIDIA-NeMo#6673).
Route the test through judge_failsafe, as the /verify route does, and assert
that those cases come back masked (judge_failed / judge_unparseable). Usable
verdicts are still graded and shaped as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(abstention): read only grades the judge gave, and mask a cut judge reply

The grade parser read grades that the judge never gave:
- The stated-grade rule ignored case, so the article in "a clear B" read as
  grade A. The letter is now case-sensitive, and "a" or "an" before it is
  skipped.
- A negated label ("not CORRECT", "isn't CORRECT") read as that label. It
  is now skipped.
- A reply that named two labels graded by the last one, so "INCORRECT. It
  would be CORRECT only if ..." graded A. A label now counts only when the
  reply names exactly one distinct label.
- A leading letter in bold, italics, code marks, quotes or brackets did not
  count. It does now.

A judge reply cut at its output limit was graded from its unfinished text.
_call_judge now raises JudgeError(judge_unparseable) for it, so the row is
masked, as math_with_judge and equivalence_llm_judge already do.

The README now gives the empty-answer and masking rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(jailbreak_detection): keep a known zero, and score a refused judge prompt as unsafe

- A row whose safety judge said UNSAFE was masked when another judge gave
  no verdict, so a harmful answer escaped its 0. When a product reward
  already has a factor of 0, a judge failure on another factor now keeps
  the 0. This covers the legacy safety x quality flow and the policy-aware
  verifiers under reward_combination product. A SAFE row still masks.
  gather now waits for every verifier, so no judge call keeps running.
- A reply cut before any output token means that the judge server refused
  the prompt for its length. A long jailbroken answer reaches this path.
  It now scores as the answer's failure (negative, unsafe or low quality)
  instead of a mask.
- A reply cut at the judge's output limit now masks even when it already
  holds a label, because the label can come from unfinished reasoning.
- The single safety judge path joins VERIFY_PATHS in the tests.
- reward_if_unclear is removed. The config ignores unknown keys, so a
  configuration that sets it still loads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(equivalence_llm_judge): score a refused judge prompt 0, and keep the first pass 0 after a rescue without a verdict

- A reply cut before any output token means that the judge server refused
  the prompt for its length (vllm_model returns such a reply for a prompt
  longer than the judge's window). The policy controls the answer length,
  so the pass now scores not equal instead of masking the row.
- The rescue pass only adds partial credit to a first pass that said not
  equal. A rescue reply without a verdict now keeps the first pass's 0. A
  failed rescue call still masks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(multichallenge): mask a cut judge reply, and fail an item whose judge prompt was refused

- A judge reply cut at its output limit was read for a draft verdict, so a
  cut reply could pass a rubric item. It now raises
  JudgeError(judge_unparseable) before the verdict is read.
- A reply cut before any output token means that the judge server refused
  the prompt for its length. The item now fails instead of masking the row.
  This check runs before the cut-reply check.
- Tests pin the end anchor of the bare verdict line ("Not enough
  information to decide." is no verdict).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): mask a cut judge reply, and fail a criterion whose judge prompt was refused

- With fail_on_unparseable_judge_response (the default), a judge reply cut
  at its output limit now raises JudgeError(judge_unparseable) before the
  verdict is read. With the setting off, scoring is unchanged.
- A reply cut before any output token means that the judge server refused
  the prompt for its length. The criterion now receives FAIL, with the
  setting on or off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(math_with_judge): score a wrong answer that breaks math-verify 0, and a refused judge prompt 0

- With the judge off, a wrong answer that made math-verify time out (for
  example a large power tower) was masked as verifier_error. When
  math-verify fails, the server now checks that it still grades the gold
  against itself. If it does, the answer caused the failure and scores 0.
  A bad gold or a broken library still masks the row.
- A judge reply cut before any output token means that the judge server
  refused the prompt for its length. The answer now scores as not equal
  instead of masking the row. This check runs before the cut-reply check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* docs: describe the masking rules in the GenRM README and reward-profiling manifests

- genrm_compare: the failsafe's placeholder reward is default_score, not
  0.0.
- The abstention notes in the reward-profiling manifests said that
  parse_judge_grade falls back to INCORRECT. A reply without a grade, or a
  cut reply, now masks the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(rollouts): count a judge failure as 0 whatever placeholder it carries

count_failure_classes_as_zero promises zero-valued metric inputs. First
collection drops the reward from a judge-failure row, so it counts as 0.
But when the judge fails again in the end-of-run re-judge, the re-judge
saves the /verify reply, which carries the failsafe's placeholder reward.
_counted_failure_row kept that reward, so a server that overrides
judge_failure_reward() (genrm_compare returns 3.0) was counted at its
placeholder.

_counted_failure_row now counts a row whose class or legacy class is
judge_failed as 0.0. Every other class still counts as it stands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* docs(verification): describe the judge_unparseable kind and the placeholder reward

- The judge.py module docstring still told a parser to score an
  unparseable verdict and not raise. It now names
  JudgeError(..., failure_kind="judge_unparseable").
- The judge_failsafe docstring said the placeholder reaches reward metrics
  but no training signal. It now says what each side does: Gym leaves the
  row out of its aggregates, and a trainer that reads the /run reply gets
  the placeholder, which NeMo RL's default masked_reward_policy include
  counts in the group baseline.
- The judge guide names SimpleResourcesServer.judge_failure_reward().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* test: run judge_unparseable through collection, recovery and re-judge

- The saved-generation recovery test also runs for judge_unparseable and
  provider_credentials_rejected.
- The collection and re-judge test also runs a
  JudgeError(failure_kind="judge_unparseable") and a judge_unparseable
  event.
- The failsafe test asserts the kind on the selected failure event, which
  recovery reads first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): read only a whole PASS or FAIL word in the keyword fallback

The keyword fallback of _extract_verdict tested `"PASS" in line` before
FAIL on the last lines. So a reply whose last lines held "passenger",
"passport", "passing" or "0 out of 3 passed" read as PASS, and the
criterion scored 1.0. In a replay of real inverse_if judge replies, 41 of
177 replies used this fallback, and 15 of those got PASS only from such a
word.

The fallback now reads only the whole word PASS or FAIL, latest line
first. A line that names both words is ambiguous, so the reply has no
verdict and the row is masked, as for any reply without a verdict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): read the keyword fallback verdict only in capitals

The keyword fallback matched PASS and FAIL in any case. A lowercase word
is prose ("Since 5 of 6 criteria pass") and can describe other criteria
than the one asked. In a replay of real inverse_if replies, 11 of the 37
replies that used the fallback got their verdict only from a lowercase
word, and 2 of those contradicted what the reply said about the asked
criterion. Only the whole word PASS or FAIL in capitals counts now, so
"Result: Pass" in mixed case also gives no verdict, and the row is masked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(judges): mask ambiguous, filtered and inconclusive verdicts

Signed-off-by: yaoyu-33 <[email protected]>

* fix(abstention): reject conflicting grades anywhere in a judge reply

Signed-off-by: yaoyu-33 <[email protected]>

* fix(math): check the reference after a library grading deadline

Signed-off-by: yaoyu-33 <[email protected]>

* test(ether0): verify invalid predictions receive a measured zero

Signed-off-by: yaoyu-33 <[email protected]>

* fix(abstention): give the shipped judge room for more than a bare letter

A judge reply cut at max_output_tokens masks the row
(judge_unparseable). The shipped configuration gave the judge 64 output
tokens, which fits a bare letter only, so a judge that reasons or explains
its grade masked every row. The shipped budget is now 8192 tokens, as in
the reward-profiling manifests and the multichallenge and inverse_if
configurations. A test checks the shipped budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* docs(verification): describe the placeholder under NeMo RL's exclude_infra default

NVIDIA-NeMo/RL#4968 makes masked_reward_policy: exclude_infra the default.
Under it, a judge failure is not a policy fault, so a masked judge-failure
row leaves the group baseline, and its placeholder does not change the
other rollouts' advantages. The judge_failsafe docstring and the judge
guide said that the placeholder counts in the baseline under the default
include. They now say that it counts only under include, or when a
recipe adds the judge's failure kind to policy_failure_kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* refactor(server_runtime): rename judge_failure_reward() to judge_failure_placeholder_reward()

The hook and the judge_failsafe argument named one concept twice. The hook
now carries the same name as the argument it supplies, placeholder_reward.
Both are new in this PR, so no alias is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* refactor(genrm_compare): override judge_failure_placeholder_reward()

NVIDIA-NeMo#6675 renamed the hook judge_failure_reward() to
judge_failure_placeholder_reward(). Rename the GenRM override with it, so
a cohort that the judge failed to score still carries default_score.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(abstention): a quoted question mark is not the judge's doubt

An explicit leading grade whose explanation quotes the question, such as
'A: Paris answers the question "What is the capital of France?" exactly.',
was masked: the doubt check read the quoted question mark as uncertainty.
The parent scored this reply 1.0. Quoted text is now removed before the
doubt check. 'maybe', 'perhaps' and 'I cannot' outside quotes still give
no grade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): a cut judge reply scores FAIL when fail_on_unparseable_judge_response is off

With the option off, a reply cut at the judge's output limit was still read
for verdict words, so one ending 'A bare yes would PASS, however the' scored
1.0. The README says such a reply scores FAIL. A cut reply now scores FAIL
without being read; with the option on it still raises judge_unparseable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

* fix(inverse_if): the keyword fallback reads only a line that states the verdict

'I cannot assign a PASS without further evidence.' got an unmasked 1.0: the
fallback took any of the last lines with exactly one capital PASS or FAIL.
That line must now state the verdict: the word alone, or after a label such
as 'Result:' or 'Verdict:' (also a JSON "result" line whose block does not
parse), with an optional reason after it. A verdict word inside a sentence
gives no verdict, so the row is masked by default.

On the 167 saved real judge replies of the NVIDIA-NeMo#6673 replay, 2 replies change
(one FAIL that belonged to another criterion, one PASS inside prose), both
in a row that is already masked; no row outcome changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>

---------

Signed-off-by: Yi-Fu Wu <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Jiaqi Zeng <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants