Skip to content

lightning config for requeing jobs on a preempted slurm partition - #478

Open
edyoshikun wants to merge 4 commits into
mainfrom
requeing_slurm
Open

lightning config for requeing jobs on a preempted slurm partition#478
edyoshikun wants to merge 4 commits into
mainfrom
requeing_slurm

Conversation

@edyoshikun

Copy link
Copy Markdown
Member
  • PR adds adds optional flag to support the requining of slurm jobs in a preemtable SLURM cluster (e.g Reef)

@srivarra

srivarra commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@edyoshikun Any suggestions on how to test this?

@edyoshikun

Copy link
Copy Markdown
Member Author

Just tested this on Reef and it worked. I sent SIGUSR1 mid-training -> Lightning caught it, checkpointed, called scontrol requeue, and then the same job was requeued again, and on restart, train.sh found checkpoints/last.ckpt and resumed with the same run ID

@srivarra srivarra 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.

Glad it worked out, I think the code looks good as well.

@@ -16,6 +16,8 @@
#SBATCH --cpus-per-task=15
#SBATCH --mem-per-cpu=8G
#SBATCH --time=3-00:00:00
#SBATCH --requeue
#SBATCH --signal=B:USR1@300

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.

do you still need that signal? #SBATCH --signal=B:USR1@300?

Copilot 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.

Pull request overview

This PR introduces an opt-in mechanism to auto-requeue Lightning training jobs when running under SLURM on preemptible partitions (e.g., Reef), aiming to checkpoint on SIGUSR1 and resume after SLURM requeues the job.

Changes:

  • Added a --slurm_auto_requeue CLI flag and wiring to attach SLURMEnvironment(auto_requeue=True, requeue_signal=SIGUSR1) when running under SLURM.
  • Updated the DynaCLR SLURM training launcher to auto-resume from checkpoints/last.ckpt and persist a W&B run id across requeues.
  • Updated one example SLURM sbatch script to enable requeueing and to emit SIGUSR1 ahead of termination.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/viscy-utils/src/viscy_utils/cli.py Adds an opt-in CLI flag and config rewrite to attach Lightning’s SLURM auto-requeue environment plugin.
applications/dynaclr/configs/training/slurm/train.sh Adds auto-resume logic and stable W&B run id persistence to support continuity across SLURM requeues.
applications/dynaclr/configs/training/DynaCLR-2D/DynaCLR-2D-MIP-BagOfChannels.sh Enables SLURM requeueing and sends SIGUSR1 before termination for checkpoint/requeue behavior.
uv.lock Updates locked dependencies/extras (includes changes not described by the PR’s stated SLURM-focused scope).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/viscy-utils/src/viscy_utils/cli.py
Comment thread packages/viscy-utils/src/viscy_utils/cli.py
Comment thread applications/dynaclr/configs/training/slurm/train.sh
edyoshikun and others added 3 commits July 20, 2026 10:55
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Pin ModelCheckpoint.dirpath to default_root_dir and scope the run's
checkpoints/wandb-id/hpc_ckpt by SLURM_JOB_ID so a fresh submission starts
clean while a genuine preemption+requeue (same SLURM_JOB_ID) resumes its own
state. Append an instantiated SLURMEnvironment rather than a lazy_instance/
class_path spec, which fails Union-slot validation in before_instantiate_classes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…luster

Add docs/clusters/reef.md (CoreWeave SLURM adaptation guide) and split the
DynaCLR-2D training configs into per-cluster bruno/ and reef/ subdirectories.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants