Skip to content

feat(eval): count repetition stops in the inspect's failure facts - #6093

Merged
AdamRajfer merged 2 commits into
mainfrom
arajfer/inspect-repetition-stops
Nov 13, 2026
Merged

AdamRajfer merged 2 commits into
mainfrom
arajfer/inspect-repetition-stops

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes a repetition stop visible in the inspect of every run.

When vLLM's repetition detection stops a generation, #5975 keeps the cause as native_finish_reason: repetition beside the SDK's stop, and rollout health flags the call as model_call_runaway_generation. The inspect (gym eval resubmit --recover --inspect) still could not see it: the evidence collector keeps only a fixed set of finish reasons and none of the saved response, so such a call read as an ordinary stop, and a looped answer looked like any other answer in gate_task.failures.

  • The evidence collector flags each saved model call that the provider stopped for repetition (a repetition finish reason or a repetition_detected stop reason, on the call or its saved Chat Completions or Responses reply). Only the boolean leaves the run host.
  • gate_task.failures.repetition_stops counts the policy's flagged calls and the rows that hold them, beside output_budget_refits. A judge's or another model's call is not counted.
  • The health verdict line names the count when it is nonzero.
  • run-and-babysit-eval lists the new field.

A repetition stop is the model's own ending. It is a reported fact, not a failure: the answer is scored as produced, nothing is retried, no failure kind is added, the gate's verdicts and thresholds are unchanged, and no repetition detector is enabled. Whether to turn detection on stays a model-serving choice of the caller; the benchmark protocol is unchanged.

Issue: none; this follows #5975 to the inspect.

Validation

  • pytest tests/unit_tests/orchestration/test_repetition_stop_facts.py: 2 passed. Both fail on main (the field does not exist). The test runs the real collector script over saved rows: Responses and Chat Completions repetition stops, a stop-reason-only stop, a judge's repetition stop that must not count, and an answered zero-reward row that must not become a response or trial failure.
  • pytest tests/unit_tests/orchestration -n 8: 3024 passed; the 6 failures in test_eval_resubmit.py need the wandb extra, which my environment lacks, and fail the same way on main.
  • pytest tests/unit_tests/rollouts/test_rollout_collection.py tests/unit_tests/eval tests/unit_tests/cli: 2368 passed.
  • pre-commit run on the changed files passes (ruff, format, guardwords, import-linter).

Rollouts

N/A: the change reads saved evidence after a run; it changes no agent, environment, sampling or scoring. The fixtures use the response shapes #5975 saves for a vLLM repetition stop.

Compatibility

gate_task.failures gains one key, repetition_stops: {count, rows}. Existing keys and the verdict text of runs without repetition stops are unchanged.

output_budget_refits now counts only the row that decides each scored trial, like the new key: refits in superseded attempts and in rows of unscored (infra-failed) trials no longer count, so a run can show fewer refits than on an earlier Gym version (test_only_the_row_that_decides_the_trial_is_counted).

Since #5975 Gym keeps vLLM's repetition stop as native_finish_reason
"repetition" beside the SDK's "stop", and rollout health flags it. The
inspect still could not see it: the evidence collector keeps only a
fixed set of finish reasons and none of the response, so a call the
serving engine stopped for repetition read as an ordinary "stop".

The collector now flags each saved model call it finds stopped for
repetition (a "repetition" finish reason or a "repetition_detected"
stop reason), and gate_task.failures counts the policy's flagged calls
and their rows as repetition_stops; the health verdict line names them
when there are any. It is a fact, not a failure: the answer stays
scored as produced, nothing is retried, and no detector is enabled.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer self-assigned this Nov 13, 2026
@AdamRajfer AdamRajfer added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Nov 13, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 13, 2026 00:09

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP WITH CARE

One RISK: the new count attributes a judge's repetition stop to the policy when both use the same model server.

I reviewed all four changed files and traced the affected saved-call, collector, ownership, and gate-summary paths. I found no change to scoring, retry decisions, or health thresholds. This was a static review; I couldn't execute tests in this read-only environment.

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

Comment thread nemo_gym/orchestration/recovery.py Outdated
observed = row.get("ng_trial_observations")
calls = observed.get("model_calls") if isinstance(observed, dict) else None
stops = sum(
isinstance(call, dict) and call.get("repetition_stop") is True and _policy_call(row, call)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

RISK — Exclude verifier-owned calls that share the policy server

Failure: With one ordinary policy call c0 and one repetition-stopped judge call c1, both using policy_model, this reports {count: 1, rows: 1} instead of zero. This is a supported configuration: the committed judge configuration and agent configuration name the same server. _policy_call checks the server name, not the caller's role, so the inspect incorrectly labels the judge's loop as a policy loop. The existing health join already distinguishes verifier ownership from model identity.

Correction: Could you exclude calls referenced by verifier_invocations[].model_calls inside repetition_stops, before applying _policy_call? Keep the shared _policy_call helper unchanged for its existing classification callers. Match by call ID when supplied, otherwise by model reference and response ID, retaining any additional reference constraints.

For example, insert the following before stops = sum(...), then add and not verifier_owned(call) to that sum's predicate:

        verifiers = observed.get("verifier_invocations") if isinstance(observed, dict) else None
        verifier_refs = [
            ref
            for verifier in verifiers or []
            if isinstance(verifier, dict)
            for ref in verifier.get("model_calls") or []
            if isinstance(ref, dict)
        ]

        def verifier_owned(call):
            meta = call.get("response_metadata")
            meta = meta if isinstance(meta, dict) else {}
            return any(
                (
                    ref.get("model_call_id") == call.get("model_call_id")
                    if ref.get("model_call_id")
                    else ref.get("model_ref") is not None
                    and ref.get("response_id") is not None
                    and ref["model_ref"] == meta.get("model_ref")
                    and ref["response_id"] == meta.get("response_id")
                )
                and (ref.get("model_ref") is None or ref["model_ref"] == meta.get("model_ref"))
                and (ref.get("response_id") is None or ref["response_id"] == meta.get("response_id"))
                for ref in verifier_refs
            )

This is a source-based suggestion, not executed code; verify it before adopting it.

Preservation and acceptance: Add a proposed collector-backed regression with ordinary c0, repetition-stopped c1, the same policy model reference on both, and verifier ownership of c1. Expect {count: 0, rows: 0} and no repetition text in health_verdict. Cover ownership by call ID and separately by model/response IDs. Then mark c0 repetition-stopped too: expect {count: 1, rows: 1}, still excluding c1. Retain the existing mixed-model assertions: three policy stops in two rows, a distinct judge model excluded, zero response/trial failures, no exported response payload, and zero counts for ordinary or observation-free rows. The fix must leave scores, retry decisions, and gate status unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3dd4b1e: calls a verifier invocation owns (matched by call id, else by model and response id) are excluded before the policy check, with a regression test for a judge on the policy server. The count also reads only the row that decides each scored trial now, as does output_budget_refits.

A judge served by the policy's own server sent its calls under the policy's
model name, so a looping judge call counted as a policy repetition stop.
Calls a verifier invocation owns (by call id, else by model and response
id) are no longer counted.

Both repetition_stops and output_budget_refits now read only the row that
decides each scored trial (the last one saved for it), so an attempt a
later one superseded is not counted twice.

Signed-off-by: Adam Rajfer <[email protected]>

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. The collector sends only the boolean off the run host. The count is limited to policy calls in the rows that decide scored trials. Judge calls are excluded by verifier ownership: by call id, or by response id plus model_ref, both of which trial_refs / trial_metadata keep. A repetition stop changes no gate verdict, failure kind or retry. The tests run the real collector script over saved rows. One non-blocking note is inline.

return False


def output_budget_refits(decision: RecoveryDecision, collected: CollectedEvidence | None) -> dict[str, int]:

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.

Non-blocking: this also changes output_budget_refits. It used to count every saved row; now it counts only the last row of each scored identity. So refits in superseded attempts and in rows of unscored (infra-failed) trials no longer count. I think that is the right behavior, and test_only_the_row_that_decides_the_trial_is_counted pins it. But the Compatibility section says existing keys are unchanged. Could you add a line there, so a reader comparing refit counts across Gym versions knows why they dropped?

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.

Added to the Compatibility section: output_budget_refits now counts only the deciding row of each scored trial, so refit counts can drop against earlier Gym versions.

@github-actions

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit a6ab3e4 Nov 13, 2026
72 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/inspect-repetition-stops branch November 13, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants