Skip to content

fix(orchestration): uv on PATH, one resume follow-up per job, resubmit round trip, failed chain stops - #4840

Merged
AdamRajfer merged 10 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/uv-env-path
Oct 23, 2026
Merged

AdamRajfer merged 10 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/uv-env-path

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

The uv installer does not write $HOME/.local/bin/env when $HOME/.local/bin is already on PATH. The driver preamble then fails on source "$HOME/.local/bin/env", and set -e aborts the job although uv was installed.

The env file only prepends $HOME/.local/bin to PATH, so the preamble now does export PATH="$HOME/.local/bin:$PATH" directly.

Tests: test_render_driver_entrypoint_puts_uv_on_path_without_env_file checks that the rendered script no longer references .local/bin/env and puts $HOME/.local/bin on PATH after the uv install and before uv venv. It fails on the previous code.

Also: one auto-resume follow-up per Slurm job. The auto-resume part of the job script queues its follow-up with sbatch --dependency=afternotok:$SLURM_JOB_ID. A Slurm requeue keeps the job id and runs the script again, so it queued a second follow-up, and both started on the same run directory when the job ended. The script now creates a marker directory .gym_followup_queued.$SLURM_JOB_ID with mkdir, which is atomic, before it calls sbatch. A requeued job finds the marker and queues nothing. A new segment has a new job id and still gets its follow-up. If sbatch fails, the marker is removed, so a later requeue can try again. This is the same job script and the same reviewer as the change above.

Tests: test_a_requeued_job_does_not_queue_a_second_follow_up (a first segment and a resumed segment), test_each_resumed_segment_still_queues_its_own_follow_up and test_a_requeue_retries_a_follow_up_that_failed_to_submit. They run the rendered script in bash with fake sacct and sbatch. All but the retry test fail on the previous code.

Also: gym eval resubmit loads the config that gym eval submit saved. Resubmit refused every saved config with a lit: env value or a driver.policy_model, so nothing was queued.

  • persist() put host: values back as references but wrote literals without their prefix. It now writes lit: back. host: values stay references, so no resolved secret reaches the record.
  • _saved_config loads with a saved-config context, so a file saved before this fix, with bare literals, still loads.
  • The driver.policy_model validator wrote policy_base_url, policy_model_name and policy_api_key into benchmark.run at submit. Re-validation of the saved file then refused them as set twice. Values that equal what driver.policy_model derives are now accepted when loading a saved config. A differing saved key, or hand-written policy keys, still conflict.
  • A command benchmark gets the same three keys in its run and reads them as NEMO_GYM_POLICY_*, so its saved config holds a command with a run, which the benchmark check refused. On a saved config, a command may now keep exactly the keys derived from a model service, and the equality check above compares their values. A hand-written command with a run, or a saved one with any other run key or without a model policy, is still refused.

Tests in tests/unit_tests/test_eval_resubmit.py:

  • test_the_config_submit_saves_loads_back_as_resubmit_loads_it, through the real SlurmExecutor().persist and _saved_config;
  • test_resubmit_queues_a_run_submitted_with_lit_env_and_a_policy_model, gym eval resubmit against stub squeue and sbatch;
  • test_a_config_saved_with_bare_literals_still_loads;
  • test_a_run_with_a_policy_model_and_no_env_loads_back;
  • test_a_saved_command_benchmark_with_a_policy_model_loads_back_and_resubmits.

Each fails on the previous code. The refusals keep their own tests: a saved command with a differing policy value, with an extra run key, or without a policy model, and a hand-written command with a run.

Also: a chain that stops with rollouts missing fails. When the auto-resume chain stops at the max_walltime cap, or after a cancel, the job used to exit 0, so the run read as done. It now exits non-zero, with a message to resubmit, and writes .gym_chain_incomplete next to the run. A chain that continues clears the marker; a chain that finished still exits 0. Tests: test_a_chain_stopped_at_the_walltime_cap_exits_non_zero_and_marks_the_run_incomplete, test_a_chain_stopped_after_a_cancel_exits_non_zero_and_marks_the_run_incomplete and test_a_chain_that_continues_clears_an_earlier_incomplete_marker. A resubmit gives the chain a fresh walltime budget, as it already gives a fresh retry count, so "resubmit to continue" gets past the cap: test_a_resubmitted_job_starts_a_fresh_walltime_budget.

This branch now contains main, merged in, because main's gym eval resubmit changed the same files.

🤖 Generated with Claude Code

The uv installer does not write $HOME/.local/bin/env when that directory is
already on PATH, so the driver preamble's source failed and set -e aborted the
job although uv was installed. The env file only prepends $HOME/.local/bin to
PATH, so the preamble now exports it directly. A new unit test checks the
rendered script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer self-assigned this Oct 21, 2026
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test ce28343

@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working labels Oct 21, 2026
@AdamRajfer
AdamRajfer marked this pull request as ready for review October 21, 2026 15:01
@AdamRajfer
AdamRajfer requested a review from prokotg October 21, 2026 15:01
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 21, 2026

@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

LGTM — no reliability concerns.

The driver preamble now puts uv on PATH without depending on the optional env file, while preserving fail-fast setup and virtual-environment activation. The regression test checks removal of that dependency and ordering before virtual-environment creation.

Inspected both changed files and traced the shared Slurm and Kubernetes callers. No actionable findings. Static review only; tests were not executed.

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

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

When Slurm requeues a job (a node failure, or preemption with
--requeue), the job keeps its job id and runs job.sh again. The
auto-resume prologue then queued a second follow-up with the same
afternotok dependency, so two resume jobs started on one run directory
when the job ended, and they could duplicate or corrupt rows.

The prologue now takes a marker named after the job id, with an atomic
mkdir, before it queues the follow-up. A requeued run of the same job
finds the marker and queues nothing. A new segment of the chain has a
new job id, so it still queues its own follow-up. If sbatch fails, the
prologue removes the marker, so a requeue of that job can try again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Main's NVIDIA-NeMo#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]>
AdamRajfer and others added 2 commits October 22, 2026 03:57
gym eval resubmit validates the resolved config that submit persisted,
and it refused that config in two ways:

- persist() wrote host: env values back as references but dropped the
  lit: prefix, so each literal failed the env check.
- driver.policy_model writes policy_base_url, policy_model_name and
  policy_api_key into each benchmark's run at submit. persist() saves
  them, and the validator then refused them as set by hand.

The dump now writes lit: back on every literal; host: values stay
references and runtime: values keep their own prefix, so no resolved
secret reaches the record. _saved_config validates with a new
saved_config context. In that context a bare env value reads as lit:,
so configs saved before this change still load. That is safe because
the earlier dump wrote only host: references, runtime: values and bare
literals. The same context accepts a policy key that equals the value
driver.policy_model derives. A differing value still conflicts, and a
config written by hand is checked as before.

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

When the chain stopped because it reached max_walltime, or because the
previous job was cancelled, the job exited 0. sacct then showed the
last job COMPLETED, and readers took the run as done although rollouts
were missing.

The chain only takes these two stops after a job that did not finish
the run: a job that finishes it COMPLETEs, and its follow-up never
starts. So both stops now exit 1 with a message that says rollouts are
missing and that a resubmit continues the run. The prologue cannot
count rollouts itself (the expected total is only known to rollout
collection), so it also writes .gym_chain_incomplete in the job dir
with the reason. A job that continues the chain removes that marker.
A chain whose previous job COMPLETED still exits 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer changed the title fix(orchestration): put uv on PATH without sourcing its env file fix(orchestration): uv on PATH, one resume follow-up per job, resubmit round trip, failed chain stops Oct 22, 2026
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/review reset=true

@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

Two RISK findings remain in the resubmit/requeue recovery paths: saved command benchmarks with a policy model still fail to reload, and an interrupted follow-up submission can permanently strand a requeued chain.

Completed the broad RESET review across all eight changed files and their directly affected callers, persistence contracts, and regression tests. The earlier uv PATH fix remains intact. Static review only; tests were not executed.

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

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

Resolve the conflict in tests/unit_tests/test_eval_resubmit.py: both
sides added tests at the end of the file, and both sets are kept.

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

driver.policy_model writes the policy keys into every benchmark's run at
submit, and a command benchmark reads them as NEMO_GYM_POLICY_*. Its
saved config therefore holds a command with a run, which the benchmark
check rejected on reload, so resubmit queued nothing. On a saved config,
a command may now keep exactly the keys derived from a model service, and
the existing check still rejects a value that differs. A hand-written
command with a run, or a saved one with any other run key, is still
refused.

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

Copy link
Copy Markdown
Contributor Author

/review reset=true

Picks up the unit-test runner pin to Ubuntu 24.04 (NVIDIA-NeMo#4971) and the Terminus
interrupt test fix (NVIDIA-NeMo#4966), so CI runs on the current main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer
AdamRajfer added this pull request to the merge queue Oct 23, 2026
@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/39955672662

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

This branch was previously deployed

1 inactive deployment
public — 8e598adb Deployed Oct 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #6786
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 bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants