Skip to content

feat(orchestration): stop a node-local job on Slurm's USR1 before its time limit - #6296

Merged
wprazuch merged 10 commits into
wprazuch/segment-node-local-archivefrom
wprazuch/node-local-walltime-stop
Nov 23, 2026
Merged

wprazuch merged 10 commits into
wprazuch/segment-node-local-archivefrom
wprazuch/node-local-walltime-stop

Conversation

@wprazuch

Copy link
Copy Markdown
Contributor

What does this PR do?

Stacked on #6217 (node-local driver dir, archived per Slurm job); review that first. A reviewer of #6217 asked for the stop before the time limit as its own PR, triggered by Slurm's --signal, and for the same stop to shut down the OpenTelemetry collector.

A step at its time limit is killed within moments, and a step off the batch node cannot start then, so the node-local dir may not be archived. With node_local, the job now stops before the limit:

  • node_local.stop_before_walltime_seconds (default 420; 0 turns it off) adds #SBATCH --signal=B:USR1@<seconds>.
  • On USR1 the batch shell stops the driver (TERM, up to 60 s), archives with the existing per-job step, stops the collector so it appends its node files to <benchmark dir>/otel/, removes the dir, and waits for the limit. The job still ends TIMEOUT, so the auto-resume chain is unchanged.
  • Off the batch node, those steps run as srun steps on the driver's node.
  • A driver that already ended or is past its evaluation is not stopped; the job keeps its status. An archive already running finishes and is not repeated. A USR1 before the handler is armed is acted on once it is.
  • The window must cover the stop: archive_timeout_seconds + 60 + 140 + 60 + 30 (driver exit, collector shutdown, signal slack, margin), 410 at the defaults.
  • With node_local, the collector's node dir moves under node_local.base_dir, so one setting places all of a job's node-local files.

Validation

Rollouts

N/A: only the batch script's lifecycle near the time limit changes.

Compatibility and benchmark impact

Only benchmarks with node_local: their jobs stop the driver about 7 minutes before the limit and hold the allocation idle until it. stop_before_walltime_seconds: 0 keeps #6217's behavior. Scripts without node_local render as before.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally.
  • Documentation added or updated (configuration.mdx, eval-submit-collector.mdx).
  • Pre-commit checks pass locally (on the changed files).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

…local.base_dir

When a benchmark sets node_local, the collector's node directory is created
under node_local.base_dir instead of /tmp, so one setting places all of the
job's node-local files. A collector container gets base_dir mounted. Without
node_local the collector stays in /tmp.

Signed-off-by: Wojciech Prazuch <[email protected]>
…e the time limit

node_local.stop_before_walltime_seconds (default 420, 0 turns it off) adds
#SBATCH --signal=B:USR1@<seconds>. On USR1 the batch shell stops the driver
(TERM, up to 60 s), archives the node-local dir, stops the OTel collector
once so it appends its files, removes the dir, and waits for the time limit,
so the job still ends TIMEOUT. Off the batch node these run as steps on the
driver's node, which can still start then.

A driver that already ended, or is past its evaluation, keeps the job's
status; a running archive finishes first and is not repeated. A USR1 before
the stop is set up, or during the driver's launch, is noted and acted on.
The window must cover archive_timeout_seconds + 60 + 140 + 60 + 30.

Signed-off-by: Wojciech Prazuch <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 17, 2026 10:35
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

…ed runner

The fake tar sleeps 3 s and the test's archive bound was 5 s, so a busy CI
runner could time the archive out.

Signed-off-by: Wojciech Prazuch <[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 WITH CARE

I found one RISK: a USR1 during collector launch can bypass its early shutdown, leaving telemetry copy-out dependent on KillWait again.

I inspected all seven changed files and traced the affected driver, archive, collector, and resume paths. This was a static review; I did not execute tests or verify signal delivery on a Slurm cluster.

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

{pid_var}=""
_gym_collector_stopped=""
{command}() {{
[[ -z "$_gym_collector_stopped" && -n "${pid_var}" ]] || return 0

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.

RISK: Defer USR1 across the collector launch and PID capture.

If USR1 arrives between the collector's background srun and OTEL_COLLECTOR_PID=$!, this guard returns because the PID is still empty. Those are separate generated commands. The stop handler sees no driver, archives, and enters its indefinite walltime wait, so execution never reaches the PID assignment. The already-launched collector misses the early stop and append; its files again depend on shutdown fitting within KillWait. This affects early signals during collector startup on either placement, with host or container execution.

Could you guard the collector launch using the existing LAUNCH_GUARD? Keep the empty-PID return for a collector that genuinely has not started. The invariant is that the stop handler cannot run between starting the collector and recording its PID.

Suggested change in _render_collector_service: add the keyword-only argument launch_guard: tuple[str, str] | None = None, assign its current _render_service_command(...) result to service, and replace the return with:

if launch_guard is None:
    return service
before, after = launch_guard
return f"{before}\n{service}\n{after}"

At the builder call, pass:

launch_guard=node_local_script.LAUNCH_GUARD if stops_early else None,

This records a pending signal until the PID is known, then lets the existing handler stop the collector before waiting. Scripts without early stopping stay unchanged. Please verify the suggested code before adopting it.

Proposed acceptance checks, not executed: render a job with the existing fake collector and inject a wait for its ready file followed by kill -USR1 $$ immediately before the collector PID assignment. For batch-node and off-batch placement, assert that the driver never starts, shared traces.jsonl contains start\nflushed\n, the collector directory is removed, and the batch shell keeps waiting for the time limit. Retain the existing assertions that driver-time USR1 appends after earlier segment and that a signal during restore starts neither services nor driver. Also check that stop_before_walltime_seconds: 0 still renders no USR1 handling.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The collector launch is wrapped in the same guard as the driver. test_a_usr1_between_the_collector_launch_and_its_pid_still_stops_the_collector fails without it.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the feature New capabilities, enhancements, or enablement work label Nov 17, 2026
Signed-off-by: Wojciech Prazuch <[email protected]>

# Conflicts:
#	nemo_gym/orchestration/executors/node_local.py
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:orchestration Job submission, deployment, services, and lifecycle management needs-review PR is ready for code review and waiting on a reviewer labels Nov 17, 2026
…ts PID is known

A USR1 between the collector's background srun and its PID capture ran the
stop with no collector PID, so the collector missed its clean shutdown. The
launch now takes the same guard as the driver's.

Signed-off-by: Wojciech Prazuch <[email protected]>
Brings #6217's merge of main (#6228 moved the Slurm executor, resume script
and recovery planner); node_local keeps this branch's stop-wait import.

Signed-off-by: Wojciech Prazuch <[email protected]>
Signed-off-by: Wojciech Prazuch <[email protected]>

# Conflicts:
#	nemo_gym/orchestration/executors/node_local.py
@wprazuch

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.

SHIP

I verified that the prior collector-launch race is fixed. The collector launch guard now defers USR1 until the collector PID is recorded. The new regression test injects the signal at that boundary and asserts that the driver never starts and telemetry flushes before walltime, for both placements.

I compared the fix and subsequent lifecycle, relocation, and test changes against the previous reviewed head. I found no unresolved prior findings or new regressions above the existing moderate-impact ceiling. This was a static follow-up review; I did not execute tests or validate signal delivery on Slurm.

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

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 18, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 20, 2026 11:55
@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high ready-to-merge PR is approved, current, and waiting for final CI or merge labels Nov 20, 2026
@wprazuch
wprazuch merged commit 0ddac6a into wprazuch/segment-node-local-archive Nov 23, 2026
72 of 73 checks passed
@wprazuch
wprazuch deleted the wprazuch/node-local-walltime-stop branch November 23, 2026 09:01
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 feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer ready-to-merge PR is approved, current, and waiting for final CI or merge risk:high Autobot PR risk: high 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