Skip to content

fix(slurm): end the job when a service exits while the driver runs - #4785

Merged
AdamRajfer merged 5 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/slurm-end-job-on-service-exit
Oct 21, 2026
Merged

AdamRajfer merged 5 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/slurm-end-job-on-service-exit

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

When a service step such as a vLLM server died mid-run, nothing noticed: the job script kept each service's PID only for the startup health check, so the driver kept retrying the dead service and the job hung until its walltime.

Changes:

  • The driver runs in the background, and the job script checks it and every service step every 5 seconds: vLLM services, both vllm_pd tiers and the router, and the Ray head and worker steps. The OTel collector is not checked, because losing it costs telemetry, not the run.
  • If a service exits first, the script prints service <name> exited (status N) while the driver was running; stopping the driver., sends the driver TERM as the time limit would, and exits 1. The auto-resume chain or a resubmit then reruns the job with fresh services; rollouts that were in flight leave no row and run again on resume.
  • When the driver exits first, the job's exit status is the driver's, as before.
  • The Slurm executor and troubleshooting docs describe the check and the error line.

Tested with unit tests that run the rendered job.sh with a fake srun: a service that dies while the driver runs ends the job with status 1 in about 5 seconds and names the service; a driver that exits first keeps its exit code; Ray workers are watched and the collector is not. The two vllm_pd golden scripts are updated. The Slurm script, executor, resume and OTel suites pass (295 tests).

🤖 Generated with Claude Code

When a service step such as a vLLM server died mid-run, nothing noticed:
the job script kept each service's PID only for the startup health check,
so the driver kept retrying the dead service and the job hung until its
walltime.

The driver now runs in the background, and the job script checks it and
every service step every 5 seconds: vLLM services, both vllm_pd tiers and
the router, and the Ray head and worker steps. The OTel collector is not
checked, because losing it costs telemetry, not the run. If a service
exits first, the script names it and its exit status, sends the driver
TERM as the time limit would, and exits 1, so the auto-resume chain or a
resubmit reruns the job with fresh services. Rollouts that were in flight
leave no row and run again on resume. When the driver exits first, the
job's exit status is the driver's, as before.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/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 — two RISK findings leave supported service failures undetected.

Inspected all six changed files and traced service launchers, Ray worker expansion, driver exit handling, collector shutdown, and auto-resume. This was a static review; tests and suggested patches were not executed and 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

Two gaps the review found in the service watch:

- A service step with several tasks, such as a vllm_pd tier or a Ray
  worker pool, kept its srun alive when one task died, so the watch saw
  nothing and the driver kept retrying the dead server. Service steps now
  run with --kill-on-bad-exit=1 --wait=1: any one task's exit ends the
  whole step within a second, whatever the cluster's KillOnBadExit and
  WaitTime defaults, and the watch then ends the job. The driver step is
  unchanged.
- The driver's PID was kept in DRIVER_PID, which is also the PID
  variable of a service named DRIVER, so that service was never watched.
  The driver's PID now lives in _gym_driver_pid, which no service
  variable can take.

Tests: a service named DRIVER that exits ends the job and names itself;
every service step, and not the driver step, carries the two flags. The
two vllm_pd golden scripts are updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@yaoyu-33 yaoyu-33 added area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 20, 2026
14d68f8 gave every step rendered by _render_service_command
--kill-on-bad-exit=1 --wait=1, the OTel collector included, although
the job does not watch the collector. Only watched service steps need
the flags, so the collector's srun line is back to what it was, which
test_orchestration_otel checks exactly. The service-step test now also
asserts that the collector keeps Slurm's defaults, and the two vllm_pd
golden scripts drop the flags from their collector line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Resolve the import conflict in tests/unit_tests/test_slurm_script.py with NVIDIA-NeMo#4730 by keeping both sides imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
Comment thread tests/unit_tests/test_slurm_script.py Resolved
…e ends

At the end of a successful run the driver can exit and the service steps
stop inside one polling window. The watch loop then found a service dead
before it saw the driver gone, logged that the service exited while the
driver was running, and failed the job. _gym_service_exited now checks
the driver first and, if it has exited, returns the driver's status.

A test drives that window deterministically: on the loop's first service
check both fake steps end, and the check runs only after both have
exited. The test also renames the fake-binary loop variable so it no
longer shadows the name parameter.

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 21, 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/39612995962

Merged via the queue into NVIDIA-NeMo:main with commit 1a1c74a Oct 21, 2026
48 of 53 checks passed
@AdamRajfer
AdamRajfer deleted the fix/slurm-end-job-on-service-exit branch October 21, 2026 14:16
AdamRajfer added a commit to AdamRajfer/Gym that referenced this pull request Oct 21, 2026
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]>

This branch was previously deployed

1 inactive deployment
public — 0f0be311 Deployed Oct 21, 2026 by copy-pr-bot[bot] via release / finalize / notify #6230
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 complexity:low Localized change in one scope with a small, straightforward review surface 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