Skip to navigation

Resumable Runs

View as MarkdownOpen in Claude

A long evaluation can outlive one allocation: the walltime runs out, the job is preempted, or a node fails. Marking a benchmark resumable makes its Slurm job a self-chaining sequence. When one job is killed by the scheduler, a successor starts and the run continues from the rollouts already collected instead of from zero.

driver:
benchmarks:
gpqa:
resumable: true
run:
config_paths:
- benchmarks/gpqa/config.yaml

To tune it, pass a mapping instead of true:

resumable:
max_retries: 5 # infrastructure retries: preemption, node or boot failure (default 3)
max_walltime: "48:00:00" # cap on total accumulated walltime (default: none)

Only executors that support it may set resumable, and Slurm does. The setting is per benchmark.

max_walltime is the chain’s total budget, summed over every job, not a per-job limit; each job still requests compute.cluster.walltime. Without it the chain has no walltime cap. With a cap equal to the job walltime, the first job that ends at its time limit spends the whole budget: its successor starts, stops at once with a walltime-cap stop (reached max_walltime cap, or Less than one minute remains in the walltime budget) and the run waits for gym eval resubmit <GYM_JOB_ID> <BENCHMARK> --recover --max-walltime HH:MM:SS --walltime-reason TEXT. To let the chain continue on its own, set max_walltime to the total time the run may use, for example three times the job walltime for up to three segments. This is deliberate: the chain never grants time beyond the budget, so a run that needs more than it was given stops with its rollouts saved instead of running on unattended.

Recovered grading attempts are reported separately and do not count toward the trial-health threshold when every observed attempt is joined to the same completed grading operation and its valid saved verdict. A completed grader that returns a bound result without a valid verdict counts as a trial fault; missing or unbound grading evidence remains unknown. The denominator remains the full expected trial inventory, including repeats.

How it works

The job script begins with a prologue that runs before any service starts. Each job in the chain receives its predecessor’s Slurm job ID, looks at that job’s final state with sacct, and decides whether to carry on. Before doing any real work, it queues its own successor with sbatch --dependency=afternotok:<this job> --kill-on-invalid-dep=yes, so the chain continues even if this job is killed mid-run.

It then queues a sentinel for that successor, sbatch --dependency=afterany:<successor>. The sentinel continues the chain only if the successor dies after it started and before its own prologue recorded it; otherwise it exits without doing work.

If a job finishes successfully, its queued successor has a dependency that can never be satisfied, and Slurm cancels it. That cancellation satisfies the sentinel’s dependency, so a sentinel left in the queue would start and exit at once. A job whose driver finishes the run therefore ends the chain itself: after the driver step it cancels its queued sentinel and successor and journals both, with their job IDs and the scancel result, in chain-end-journal.jsonl, so no allocation starts for a finished run. A stop the chain recorded earlier (a refused follow-up, unknown accounting, the walltime cap) no longer applies once a segment completes the run: that segment removes .gym_chain_incomplete, logs the stop it supersedes and journals run_complete_stop_superseded. A complete run whose required MLflow export has no current receipt ends as run_complete_export_receipt_missing instead, and the marker says so. A job whose driver exits 76 (nothing is eligible for another attempt) ends its chain the same way, unless its driver left one of the failure kinds the next job’s guard stops on (see below): it writes the no_eligible_retry stop to .gym_chain_incomplete, cancels its sentinel and successor, and journals the end. The ended field of each journal line is run_complete, run_complete_stop_superseded, run_complete_export_receipt_missing or no_eligible_retry. In a job.sh rendered before that, or when the journal reports scancel_failed, cancel the sentinel yourself (its ID is in .gym_followup_sentinel.<job ID>).

What the next job does with the previous job’s state:

Previous job stateNext job
none (the first job)Starts.
state not yet visible to sacctRetries the lookup for about a minute, then stops if accounting is still unavailable.
COMPLETEDExits successfully.
CANCELLED...Stops the chain.
TIMEOUTContinues the planned allocation segments within the remaining max_walltime. A segment that ended before the task inventory was written stops the chain: nothing can be resumed, and the stop names the fresh-restart command. This scheduler state does not classify a model response timeout.
PREEMPTED, NODE_FAIL, BOOT_FAILResumes only with remaining retry and walltime budgets; records one admitted retry before work.
FAILED, OUT_OF_MEMORY, DEADLINEPreserves known elapsed time and stops. These states alone do not establish a retryable infrastructure cause. A driver that failed with server_spinup_timeout, driver_install_failed, collection_resume_refused or provider_credentials_rejected stops the chain at once, before saved state is read, and the stop names that kind and its remedy. A driver that failed with server_start_failed (for example a port already in use) in a FAILED job, before the run saved any rollout, is restarted fresh once, as one infrastructure retry; a second such failure, or a spent retry budget, stops with fresh restart exhausted and the fresh resubmit command. Agentic IF Realworld can resume a failed allocation that recorded a deferred judge request and saved its inventory. The follow-up spends one infrastructure retry and validates the journal before dispatch.
unknown, malformed or nonterminal accountingStops without dispatching more work.

Preemption and node failure count against max_retries; max_retries: 0 admits no retry after either. Scheduler allocation timeouts retain the planned-segment behavior, bounded by max_walltime. Unknown elapsed time cannot grant a fresh allowance. A generic FAILED state can represent invalid configuration or an application failure; the chain never classifies it as infrastructure failure from its exit code or log text. Saved-evidence recovery remains subject to the checks below.

What gets resumed

Submit adds resume_from_cache: true to the benchmark’s run overrides unless you set it yourself. On the first job there is no cache and it starts fresh; on later jobs gym eval run reuses what was already collected. All jobs of a chain share one benchmark directory, so rollouts accumulate in the same artifacts/ files, and each job’s logs are kept separately because their file names include the Slurm job ID.

The prologue keeps its state in dot-files in the benchmark directory:

FileContents
.gym_job_chainThe Slurm job ID of every job in the chain, one per line.
.gym_accumulated_walltimeSeconds of walltime consumed by finished jobs. Compared with max_walltime.
.gym_infra_retriesCount of infrastructure retries so far.
.gym_infra_retry_extensionInfrastructure retries added to the configured cap, written only by gym eval resubmit --recover --extend-retries.
.gym_followup_queued.<job ID>The observed successor job ID, or an unresolved submission claim. An unresolved claim cannot authorize another submission.
.gym_followup_sentinel.<job ID>The job ID of the sentinel queued for that job’s successor.
.gym_driver_failure.<job ID>The failure kind that job’s driver left when it failed in a way the next job would repeat.
.gym_fresh_restart.<job ID>Written by a job that restarted the run fresh after server_start_failed; the next job does not restart it again.
.gym_chain_incompleteWhy the chain stopped before the run finished (the stopping job also logs how many rollouts are open, from the coverage report’s open count): no eligible retries, the walltime cap, a cancel, a typed driver failure, a refused follow-up submission (follow_up_submission_refused), unknown accounting, or a complete run without its required export receipt. A chain that continues removes it, and so does a segment that completes the run.

job-allocations.jsonl records the Slurm allocations of the run for GPU-hour accounting: one JSON line per allocation incarnation of every job of the run (segments, successors and sentinels, each requeue separately), from sacct. Each job appends every incarnation that has ended and has no line yet, once it has queued its successor; a job that ends with nothing after it to record it (a stop, a complete run, an idle sentinel, the segment that ends the chain) also appends its own, as of its exit, with "ended": false. A line has job_id, restarts (the incarnation), state, start_epoch_s and end_epoch_s (Unix seconds, null when the job never started or has not ended), elapsed_s, nodes, node_list, alloc_tres, gpus (the gres/gpu count of alloc_tres, null when absent), ended, recorded_at and source (sacct). Take the GPU-hours of an incarnation as gpus * elapsed_s / 3600, from its "ended": true line when there is one. Recording is best-effort: its sacct queries end within 30 seconds, and when sacct does not answer nothing is written for that job and a later job adds it; an incarnation that no later job saw has no line.

Recover from saved evidence

For a submitted Slurm benchmark, recovery reads the existing materialized inventory, results, failure sidecar, quality report, scheduler state and retry/time counters before choosing an action. It requires the saved resumable configuration and a job script that supports budget-preserving recovery.

For managed rollouts on a remote host, recovery uses the saved driver.gym_install repository and immutable commit to run the authoritative Store reader over SSH. The temporary installation and read are bounded by a size-aware limit (see NEMO_GYM_REMOTE_READER_TIMEOUT_S below), with one retry at twice the bound after a timeout or a failed SSH hop; recovery checks the imported source, exact job directory, stable artifact snapshots and saved submission configuration. An unavailable runtime, an unpinned ref, or an older pinned version without the reader stops recovery. It does not silently upgrade the saved version or copy saved answers to the caller.

Use the submission ID printed by gym eval submit and the benchmark name. Select an aggregate entry by its saved agent_ref.name and, where needed, _ng_environment_server; its position in the aggregate array is not an identity.

gym eval resubmit "$GYM_JOB_ID" gpqa --recover \
--score-agent simple_agent \
--score-key '["agent_metrics", "mean/reward"]' \
--max-unhealthy-fraction 0.02

Replace simple_agent with the name in that run’s aggregate entry. Add --score-environment NAME when the agent has several environment entries. Missing or ambiguous identities and nonfinite scores leave the score unavailable; a genuine score of zero is retained. Legacy aggregate objects can still use a string-key metric path without an identity selector.

The JSON response separates dispatch from acceptance:

Field or statusMeaning
okThe requested recovery operation was supported and completed. A successful NOOP does not certify the evaluation.
dispatchedThe action actually taken; null means no job or re-verification was dispatched.
gate_task.status = RUNNINGA job for the run is already live; recovery does not queue a duplicate.
PLANNED--inspect found eligible work or supported saved-answer re-verification and dispatched nothing; warnings says PLANNED (NOT DISPATCHED).
RESUMINGEligible work was submitted or supported saved-answer re-verification was dispatched. Only a dispatch reports it.
FAILEDRecovery stopped, the action is unsupported, or required acceptance evidence is missing or failed. Read errors and unsupported.
SUCCESSRequires complete results and every acceptance gate. Trial health can pass only when supported, source-bound operation and grading observations cover every expected identity; completion alone is insufficient.

Completed answers, ordinary incorrect answers and supported final model zeros are not regenerated. Judge-only failures request re-verification of saved answers: on Slurm, a submission that deploys no model service re-judges in place within its remaining allowance, and a run that served its own model gets a judge-only job on a CPU partition (the saved config’s CPU pool, or --judge-partition; without a CPU partition the refusal names the option). The judge-only job prepares the benchmark data first, as the run did, because a resources server can read a prepared file when it starts. A run containing both judge failures and missing or retryable policy work is resubmitted; the resumed run re-judges the saved judge failures before its policy work, while its judge servers are up, and again at the end of the run.

Where the remote readers run

On a Slurm run, gym eval resubmit --recover (and --inspect) reads the saved run on the login host with two readers: the collector, and the managed Store reader. NEMO_GYM_REMOTE_READER_TIMEOUT_S bounds the Store reader (clamped to 300-14400 s; by default the bound grows with the size of the rollout files). A login host may allow each user one core, so both readers can run in a Slurm step instead:

  • NEMO_GYM_REMOTE_READER_SRUN: extra srun arguments for the step, for example -p cpu -c 4 --mem=16G. When it is unset, the readers run on the login host exactly as before. Gym adds --ntasks=1, a time limit of the reader bound plus 60 s, and the job name gym-reader-<GYM_READER_TOKEN>. If the recovery process or its SSH connection ends while the Store reader runs in a step, Gym cancels the step by name.
  • NEMO_GYM_REMOTE_READER_SRUN_WAIT_S (default 120): a step that has not started by then is cancelled by name, at most 60 s is spent waiting for it to leave the queue, and the reader then takes the fallback below. If the cancelled step is not confirmed gone, no second reader is started on the login host.
  • NEMO_GYM_REMOTE_READER_MAX (default 8): when the user already has this many gym-reader-* steps running or pending, the reader queues instead: it counts them again every 10 s for up to NEMO_GYM_REMOTE_READER_QUEUE_WAIT_S seconds (default 600; 0 does not wait) and runs in its step once one ends, printing gym-reader progress: queued behind N reader steps. A cap still reached after that wait, or a failing squeue, takes the fallback below.
  • NEMO_GYM_REMOTE_READER_LOGIN_FALLBACK (default forbid; allow permits it): whether a reader that cannot run in its step may read on the login host instead. Forbidden, the read does not run and nothing is read or decided from the login host; stderr says gym: the reader did not run: ....

When a reader ran on a remote host, the gate task reports reader_host and collector_host (login, cpu:<job id>, none when the reader did not run, or unconfirmed when a cancelled step was not confirmed gone), and reader_fallback_reason and collector_fallback_reason when a reader stayed on the login host or did not run.

The optional unhealthy fraction is a per-rollout criterion for the existing quality report. It is not a response or trial denominator. Response failures are reported by cause and rate under failures and never fail the gate. Evaluation health, the trial gate, rejects at 2% from its known-failure lower bound. Below that threshold, it can pass when source-bound agent, model-attempt, supported client-executed function-tool, and verifier observations join across every expected identity and repeat. The verifier must record an actually executed programmatic grading calculation bound to the saved response and reward. Unjoined recovered failures, unsupported hosted or custom tools, unobserved judge dependencies, sandbox lifecycle gaps, and historical records without grading observations remain unknown; a low failure count alone does not certify them. Missing report-source identity, unsupported multi-source summaries, malformed counters or missing runtime facts remain unknown.

Unobserved trials

Acceptance reports its trials in three counts, in gate_task.trial_counts: observed_healthy, unhealthy (the known failures the trial gate counts) and unobserved. A scored trial is unobserved when its verifier recorded no grading operation for it, for example a benchmark whose resources server does not record its grading. Nothing observed how such a trial was graded, so it is unverified: it counts neither as healthy nor as a failure, and the trial gate stays unknown. unobserved_reason names the resources servers, and the trial reason reads trial: UNOBSERVED <n> of <N> expected trials: ..., so the run is unverified, not healthy. A run in which every trial is unobserved is never healthy; its gate status is UNVERIFIED, with that reason, even at full score and coverage.

Only supply --mlflow-run-id ID --mlflow-status FINISHED after observing that exact backend run and status. Those flags do not perform an export. Acceptance also requires a current content-bound receipt recording rollout delivery. The postrun exporter writes this receipt. A fresh live MLflow activation can also write it for the same run after final collection and health artifacts are stable, acknowledged rollout/config/metric delivery matches those artifacts, and the backend confirms completion. Resumed activations and incomplete delivery remain unverified; legacy run-ID-only markers do not satisfy this check. A successful recovery invocation is therefore separate from confirmed tracking delivery.

Rollout export projection version 1 retains the canonical ng_trajectory identities, invocation and verifier outcomes, model/tool joins, timing, failure evidence, and observation gaps. It omits invocation conversations, turn question/answer/reasoning payloads, raw model requests/responses, and tool outputs. Omitted payloads remain unavailable; the projection does not by itself establish response health or saved-answer reverification. Delivery receipts include rollout_projection_version: 1 and bind the acknowledged projection to the saved artifacts. Older receipts without this field do not verify canonical evidence delivery and are not overwritten or automatically re-exported.

Automatic recovery preserves spent history and rollout attempts, and a recovery allocation consumes one remaining retry when it starts. The first allocation end of a rollout that was in flight is free; from the second end on, each one charges the affected rows one attempt (rollout_allocation_ended, retried under the attempt cap). For a capped run, every recorded allocation must have terminal scheduler accounting, consistent with the stored budget epoch. The last allocation’s elapsed time is preserved before scheduling. Automatic resubmit rechecks the collected chain, counters, reset offset, saved configuration and follow-up claims under its existing submission lock before changing files or submitting. If any changed, it refuses and requires fresh evidence. Before starting services, the generated prologue limits the current Slurm allocation to the remaining walltime and verifies the scheduler readback. It only decreases the existing limit and rounds the remaining allowance down to whole minutes; less than one minute, failed updates or unknown accounting stop the job. Slurm enforces the time limit with the cluster’s normal termination grace. A Slurm requeue of the same job ID stops before work or counter resets: these counters cannot establish the elapsed time of the prior incarnation. Recover only when complete terminal accounting is available.

A run that ended before its task inventory was written has nothing to recover, and recovery answers fresh-restart: resubmit it as a fresh run with a longer walltime. Without --max-walltime, the reason says that it is required and names the command, gym eval resubmit <GYM_JOB_ID> <BENCHMARK> --recover --max-walltime HH:MM:SS --walltime-reason TEXT. With a --max-walltime longer than the recorded walltime, recovery queues the run as a fresh run with fresh retry and walltime budgets, records plan: FRESH-RESTART, why and both walltimes in walltime-extension-journal.jsonl, writes the same facts to .gym_chain_incomplete until the queued job continues the chain, and leaves the saved artifacts as they are. While a job of the run is live, recovery answers NOOP and queues nothing.

Every recovery option, including the journaled budget extensions (--extend-retries, --extend-attempts, --max-walltime, --server-spinup-timeout-seconds), the pin options (--repin, --no-auto-repin) and the explicit opt-ins for masked rows without a gradeable artifact and for failed judge-only jobs, is listed under gym eval resubmit.

Without --recover, ordinary gym eval resubmit keeps its existing explicit-reset behavior: it starts a fresh retry/time and per-rollout attempt allowance. Do not use it as an automatic substitute for a recovery STOP.

Limits and caveats

  • max_walltime applies to all continuation paths, including --recover. A capped job needs permission to read and decrease its own Slurm time limit with scontrol; failure stops before services or another successor start. Existing job scripts are not silently rewritten: stage the new generated prologue to obtain these guards.
  • If the scheduler refuses the successor outright (sbatch names an invalid request, a violated policy or limit such as a QOS cap on submitted jobs, or an unavailable resource or dependency), nothing was queued and the accounting is known: the job writes follow_up_submission_refused: sbatch exited <code>: <error lines> to .gym_chain_incomplete, carries on, and its log line says to continue with gym eval resubmit --recover once the scheduler accepts the job.
  • If queueing a successor fails in any other way, the job prints a warning (Failed to submit auto-resume follow-up) and carries on. sbatch can fail after it created the job, so check with squeue --me --all. A missing queue entry does not prove that a successor never ran. Automatic continuation remains stopped until the complete queue and terminal accounting are reconciled, including guard-stopped allocations. Requeueing does not repair unknown accounting or reset its stop state.
  • A job that finds its predecessor CANCELLED stops the chain. Because each job queues its successor before doing work, a successor may already be waiting in the queue when you cancel; check squeue --me --all and cancel any job still pending: the IDs of a job’s successor and its sentinel are in .gym_followup_queued.<job ID> and .gym_followup_sentinel.<job ID>, and .gym_job_chain lists the jobs that have run.
  • An empty sacct reply for the previous job is retried: the job asks up to 6 times, 10 seconds apart, and then stops the chain with accounting unknown instead of resuming, so a scheduler whose accounting lags by about a minute stops chains. The stop’s log line names the continuation, gym eval resubmit <GYM_JOB_ID> <BENCHMARK> --recover --max-walltime HH:MM:SS --walltime-reason TEXT, adding --extend-retries N when the retries are spent, and gym eval resubmit --recover --inspect reports it too; the .gym_chain_incomplete marker keeps the bare reason.
  • resumable does not work with a benchmark command, because resuming relies on gym eval run’s cache.
  • The gym-job.json record contains the first job’s ID only.

Recovery uses the shared outcome policy for eligible failures. The Python recover(..., outcome_policy=RecoveryOutcomePolicyConfig(...)) API accepts partial HTTP-status, failure-kind and failure-class action overrides, in that priority order before the default action. retry permits another episode only within the saved attempt and chain budgets; verify re-verifies a saved judge answer, and fail leaves it ungraded. Settled results and terminal failures are never reopened. Mixed decisions stop when the executor cannot honor them separately. Saved-answer re-verification still requires an executor that supports it. A benchmark config sets the same policy under its resumable mapping as recovery_outcome_policy (by_failure_kind, by_status_code, by_failure_class, default_action; unnamed entries keep their defaults; a mistake fails at config load as invalid recovery_outcome_policy: <field>: <problem>). The run saves it in resolved-config.yaml, its continuations use it, and a change between inspection and dispatch refuses the resubmit. An explicit Python outcome_policy replaces the config section as a whole; there is no CLI flag. The inspection reports the policy in force as outcome_policy with its source (default, config or python). The policy decides what is retriable. Its classification subsection supplies the shared rules used by recovery, the health gate and health metrics. Action overrides do not change a failure’s class. A class already saved with a result remains authoritative.

--max-response-failure-fraction and --max-trial-failure-fraction are validated and reported under criteria with applied: false; they do not change the verdict. The gate’s only health verdict is evaluation health, at the fixed limit of a strict fraction below 0.02, before rounding, which criteria.evaluation reports; response and trial failures are reported by cause under failures. The shared FailureClass mapping in nemo_gym/core/failure_kinds.py assigns model, evaluation (including infrastructure), or unknown; a policy-model response timeout is the model’s fault by default, and --policy-timeout-counts-as-model false (policy_timeout_counts_as_model, reported under criteria.evaluation) counts it as a server fault for a self-hosted evaluation. None of this changes rewards or retry policy. A trial failure classified as unknown makes the gate UNVERIFIED. The report keeps these failures in its unknown bucket; server_kinds identifies the server subcategory within evaluation failures. A positive trial result requires observed coverage of every expected identity. Supported paths join invocation, selected response, model operations, client-executed function-tool results, and observed programmatic grading bound to the saved result. Unsupported paths, missing grading or runtime observations, and unjoined recovered failures remain unknown. Recovery NOOP is separate from acceptance and tracking delivery.

The live and post-run tracking paths export the same saved-evidence health snapshot under health/response, health/trial, and separate model/grading recovery namespaces. Always check the current known metric before interpreting a passed value or rate: known=0 means unknown and resets passed=0 (not passed, not a classified failure); older count and rate values remain historical. Trial counts_known=0 labels a known failure from a lower bound; its failed_lower_bound and failure_rate_lower_bound are not exact counts. These facts do not certify tracking delivery or replace the gate’s evaluation health verdict.

health/trial/unclassified counts trial failures whose class is unknown. It is separate from missing coverage: either can prevent a health verdict, but a recovered failure beside a complete result is not itself an unclassified trial.

These exported health flags use the fixed strict 2% limit; no recovery command applies a custom threshold. Upstream recovery includes observed model HTTP operations, including judge calls; grading recovery is a separate joined projection. These counters overlap and must not be summed.