Skip to content

fix(orchestration): settle a requeued chain on its REQUEUED records - #5992

Merged
AdamRajfer merged 2 commits into
mainfrom
arajfer/requeue-settle-chain-stop
Nov 13, 2026
Merged

AdamRajfer merged 2 commits into
mainfrom
arajfer/requeue-settle-chain-stop

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

What does this PR do?

A requeued resumable chain never settles, so the sentinel stops it.

When Slurm requeues a job, sacct keeps the earlier incarnation as a REQUEUED row for good. _gym_chain_settled in the resume script accepted only COMPLETED, FAILED, CANCELLED, TIMEOUT, OUT_OF_MEMORY, NODE_FAIL, BOOT_FAIL, DEADLINE and PREEMPTED, so with a real requeue the check never passed. The sentinel then timed out with "its terminal scheduler records did not settle within 300s" and left the chain stopped, although no budget was spent. The operator had to recover by hand.

The Python reader in recovery.py (accounted_requeued_chain_walltime, allocation_cut_from_accounting) already treats REQUEUED as ended once a later incarnation exists. This change makes the shell check agree. REQUEUED counts as settled only for an incarnation that a later one followed. A last incarnation still REQUEUED is waiting to run again and still does not settle.

Seen on an eval chain where the follow-up job was requeued once. Its sacct rows were REQUEUED|36|0 and FAILED|14|1, next to the previous job's FAILED row.

Related: #4840 (a requeue no longer queues a duplicate follow-up) and #4978 (count a requeued job's walltime and retry once). This PR touches neither counter. It only changes which sacct states the sentinel accepts as settled.

Validation

  • tests/unit_tests/orchestration/test_requeued_chain_sentinel.py::test_a_requeued_follow_up_settles_on_its_requeued_record uses the row shape above. It fails before the fix and passes after it: one recovery is queued, with the right accumulated walltime.
  • test_a_last_incarnation_still_requeued_does_not_settle guards the case that must keep waiting.
  • uv run --extra dev python -m pytest tests/unit_tests/orchestration/test_requeued_chain_sentinel.py tests/unit_tests/test_resume_script.py: 222 passed.
  • ruff check and ruff format --check are clean on the changed files.

The sentinel that reconciles a requeued chain waited for every incarnation to
have a terminal scheduler record, but sacct keeps the earlier incarnation of a
requeued job as a REQUEUED row, and the check did not accept that state. A
chain with a real requeue therefore never settled: the sentinel timed out and
left the chain stopped. Accept REQUEUED for an incarnation that a later one
followed, as the recovery reader already does; the last incarnation still
REQUEUED waits to run again and does not settle.

Signed-off-by: Adam Rajfer <[email protected]>

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

I reviewed both changed files and traced the affected accounting and recovery path. The settlement check now matches the Python reader: an older REQUEUED incarnation can settle only when the same job has a later incarnation. A latest REQUEUED row, incomplete restart history, and nonterminal records still prevent recovery.

The new regression tests exercise the rendered prologue and real recovery reader, checking one preserved-budget submission, 15050 seconds of accumulated walltime, and no submission while the latest incarnation remains requeued.

This was a static review; I didn't execute tests.

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.

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test a0bfee9

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

🤖 Adam’s AI assistant

@prokotg this one and #6086 (bounded-memory read of oversized rows) are the two recovery fixes waiting on your review; CI is green on both. Could you take a look when you have a moment?

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

Looks good to me. The shell settlement check now matches the recovery reader, and the new tests cover both historical and latest REQUEUED records.

@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 13, 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/43510597368

Merged via the queue into main with commit caf244d Nov 13, 2026
73 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/requeue-settle-chain-stop branch November 13, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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