rsm_rise_code / rsm_rise /scripts /beam /submit_wave.sh
rli14's picture
rsm_rise code snapshot (HF_PUSH_ALL) (part 11)
c6a8401 verified
Raw History Blame Contribute Delete
1.97 kB
#!/usr/bin/env bash
# BEAM_RISE: ONE 8-GPU gpu-mid job whose 8 slots drain status/beam/waves/<wave>/queue.txt (flock'd cursor).
# Never 1-GPU, never gpu-high. usage: GO=1 bash submit_wave.sh <wave> (no GO=1 = dry run)
set -uo pipefail
ROOT=/proj/dmfexp/zwhong/rsm_rise
W=$1; WD=$ROOT/status/beam/waves/$W; Q=$WD/queue.txt
[ -f "$Q" ] || { echo "no queue $Q"; exit 2; }
P=${SL_PART:-gpu-mid}; case "$P" in *high*) echo "refusing $P"; exit 2;; esac
case "${SL_QOS:-}" in *high*) echo "refusing QOS"; exit 2;; esac
G=8
name=rr_pack8_beam_${W}
sb=$WD/${name}.slurm.sh
cat > $sb <<EOS
#!/usr/bin/env bash
#SBATCH --job-name=$name
#SBATCH --partition=$P
#SBATCH --account=grp_runtime
#SBATCH --gres=gpu:$G
#SBATCH --nodes=1 --ntasks=1 --cpus-per-task=${SL_CPUS:-32}
#SBATCH --mem=${SL_MEM:-0}
#SBATCH --time=${SL_TIME:-06:00:00}
#SBATCH --requeue
#SBATCH --exclude=${SL_EXCLUDE:-p1-r04-n2}
#SBATCH --output=$ROOT/logs/slurm/${name}.%j.out
#SBATCH --error=$ROOT/logs/slurm/${name}.%j.err
cd $ROOT || exit 9
export RSM_LIBERO_DIR=$ROOT/code/rsm_libero_freeze_20261002
[ -f "\$RSM_LIBERO_DIR/model.py" ] || { echo "no RSM_LIBERO_DIR"; exit 8; }
echo "[beam-pack] host=\$(hostname) job=\${SLURM_JOB_ID:-none} \$(date -u)"; nvidia-smi -L
Q=$Q
# a requeued/resubmitted job restarts the cursor: cells whose JSON exists skip in seconds
rm -f \$Q.cursor.\${SLURM_JOB_ID:-0}
pop() { flock \$Q.lock bash -c 'c=\$1.cursor.\$2; n=\$(cat \$c 2>/dev/null || echo 0); echo \$((n+1)) > \$c; sed -n "\$((n+1))p" \$1' _ \$Q \${SLURM_JOB_ID:-0}; }
slot() { s=\$1; while true; do c=\$(pop); [ -n "\$c" ] || break; echo "[slot\$s] \$(date -u +%T) start \$c"; CUDA_VISIBLE_DEVICES=\$s bash "\$c"; echo "[slot\$s] \$(date -u +%T) rc=\$? \$c"; done; }
for s in 0 1 2 3 4 5 6 7; do slot \$s > $ROOT/logs/slurm/${name}.slot\$s.\${SLURM_JOB_ID:-0}.out 2>&1 & done
wait; echo "[beam-pack] done \$(date -u)"
EOS
chmod +x $sb
if [ "${GO:-0}" = 1 ]; then sbatch $sb; else echo "[dry] sbatch $sb"; cat $Q; fi