rsm_rise_code / rsm_rise /scripts /flagtopup /df_secondarm_wave3.sh
rli14's picture
rsm_rise code snapshot (HF_PUSH_ALL) (part 11)
c6a8401 verified
Raw History Blame Contribute Delete
4.46 kB
#!/usr/bin/env bash
# FLAG_TOPUP run 12: wave 3 -- a SECOND 3-seed arm per task, so the seed-noise floor is measurable on
# more than one task, plus the parked singleton payload.
#
# WHY THIS EXISTS. run 12's new section "Does the horizon sweep resolve the horizon, or the
# world-model seed?" compares the sweep's single-seed (W3) spread against the between-seed sd on a
# FIXED arm. That sd needs >= 2 arms carrying 3 full world-model seeds on the same task. Only
# threading has them (H50 mpcd + H20 mpc -> sd 1.7, spread 6.0, resolves at 3.5x). Every other task
# has at most ONE such arm, so its noise floor prints `--` and the question is unanswerable there.
#
# PRE-REGISTERED SELECTION RULE, WRITTEN BEFORE THESE CELLS EXIST (run 12, 2026-09-25 ~14:4xZ), and
# it is deliberately RATE-BLIND:
# * The second arm on a task is the non-pre-registered arm that ALREADY carries the MOST
# world-model seeds, ties broken by the LOWEST H. Seed count and H are properties of what has
# been run, not of how well it scored, so this cannot select a winner.
# * It is NOT a max-over-H. df_wmseed_eval_all.sh's run-9 rule stands: no replicate gets a fresh
# per-model horizon maximisation, because three independent maximisations would inflate the DF
# mean -- the exact selection bias this stream pre-registered against. This adds ONE fixed arm
# chosen on seed count, for a variance estimate, and the DF COLUMN REMAINS the pre-registered
# `H50 mpcd N128 M8` mean regardless of how this arm scores.
# * mug_expert_suboptimal `H50 mpc N128 M8` already has W3 (18.0) + W3s1 (14.2) and needs only W3s2.
# It was picked because it has 2 seeds and no other mug arm has more -- not because of 18.0/14.2.
#
# CHAINED, for the reason wave 2 was chained (see df_wmseed_eval_wave2.sh): pack-scripts queued in a
# deferred file are neither on disk nor PEND/RUN, so launch_df_mpc.py's dedupe cannot see them and a
# wave started while another holds a deferred queue would measure the same cell twice. pool() sums
# duplicate JSONs into one group -- the silent double-count class of run 9's argmin contamination.
set -uo pipefail
ROOT=/proj/dmfexp/zwhong/rsm_rise
cd "$ROOT" || exit 9
source scripts/env.sh
export RR_EXCL_HOSTS="$(grep -E "^p[0-9]+-r[0-9]+-n[0-9]+$" "$ROOT/status/bad_eval_hosts.txt" | tr '\n' ' ')"
echo "[exclhosts] excluding $(echo $RR_EXCL_HOSTS | wc -w) hosts"
# Wait for every DF eval pack of mine to leave the queue, bounded. Matching on the job-name prefix
# rather than a fixed id: run 11 re-queued two packs under new ids, so a hard-coded list goes stale.
deadline=$(( $(date +%s) + 150*60 ))
while :; do
live=$(bjobs -o "jobid job_name stat" -noheader 2>/dev/null \
| grep -E "rr_pack4_q_ftu_df(wmall|m64)" | grep -cE "RUN|PEND|SUSP")
[ "${live:-0}" -eq 0 ] && { echo "###### $(date -u +%H:%M:%SZ) no DF eval packs live -- proceeding"; break; }
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "###### WAIT DEADLINE: $live DF pack(s) still live after 150 min -- NOT starting wave 3 (it would risk duplicating their deferred cells). Next run decides."
exit 0
fi
echo "###### $(date -u +%H:%M:%SZ) $live DF eval pack(s) still live -- waiting"
sleep 300
done
sleep 60 # slack so the last pack's bsubs are visible to the PEND/RUN dedupe
STAMP=$(date -u +%Y%m%d_%H%M)
Q="$ROOT/status/packs/q_ftu_df2arm_${STAMP}.txt"
export RR_DEFER_PACK="$Q"
: > "$Q"
echo "###### $(date -u) wave 3: second 3-seed arm (rate-blind selection, see header)"
# mug: H50 mpc on W3s2 -- the only missing seed of the arm that already has the most.
python scripts/launch_df_mpc.py mug_expert_suboptimal --arm W3s2 --particles 8 \
--horizons 50 --readouts mpc 2>&1 | tail -3
# Drain the run-11 parked singleton alongside, so it rides a pack that was being submitted anyway
# instead of holding a whole 4-GPU node on its own (status/packs/q_ftu_singletons.NOTES.md).
PARK="$ROOT/status/packs/q_ftu_singletons.txt"
if [ -s "$PARK" ]; then
echo "###### draining $(wc -l < "$PARK") parked singleton payload(s) into this wave"
cat "$PARK" >> "$Q"
mv "$PARK" "$PARK.drained_${STAMP}"; : > "$PARK"
fi
n=$(grep -c . "$Q" 2>/dev/null || echo 0)
echo "###### QUEUE: $n payload(s) in $Q"
if [ "$n" -gt 0 ]; then
RR_GPUS=4 bash scripts/drain_pack_queue.sh "$Q" 2>&1 | tail -20
else
echo "###### nothing to drain -- every cell already exists or is PEND/RUN"
fi
echo "###### DONE $(date -u)"