lorapop / code /slurm /pheno_rep.sh
bryan7264's picture
Add files using upload-large-folder tool
a8b5668 verified
Raw History Blame Contribute Delete
2.32 kB
#!/bin/bash
#SBATCH -p gpu_devel
#SBATCH --gpus=2
#SBATCH -c 12
#SBATCH --mem=200G
#SBATCH -t 06:00:00
#SBATCH -J ph_rep
#SBATCH -o /home/bjc75/other/finetuning/logs/%x_%j.out
# MIT License, Bryan Cheng, 2026. Replication-population phenotypes (RESEARCH_PLAN 1.2, 15.2) on the 2-GPU devel lane.
# BASE=<hf id> AD=<adapters dir> OUT=<results dir> [NSH=16] sbatch slurm/pheno_rep.sh
# Same settings as the primary population (full battery, bank group 8, batch 128 / 256 capped by GPU memory). Shards are
# dealt round-robin to the workers (1 per GPU, 2 on GPUs >= 120 GB, none on a GPU with ECC faults). Finished adapters are
# skipped, so the same command continues the population in the next job.
cd /home/bjc75/other/finetuning
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True PYTHONUNBUFFERED=1 TOKENIZERS_PARALLELISM=false HF_HOME=/nfs/roberts/scratch/pi_skr2/bjc75/finetuning/hf_home
PY=/nfs/roberts/project/pi_skr2/bjc75/conda_envs/lorapop/bin/python; NSH=${NSH:-16}
IFS=, read -ra GIDS <<< "$CUDA_VISIBLE_DEVICES"; echo "allocated GPUs: ${GIDS[*]}"; nvidia-smi --query-gpu=name --format=csv,noheader
W=() # one entry per worker: physical GPU id
for g in 0 1; do
mem=$(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits | sed -n "$((g + 1))p")
ecc=$(nvidia-smi --query-gpu=ecc.errors.uncorrected.volatile.total --format=csv,noheader,nounits | sed -n "$((g + 1))p" | tr -d " ")
case "$ecc" in ""|0|"[N/A]"|"N/A") ;; *) echo "GPU $g has $ecc uncorrected ECC errors: no workers on it"; continue ;; esac
W+=(${GIDS[$g]}); [ "${mem:-0}" -ge 120000 ] && W+=(${GIDS[$g]})
done
nw=${#W[@]}; [ "$nw" -eq 0 ] && { echo "no usable GPU"; exit 1; }
for w in $(seq 0 $((nw - 1))); do
(
for s in $(seq $w $nw $((NSH - 1))); do
X=""; [ "$s" = 0 ] && X="--include_base"
CUDA_VISIBLE_DEVICES=${W[$w]} $PY src/run/phenotype.py --base $BASE --adapters $AD --out $OUT --shard $s --nshards $NSH $X \
--sizes full --group 8 --bs 128 --gbs 256 2>&1 | grep -v -i warn | grep -v " ok " | tail -5
done
) > logs/phrep_${SLURM_JOB_ID}_w${w}.log 2>&1 &
sleep 20
done
( while sleep 600; do nvidia-smi --query-gpu=index,utilization.gpu,memory.used --format=csv,noheader | tr '\n' ' '; echo; done ) &
wait $(jobs -p | head -n $nw)
echo "records: $(ls $OUT/*.json 2>/dev/null | wc -l)"