GNN4Colliders / scripts /pretrain.sh
ho22joshua's picture
Claude Opus 5.5
feat: evaluation subsample, Slurm wrappers for the study and label-efficiency plots
e71731f
Raw History Blame Contribute Delete
1.68 kB
#!/bin/bash
# Label-free pretraining of an object encoder on one GPU, then k-NN and
# linear probes of its last epoch on GamGam for each number of labelled
# events:
# sbatch -A <account> --export=ALL,CONFIG=configs/delphes_contrastive.yaml scripts/pretrain.sh [key=value ...]
# CONFIG is configs/delphes_{jepa,contrastive,masked}.yaml (or
# delphes_jepa_edge.yaml with PROBE_CONFIG=configs/gamgam_finetune.yaml);
# PROBE_CONFIG (default configs/gamgam_jepa_finetune.yaml) must have the
# encoder's sizes. The probes evaluate EVAL_EVENTS (default 20000) random
# validation events. key=value overrides apply to the pretraining. For
# several GPUs, pretrain with scripts/train_ddp.sh instead. Prepare the
# Delphes and GamGam event caches first.
#SBATCH -N 1
#SBATCH -C gpu
#SBATCH -q shared
#SBATCH -G 1
#SBATCH -c 32
#SBATCH -t 12:00:00
#SBATCH -o logs/pretrain_%j.out
set -euo pipefail
cd "${SLURM_SUBMIT_DIR:-$(pwd)}"
CONFIG="${CONFIG:-configs/delphes_jepa.yaml}"
PROBE_CONFIG="${PROBE_CONFIG:-configs/gamgam_jepa_finetune.yaml}"
name="$(basename "${CONFIG}" .yaml)"
RUN="${RUN:-outputs/${name}}"
read -r -a events <<< "${EVENTS:-100 1000 10000}"
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-8}"
export UV_CACHE_DIR="${UV_CACHE_DIR:-${SCRATCH:-${HOME}/.cache}/uv}"
export HF_HOME="${HF_HOME:-${SCRATCH:-${HOME}/.cache}/huggingface}"
mkdir -p logs
uv run gnn4colliders train "${CONFIG}" run_dir="${RUN}" "$@"
for count in "${events[@]}"; do
uv run gnn4colliders probe "${PROBE_CONFIG}" split=validation \
model.pretrained="${RUN}/last.pt" data.train_events="${count}" \
data.eval_events="${EVAL_EVENTS:-20000}" \
output="${RUN}/probe/validation_n${count}.json"
done