-
Notifications
You must be signed in to change notification settings - Fork 13
lightning config for requeing jobs on a preempted slurm partition #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edyoshikun
wants to merge
4
commits into
main
Choose a base branch
from
requeing_slurm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6f37d55
lightning config for requeing jobs on a preempted slurm partition
edyoshikun f64ed40
Apply suggestions from code review
edyoshikun c7ef9ac
fix(dynaclr): scope SLURM checkpoints by job id for clean requeue
6070f6f
docs(clusters): add Reef guide and reorganize DynaCLR-2D configs by c…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain-classical.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/bin/bash | ||
| # DynaCLR-2D-MIP-pretrain CLASSICAL (SimCLR-style) variant — Reef/Kelp smoke test. | ||
| # Adapted from | ||
| # applications/dynaclr/configs/training/DynaCLR-2D/bruno/DynaCLR-2D-MIP-BagOfChannels-classical.sh | ||
| # per docs/clusters/reef.md: named GPU partition instead of --constraint, | ||
| # explicit --qos (Reef requires one). Uses the requeing_slurm branch's | ||
| # checkpoint+requeue support (train.sh always passes --slurm_auto_requeue; | ||
| # it only attaches SLURMEnvironment(auto_requeue=True) when actually running | ||
| # under SLURM). --requeue/--signal are harmless at --qos dev (non-preemptible) | ||
| # and keep this script ready to resubmit at --qos mid/low unchanged. | ||
| # | ||
| # sbatch applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain-classical.sh | ||
|
|
||
| #SBATCH --job-name=dynaclr_2d_pretrain_smoke | ||
| #SBATCH --nodes=1 | ||
| #SBATCH --ntasks-per-node=2 | ||
| #SBATCH --gpus=2 | ||
| #SBATCH --partition=h100-reserved | ||
| #SBATCH --qos=dev | ||
| #SBATCH --cpus-per-task=15 | ||
| #SBATCH --mem-per-cpu=8G | ||
| #SBATCH --time=1-00:00:00 | ||
| #SBATCH --requeue | ||
| #SBATCH --signal=B:USR1@300 | ||
|
|
||
| export WORKSPACE_DIR="/mnt/main0/home/eduardo.hirata/repos/VisCy" | ||
| export MODEL_ROOT="/bio/projects/compimaging/models" | ||
| export PROJECT="DynaCLR-2D-MIP-pretrain" | ||
| export RUN_NAME="2d-mip-classical-ntxent-t0p2-lr2e5-bs256-192to160-zext11-single-marker-reef-smoke" | ||
| export CONFIGS="applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain.yml applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain-classical.yml" | ||
|
|
||
| # Smoke test: cap epochs/batches so we quickly get a checkpoint to validate | ||
| # against (single dirpath, no duplication) and to test SLURM preemption | ||
| # (auto-requeue + resume). Drop this override once the pipeline is validated. | ||
| export EXTRA_ARGS="--trainer.max_epochs=30 --trainer.limit_train_batches=5 --trainer.limit_val_batches=3" | ||
|
|
||
| source "${WORKSPACE_DIR}/applications/dynaclr/configs/training/slurm/train.sh" |
36 changes: 36 additions & 0 deletions
36
applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain-classical.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Override: SimCLR-style "classical" DynaCLR-2D-MIP-pretrain. | ||
| # Anchor and positive are the same crop; augmentation creates two views. | ||
| # Same mock parquet as the base leaf; only the positive-sampling strategy | ||
| # and batching differ from the (not-yet-written) temporal-positive variant. | ||
|
|
||
| data: | ||
| init_args: | ||
| cell_index_path: /bio/projects/compimaging/models/collections/DynaCLR-2D-MIP-pretrain-mock.parquet | ||
| # Self-augmented positives (SimCLR-style). Fully self-supervised: | ||
| # no lineage/track lookup, no tau scheduling. Augmentation pipeline | ||
| # provides view diversity. Single-marker batches still supply | ||
| # same-marker different-cell negatives, preserving discrimination | ||
| # signal at the marker/perturbation level. | ||
| positive_cell_source: self | ||
| positive_match_columns: null | ||
| positive_channel_source: same | ||
| # Single-marker batches (OPS strategy) — every batch is one marker, | ||
| # forcing the model to learn cellular features instead of channel | ||
| # shortcuts. | ||
| batch_group_by: marker | ||
| # Within a marker's draw, balance across the experiments containing | ||
| # that marker. | ||
| stratify_by: experiment | ||
| # Marker-uniform weights, restricted to the 5 markers actually present | ||
| # in DynaCLR-2D-MIP-pretrain-mock.parquet (G3BP1/TOMM20/SEC61B/ | ||
| # viral_sensor/Phase3D from the 5 mock 2026_* datasets). A marker key | ||
| # not present in the data is silently ignored; a marker present but | ||
| # missing from this dict gets sampling weight 0 (see | ||
| # viscy_data.sampler.FlexibleBatchSampler._precompute_groups) — so | ||
| # this list must be kept in sync with the collection's marker set. | ||
| group_weights: | ||
| Phase3D: 1.0 | ||
| G3BP1: 1.0 | ||
| SEC61B: 1.0 | ||
| TOMM20: 1.0 | ||
| viral_sensor: 1.0 |
145 changes: 145 additions & 0 deletions
145
applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| # DynaCLR-2D-MIP-pretrain (Reef/Kelp smoke test) | ||
| # ============================== | ||
| # First DynaCLR-2D-MIP training run on the Reef/Kelp (CoreWeave) cluster. | ||
| # Same 2D bag-of-channels contrastive recipe as | ||
| # applications/dynaclr/configs/training/DynaCLR-2D/bruno/DynaCLR-2D-MIP-BagOfChannels.yml, | ||
| # pointed at a mock collection (5 2026_* A549 infectomics experiments, | ||
| # Globus-copied to /bio) to validate the Reef training path end to end | ||
| # before scaling up to the full production collection. | ||
| # | ||
| # Launch: | ||
| # sbatch applications/dynaclr/configs/training/DynaCLR-2D/reef/DynaCLR-2D-MIP-pretrain-classical.sh | ||
| # | ||
| # Resume: | ||
| # CKPT_PATH=.../last.ckpt sbatch .../DynaCLR-2D-MIP-pretrain-classical.sh | ||
|
|
||
| base: | ||
| - ../../recipes/trainer/fit.yml | ||
| - ../../recipes/topology/ddp_2gpu.yml | ||
| - ../../recipes/model/contrastive_encoder_convnext_tiny.yml | ||
|
|
||
| trainer: | ||
| precision: bf16-mixed | ||
| max_epochs: 150 | ||
| limit_train_batches: 800 | ||
| limit_val_batches: 200 | ||
| logger: | ||
| init_args: | ||
| project: DynaCLR-2D-MIP-pretrain | ||
| name: null | ||
| callbacks: | ||
| - class_path: lightning.pytorch.callbacks.LearningRateMonitor | ||
| init_args: | ||
| logging_interval: step | ||
| - class_path: lightning.pytorch.callbacks.ModelCheckpoint | ||
| init_args: | ||
| monitor: loss/val | ||
| every_n_epochs: 1 | ||
| save_top_k: 5 | ||
| save_last: true | ||
| - class_path: viscy_utils.callbacks.OnlineEvalCallback | ||
| init_args: | ||
| every_n_epochs: 5 | ||
| label_key: perturbation | ||
| k: 20 | ||
| track_id_key: global_track_id | ||
| timepoint_key: t | ||
|
|
||
| model: | ||
| init_args: | ||
| encoder: | ||
| init_args: | ||
| in_stack_depth: 1 | ||
| stem_kernel_size: [1, 4, 4] | ||
| stem_stride: [1, 4, 4] | ||
| projection_dim: 32 | ||
| drop_path_rate: 0.1 | ||
| loss_function: | ||
| init_args: | ||
| temperature: 0.2 | ||
| lr: 0.00002 | ||
| pca_color_keys: "[perturbation,hours_post_perturbation,experiment,marker]" | ||
| log_negative_metrics_every_n_epochs: 2 | ||
| example_input_array_shape: [1, 1, 1, 160, 160] | ||
|
|
||
| data: | ||
| class_path: dynaclr.data.datamodule.MultiExperimentDataModule | ||
| init_args: | ||
| cell_index_path: /bio/projects/compimaging/models/collections/DynaCLR-2D-MIP-pretrain-mock.parquet | ||
| focus_channel: Phase3D | ||
| reference_pixel_size_xy_um: 0.1494 | ||
| z_window: 1 | ||
| z_extraction_window: 16 | ||
| z_focus_offset: 0.3 | ||
| yx_patch_size: [256, 256] | ||
| final_yx_patch_size: [160, 160] | ||
| channels_per_sample: 1 | ||
| positive_cell_source: lookup | ||
| positive_match_columns: [lineage_id] | ||
| positive_channel_source: same | ||
| tau_range: [0.5, 2.0] | ||
| tau_decay_rate: 2.0 | ||
| stratify_by: [perturbation, marker] | ||
| split_ratio: 0.8 | ||
| batch_size: 256 | ||
| num_workers: 4 | ||
| prefetch_factor: 1 | ||
| buffer_size: 1 | ||
| cache_pool_bytes: 0 | ||
| file_io_concurrency: 32 | ||
| seed: 42 | ||
| normalizations: | ||
| - class_path: viscy_transforms.NormalizeSampled | ||
| init_args: | ||
| keys: [channel_0] | ||
| level: timepoint_statistics | ||
| subtrahend: mean | ||
| divisor: std | ||
| augmentations: | ||
| - class_path: viscy_transforms.BatchedRandAffined | ||
| init_args: | ||
| keys: [channel_0] | ||
| prob: 0.8 | ||
| scale_range: [[0.8, 1.3], [0.8, 1.3], [0.8, 1.3]] | ||
| rotate_range: [3.14, 0.0, 0.0] | ||
| shear_range: [0.05, 0.05, 0.0, 0.05, 0.0, 0.05] | ||
| - class_path: viscy_transforms.BatchedRandFlipd | ||
| init_args: | ||
| keys: [channel_0] | ||
| spatial_axes: [1, 2] | ||
| prob: 0.5 | ||
| - class_path: viscy_transforms.BatchedRandAdjustContrastd | ||
| init_args: | ||
| keys: [channel_0] | ||
| prob: 0.5 | ||
| gamma: [0.6, 1.6] | ||
| - class_path: viscy_transforms.BatchedRandScaleIntensityd | ||
| init_args: | ||
| keys: [channel_0] | ||
| prob: 0.5 | ||
| factors: 0.5 | ||
| - class_path: viscy_transforms.BatchedRandGaussianSmoothd | ||
| init_args: | ||
| keys: [channel_0] | ||
| prob: 0.5 | ||
| sigma_x: [0.25, 0.50] | ||
| sigma_y: [0.25, 0.50] | ||
| sigma_z: [0.0, 0.0] | ||
| - class_path: viscy_transforms.BatchedRandGaussianNoised | ||
| init_args: | ||
| keys: [channel_0] | ||
| prob: 0.5 | ||
| mean: 0.0 | ||
| std: 0.1 | ||
| # Random Z crop: select 10 of 20 extracted slices for Z-invariance. | ||
| # Must come before ZReduction so MIP sees a variable sub-stack. | ||
| - class_path: viscy_transforms.BatchedRandSpatialCropd | ||
| init_args: | ||
| keys: [channel_0] | ||
| roi_size: [10, 192, 192] | ||
| # Z-reduction: MIP for fluorescence, center-slice for label-free. | ||
| # Must be LAST augmentation (before implicit final spatial crop). | ||
| - class_path: viscy_transforms.BatchedChannelWiseZReductiond | ||
| init_args: | ||
| keys: [channel_0] | ||
| allow_missing_keys: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?