Skip to content

[epic] Expose Gym's failure-handling behavior as a documented, configurable policy #1492

Closed

Description

@sephmard

Use cases, pain points, and background

Today, Gym's rollout loop already survives per-sample failures and non-kill-shaped exceptions are caught per-sample, written to a _failures.jsonl sidecar with a coarse failure class, and the batch continues. resume_from_cache re-dispatches the missing samples on a follow-up invocation. The reward profiler silently excludes NaN/missing samples from aggregates via pandas.dropna().

The problem isn't that the batch dies. The problem is:

  1. The behavior is undocumented and hardcoded. Users don't know whether a partial result is intentional or a bug. There's no per-benchmark policy.
  2. Failure categorization is too coarse for triage. Today: 5 classes (kill_shaped, timeout_exceeded, skipped, transient, legitimate). Users can't tell api_timeout from oom from context_length_exceeded.
  3. NaN exclusion in the profiler is silent. A 500-sample benchmark that loses 12 hard samples to OOM reports a number computed over 488 with no warning. Reviewers can't tell the denominator shifted.
  4. There's no strict mode. A team publishing leaderboard numbers should be able to opt into "abort the batch on any per-sample failure" so they investigate before publishing. Today's behavior is always "keep going."
  5. Kill-shaped failures (Slurm preemption, Ray worker death, OOM) are the actual "4 hours of work lost" case and these don't reach the sidecar and require the user to know to invoke resume_from_cache.

Add a documented failure_mode config field with three settings: continue (the existing default behavior, just made explicit), strict (net-new: abort on any per-sample failure), and diagnostic (net-new: continue with fine-grained categorization and visible denominator reporting). The default behavior of every existing benchmark is unchanged.

Three failure-mode-related risks are easy to land accidentally:

  1. Silent denominator shifts. A 500-sample benchmark that drops 12 hard samples is no longer a 500-sample benchmark. Today this happens silently via pandas.dropna().
  2. Coarse error metadata. The 5 existing classes (kill_shaped etc.) don't help a user decide whether to re-run, file a bug, or accept the loss.
  3. No strict gate for eval runs. Teams publishing numbers have no built-in way to say "I'd rather the batch die than silently lose samples."

The policy:

  • Default is continue exactly what happens today. No benchmark changes behavior in this PR.
  • strict and diagnostic are opt-in per benchmark, and only after the benchmark owner has demonstrated a concrete need.
  • The config field's documentation states each value's accuracy implications in plain language.
  • The reward profiler always reports the surviving-vs-original denominator in its output, regardless of mode

User scenarios

Scenario 1 — Today's silent denominator (the real problem)

A researcher kicks off a 4-hour SWE-Bench-Verified eval. At hour 3:15, the upstream API hiccups; one sample's retries exhaust. The failure is captured in _failures.jsonl; the other 499 samples complete. The researcher comes back to a partial result.

The aggregate score reported by the reward profiler is computed over 499 samples with the failed one was silently dropped via dropna(). There is no visible warning, no log line, no denominator: 499 of 500 annotation. The reported number is computed over a quietly-shifted denominator, and the failure metadata is one of five coarse classes that doesn't tell the researcher whether it was an API hiccup worth retrying or a fundamental bug.

This is the status quo. The job didn't die. The answer is quietly wrong.

Scenario 2 — Same run, failure_mode: strict

A team about to publish leaderboard numbers opts into failure_mode: strict for the run. The hour-3:15 hiccup aborts the batch immediately. The team investigates, fixes the underlying issue, and re-runs. The reported number is computed over the full 500-sample denominator with full confidence. Strict mode is the explicit opt-in for "no surprises in the result."

Scenario 3 — Long terminal-bench, failure_mode: diagnostic

A terminal-bench run hits five different failures over an 8-hour window. With failure_mode: diagnostic:

  • Each failed sample is recorded with a fine-grained error_category (api_timeout, oom, preemption, context_length_exceeded, rate_limited) — beyond today's coarse 5 classes.
  • The reward profiler emits a visible denominator-shift warning in its output: 498 of 500 samples scored — 2 excluded due to: 1 api_timeout, 1 preemption.
  • The aggregate score is explicitly computed over the surviving samples, not by silent dropna().

Scenario 4 — Kill-shaped failure during a long Ray-on-Slurm job (the actual "4 hours lost" case)

A worker is preempted at hour 3. Today, kill-shaped failures don't reach the sidecar but the affected samples are simply missing from the output. The batch may continue or may die depending on Ray's resilience. The user has to know to invoke resume_from_cache=true to re-dispatch the missing samples. With failure_mode: diagnostic, kill-shaped failures are surfaced as a visible result-set annotation (worker died at task 247, 3 samples lost) with a hint to resume.

Scenario 5 — Existing benchmark with no config change

A team that doesn't touch their config keeps the default failure_mode: continue. Behavior is byte-for-byte identical to today. The denominator may still shift; the profiler still silently excludes NaN samples. But now the policy is documented and the field is in the config, ready to be flipped to strict or diagnostic later. No existing benchmark is affected by this PR.

Scope

In scope:

  • A researcher running a long agentic eval has a clear, documented choice between "fail loud" (strict), the existing default (continue), and "keep going with structured diagnostics" (diagnostic).
  • Anyone reading a benchmark config can see at a glance which mode it's on and what that implies for accuracy.
  • Anyone reading a result set can tell whether failures occurred, what fine-grained category they fell into, and how the denominator shifted.
  • The profiler emits a visible N of M scored line on every run, so denominator drift is never silent.
  • Leaderboard-grade runs default to the conservative behavior. No accidental score inflation.

Out of scope:

This is only about how the framework reports and gates per-sample failures after retries and timeouts have already fired. It does not touch:

  • Retry / backoff policy on HTTP errors (server_utils.py retries, MAX_NUM_TRIES=3).
  • Per-sample timeouts (set by each agent server).
  • Upstream LLM client error handling (tracked under Evaluator-consolidation Feature Add copy-pr-bot #1).
  • The set of fine-grained error_category values — defining that taxonomy is its own follow-up issue; this PRD only introduces the field.
  • Auto-invoking resume_from_cache for kill-shaped failures (annotation only in this PR; auto-resume is a follow-up).

failure_mode is a policy lens over existing behavior, not a new retry layer.

Acceptance criteria

  • failure_mode is a documented config field on the rollout config, defaulting to continue (the existing behavior).
  • continue mode: byte-for-byte identical to today's default. No existing benchmark behavior changes.
  • strict mode: any per-sample failure (transient, legitimate, timeout, skipped, kill-shaped) aborts the batch with a non-zero exit code and a clear message identifying which sample failed.
  • diagnostic mode: failures recorded with a fine-grained error_category field beyond today's 5 coarse classes; the failed sample appears in the output with NaN reward and the category populated; aggregates explicitly exclude them rather than relying on implicit dropna().
  • In every mode, the reward profiler emits a visible N of M samples scored — K excluded (<breakdown>) line in its output.
  • The config field's documentation tells the reader the accuracy implications of each value in plain language.
  • No existing benchmark is flipped off continue as part of this change.
  • resume_from_cache continues to re-dispatch missing samples correctly under all three modes.

Developer References

These are documented here only to prevent reviewers from thinking they need to be built:

  • Batch survival on per-sample exception. Already exists: nemo_gym/rollout_collection.py:598-604 uses tqdm.as_completed; per-sample exceptions are caught in _post_subroutine (lines 582-596) and the loop continues.
  • Failures sidecar. Already exists: _failures.jsonl with _ng_failure_class and _ng_failure_terminal fields (rollout_collection.py:56-80, 414-434).
  • Resume-from-cache. Already exists: resume_from_cache: bool config (rollout_collection.py:188-191); _load_from_cache() does the set-difference re-dispatch (lines 306-359).
  • NaN exclusion from aggregates. Already exists, but implicit: reward_profile.py:164 calls data.dropna(); line 200 uses notna(). This PR makes the exclusion explicit and visible.
  • Coarse failure classification. Already exists: 5 classes in stirrup_agent/app.py:103-121, 163-203. This PR adds a finer-grained error_category in addition to the existing class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    evaluationneeds-designnel-feature-parity

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions