Skip to content

Cancel newest queued Slurm workers when demand drops - #487

Merged
hermabr merged 3 commits into
mainfrom
t3code/support-slurm-pool-scaling-1
Aug 6, 2026
Merged

Cancel newest queued Slurm workers when demand drops#487
hermabr merged 3 commits into
mainfrom
t3code/support-slurm-pool-scaling-1

Conversation

@hermabr

@hermabr hermabr commented Aug 5, 2026

Copy link
Copy Markdown
Owner

When satisfiable demand falls below the tracked worker count, the pool now scancels the excess, newest-first (older jobs have accrued queue age and are closest to being scheduled). Only still-PENDING jobs are cancelled: a running worker may hold a lease, and the idle timeout already retires it once work runs dry. Cancelled jobs are dropped from tracking immediately so their CANCELLED state can't be mistaken for the pool becoming unhealthy.

The one design choice worth noting: PENDING-ness is read from the squeue call the pool already makes every tick (%T added to the format), not from sacct. sacct reports still-queued array tasks in one aggregate line (100_[1,2-4%2]), which would require parsing and expanding array-spec syntax in the pool; squeue --array lists queued tasks individually, so array jobs need no special handling anywhere in production code. _task_states (sacct) is untouched.

Tests: the fake squeue now reports states and expands bracketed task specs the way real squeue does; new tests cover scale-down for plain jobs, scale-down for array jobs (aggregate bracket form in the fake), and that running workers are never cancelled.

🤖 Generated with Claude Code

When satisfiable demand falls below the tracked worker count, scancel
the excess jobs, newest-first. Only still-PENDING jobs are cancelled: a
running worker may hold a lease, and the idle timeout already retires
it once work runs dry.

PENDING-ness comes from the squeue call the pool already makes each
tick (%T added to the format). Unlike sacct, which reports queued array
tasks in one aggregate line ("100_[1-3]"), squeue --array lists them
individually, so no array-spec parsing is needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hermabr
hermabr force-pushed the t3code/support-slurm-pool-scaling-1 branch from 715f52a to ed3be57 Compare August 5, 2026 17:37
@hermabr hermabr changed the title Cancel queued Slurm workers when demand drops Cancel newest queued Slurm workers when demand drops Aug 5, 2026

hermabr commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Merge activity

  • Aug 6, 3:35 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 6, 3:35 PM UTC: @hermabr merged this pull request with Graphite.

@hermabr
hermabr merged commit 307f670 into main Aug 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant