Skip to content

feat(orchestration): add gym eval resubmit for in-place Slurm resubmits - #4766

Merged
AdamRajfer merged 8 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:feat/eval-resubmit
Oct 21, 2026
Merged

AdamRajfer merged 8 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:feat/eval-resubmit

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Resubmitting a failed Slurm run in place meant running sbatch on its job.sh by hand and keeping the job chain up to date.

Changes:

  • New gym eval resubmit GYM_JOB_ID BENCHMARK. It queues one benchmark of an earlier submission again, in place, and prints the new job id.
    • GYM_JOB_ID is the submission's id as gym eval submit reports it: the last part of its run directory, and gym_job_id in --json.
    • The command finds the record in this machine's job index, or in the run's manifest when the run directory is local. It updates both with the new job id.
    • It refuses while a job of that benchmark is still active.
    • It sends the same forwarded environment and telemetry token as the original submit.
  • resubmit(record, benchmark) -> BenchmarkJob is an executor operation. Executors that cannot resubmit raise UnsupportedOperationError; today that is Kubernetes.
  • The resubmitted job resumes from its cached rollouts and starts a fresh auto-resume retry count. Every failed rollout that is not final gets a fresh attempt budget.
    • Rollout collection owns that budget's offset file, <stem>_resubmit_offset. The failures sidecar itself is not changed.
    • Without this, a failure that outlasted the cap, such as a judge outage, stayed a zero for good.
gym eval resubmit <gym_job_id> <benchmark>

Tested with unit tests, using fake sbatch and squeue where needed, for:

  • the resubmit command and the executor contract;
  • the record update and the forwarded environment;
  • the attempt budget after a resubmit;
  • rollout collection, reverification and GDPval's multistage resume;
  • the resume script and the Slurm executor.

🤖 Generated with Claude Code

Resubmitting a failed Slurm run in place meant running sbatch on its
job.sh by hand and keeping the job chain up to date. `gym eval resubmit
JOB_DIR` queues the benchmark's own job.sh again from its job dir, so
the same config resumes into the same run, and prints the new job id.
It refuses while one of the caller's jobs still runs in that job dir,
so two jobs never write one run.

A resubmit gives every failed rollout that is not final a fresh attempt
budget. It records the failures sidecar's line count in
<stem>_resubmit_offset next to it, and the attempt cap counts only
sidecar lines from that offset on; the sidecar itself is not changed.
Without this, a failure that outlasted the cap, such as a judge outage,
stayed a zero for good. The resubmit also resets the auto-resume retry
count, and the job id appears once in .gym_job_chain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer self-assigned this Oct 19, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 19, 2026 21:12
@yaoyu-33 yaoyu-33 added area:orchestration Job submission, deployment, services, and lifecycle management complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 19, 2026
@prokotg

prokotg commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

/review

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

HOLD — 1 BLOCKER and 5 RISK findings.

The default cache-disabled job can lose its existing rollout evidence when resubmitted. Additional issues affect concurrent resubmissions, GDPVal attempt budgets, offset cleanup, remote telemetry credentials, and preparation-error handling.

Reviewed all eight changed files and their directly affected execution/cache paths. Validation was static only: tests and suggested patches were not executed. Proposed corrections require author verification.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex

Comment thread nemo_gym/rollout_collection.py Resolved
Comment thread nemo_gym/rollout_collection.py Resolved
…rent and telemetry runs

Address the review of gym eval resubmit:

- A resubmitted job.sh now adds ++resume_from_cache=True once the
  resubmit offset exists, so a run configured without cache resume
  keeps its landed rollouts instead of clearing them as a fresh run.
  A job.sh staged before this change that would start fresh is refused
  when the run already has rollouts.
- The scheduler check, the offset and retry resets and sbatch run as
  one remote script under a mkdir lock in the job dir, so two
  resubmits cannot both queue a job.
- Every preparation step fails the script before sbatch: a resubmit
  whose offset cannot be written queues nothing and says why.
- The resubmit exports the telemetry token named by the saved
  resolved config, as the first submit does, and fails before queueing
  when that token is not set.
- A genuinely fresh run removes a stale resubmit offset with the old
  failures sidecar.
- GDPVal's stage-aware resume gates and caps on attempts made since
  the offset, and keeps cumulative counts for attempt identities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

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

Review focused on the executor interface, since the job-management API is still in design.

Proposed BaseExecutor.resubmit (executors/base.py)

A SubmissionRecord describes a whole submission and holds one BenchmarkJob per benchmark (record.benchmarks). The run-level fields (run_dir, hostname, cluster, executor_metadata) are shared, and job_dir and job_id are per benchmark. So the call has to say which benchmark to resubmit. Two reasonable signatures, neither Slurm-specific:

Option 1: address the benchmark by name

@abstractmethod
def resubmit(self, record: SubmissionRecord, benchmark: str) -> BenchmarkJob:
    """Queue `benchmark` of a submitted run again, in place, and return it with its new job id.

    Same config, same run: nothing is re-staged and finished work is kept. Must refuse while a
    job of this benchmark is still active. Executors with no equivalent raise
    `UnsupportedOperationError`.
    """

The caller can't pass a benchmark that doesn't belong to the record, since the executor resolves the BenchmarkJob from record.benchmarks itself. It matches how a user would address the job (gym job id plus benchmark name), so the CLI doesn't have to depend on executor-specific paths.

Option 2: pass the BenchmarkJob

@abstractmethod
def resubmit(self, record: SubmissionRecord, benchmark: BenchmarkJob) -> BenchmarkJob:
    """Same contract as above; `benchmark` must be one of `record.benchmarks`."""

The executor gets job_dir and the previous job_id without a lookup. The cost is that the signature allows a mismatched (record, benchmark) pair, so the contract has to state that benchmark belongs to record, and the executor should check it.

I lean toward option 1. Either way, the return value should be the updated BenchmarkJob and not a bare job id (see inline comment on slurm.py). Any future job-lifecycle operation (kill, status, etc.) should follow the same (record, benchmark) shape, so the CLI stays independent of the backend. Those are out of scope for this PR; this is only the pattern to keep them consistent with.

KubernetesExecutor (executors/kubernetes.py)

With resubmit abstract, KubernetesExecutor must now define it. Please add an explicit implementation that raises UnsupportedOperationError("Kubernetes executor does not support resubmit") and a test for it. That test is the one place we assert which executors support the operation.

Inline comments cover the dispatcher in submit.py, record lookup placement, the CLI handle, the return value, and the responsibilities inside SlurmExecutor.resubmit.

Comment thread nemo_gym/orchestration/submit.py Resolved
Comment thread nemo_gym/orchestration/submit.py Resolved
Comment thread nemo_gym/cli/main.py Resolved

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

Thank you! The following things are blocking, let me know if I misunderstood something:

  1. Resubmit is not part of the executor contract. submit.resubmit() hard-codes "slurm" and instantiates SlurmExecutor directly, bypassing _EXECUTORS. It should be an @AbstractMethod on BaseExecutor, dispatched through the registry, so support is declared by the executors themselves. This needs a signature decision, (record, benchmark: str) or (record, BenchmarkJob). KubernetesExecutor must also implement it and raise explicitly.
  2. The submission record isn't updated after a resubmit. resubmit returns a bare job id and only appends to .gym_job_chain. BenchmarkJob.job_id in gym-job.json and the local index still point at the old job. The method should return the updated BenchmarkJob and persist it.
  3. The CLI handle is Slurm-shaped. JOB_DIR is a filesystem path, and the lookup matches on it. While the job-management API is in design, the identifier should be executor-neutral (gym_job_id plus a benchmark name). Record lookup should also move out of submit.py into jobs.py.
  4. SlurmExecutor.resubmit owns responsibilities that aren't its own. It writes the rollout-collection attempt-budget offset with inline bash (wc -l), with the file format shared implicitly with rollout_collection. Run-state reset should live in one component outside the Slurm transport. In this PR "resubmit" should mean "queue the job again".
  5. Resubmit doesn't repeat what submit did. It drops compute.forward_env and re-parses resolved-config.yaml as raw YAML for the OTEL token. A resubmitted job can start with a different environment than the original submit.

AdamRajfer and others added 3 commits October 21, 2026 14:56
…ates the record

Address review of gym eval resubmit (executor contract, record, CLI handle):

- resubmit is now an abstract BaseExecutor method,
  resubmit(record, benchmark) -> BenchmarkJob, dispatched on the
  record's executor name. KubernetesExecutor raises
  UnsupportedOperationError.
- The Slurm executor returns the benchmark's updated entry and
  persists the record to gym-job.json and the local index through
  persist_record, the store persist() writes. It no longer appends to
  .gym_job_chain, which only the job script's own prologue writes.
- The CLI takes `gym eval resubmit GYM_JOB_ID BENCHMARK`. The record
  lookup moves to jobs.load_submission_record: the local index, then
  the run's manifest when its run dir is on this machine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Address review of gym eval resubmit (who resets run state, and
repeating what submit does):

- SlurmExecutor.resubmit only queues the job again: under its lock it
  checks that no job of the run is active, then runs sbatch with
  GYM_RESUBMIT=1. It no longer writes the attempt-budget offset or
  removes the retry file with inline shell.
- The job does the reset when it starts. The auto-resume prologue
  clears its retry count and unsets the variable, so later chain hops
  are ordinary. The run step adds ++resubmit=True to gym eval run.
- Rollout collection owns the offset file: resubmit=True implies
  resume_from_cache, and record_resubmit_offset() writes the offset
  atomically next to load_resubmit_offset(). The GDPval multistage
  resume uses the same function.
- A run with rollouts whose job.sh predates this handling is refused,
  since that job.sh could start fresh and delete them.
- The resubmit loads the saved resolved-config.yaml as a SubmitConfig
  and sends what run() sends ahead of sbatch: compute.forward_env and,
  when telemetry is on, the token from resolve_token(). A missing value
  fails before anything is queued.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 21, 2026 13:03
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

@prokotg Thanks for the review. All five blocking points are fixed, in two commits on top of a merge of main (needed for compute.forward_env):

  • c920196: resubmit is an executor operation that returns and persists the updated BenchmarkJob. The CLI takes GYM_JOB_ID BENCHMARK, and the record lookup lives in jobs.py.
  • 4caab98: the job resets its own run state, and resubmit sends what submit sends.

Each point has a test that fails without it. Replies are on each thread.

prokotg
prokotg previously approved these changes Oct 21, 2026
… records in one place

The guard that refuses a populated run whose job.sh predates resubmit now
applies only to a job.sh that runs the built-in `gym eval run`, the only
runner whose fresh start deletes rollouts. A `command` benchmark's job.sh
runs its own command and never carries the resubmit flag, so it was
refused even when current.

persist() and persist_record() now share one store path, so the local
index first, then the run dir, and the failure message naming the queued
jobs live in one place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Resolve the GDPval attempt count: keep counting only attempts after the
resubmit offset, and keep main's reverifiable failure classes out of the
terminal set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Resolve the two rendered-script fixtures: the resubmit line now comes
before the driver watch that main gained in NVIDIA-NeMo#4785.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

@prokotg Thanks for the review! Both points are in d96b06e.

  • Resubmit guard: it now applies only to a job.sh that runs the built-in gym eval run, the only runner whose fresh start deletes rollouts. The guard matches gym eval run as a line of its own, the way render_gym_cmd writes it, so a job.sh from before resubmit is still refused. A command benchmark with rollouts is now queued: test_resubmit_queues_a_populated_command_benchmark renders a real command-benchmark job.sh, and it fails on the previous guard.
  • One store path: persist() and persist_record() now share BaseExecutor._store, following your sketch. It writes the local index first, then the resolved config (on submit) and the manifest, and raises one error that names the queued jobs. test_a_failed_record_update_names_the_queued_jobs covers the resubmit side.

I also merged main twice to resolve the conflicts:

@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/39619980006

Merged via the queue into NVIDIA-NeMo:main with commit 69c2ff3 Oct 21, 2026
50 of 56 checks passed
@AdamRajfer
AdamRajfer deleted the feat/eval-resubmit branch October 21, 2026 15:08
copy-pr-bot Bot pushed a commit that referenced this pull request Oct 22, 2026
Main's #4766 changed the auto-resume block of resume_script.py. The one conflict is resolved by keeping main's job-chain file name and adding this branch's one-follow-up-per-job marker after it. The requeue tests pass on main's script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 03debe11 Deployed Oct 21, 2026 by copy-pr-bot[bot] via release / finalize / notify #6265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orchestration Job submission, deployment, services, and lifecycle management complexity:high Cross-component or shared-contract change with a large review surface 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.

4 participants