Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
31 lines
2.5 KiB
Bash
31 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# (spd-gap copy of cmp_window.sh: the job script is the second argument)
|
|
# A holder-free window for cmp_codex_job.sh (vanilla arm), started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor
|
|
# (the mechanism of the quality-245k and service-validation windows): cmp_window.sh LABEL (environment is passed through)
|
|
# 1. waits until the lab holder has ended and its memfd is gone; 2. runs cmp_codex_job.sh; 3. ALWAYS restarts the lab holder afterwards, so the queue goes on.
|
|
set -u
|
|
LABEL=${1:-window}
|
|
C=/data/leleka-e2e/codex-compare
|
|
H=$HOME/work/gpu-runs/holder2
|
|
NOTES=/data/leleka-e2e/decode/notes.md
|
|
note() { echo "[$(date -u +%FT%TZ)] [DEV spd-gap] $*" >> "$NOTES"; }
|
|
restart_holder() {
|
|
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then echo "a holder is already running"; return; fi
|
|
rmdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null # ours, if the payload died holding it
|
|
rm -f "$H/jobs/STOP" "$H/jobs/READY"
|
|
# the restarted holder must not inherit this window's CMP_* settings (it passes its environment on to every later queue stub: cmp-van-r2 once ran as VANL because of it)
|
|
( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL SPD_LOSSY SPD_MAX SPD_CELLS SPD_RUN && HOLDER_MEMFD=sparse setsid nohup bash /data/leleka-e2e/prefill-latency/tools/pf_holder_sparse.sh > "$H/holder3.out" 2>&1 < /dev/null & )
|
|
note "window $LABEL over: holder restarted SPARSE with pf_holder_sparse.sh (holder3.out; the full single-copy-holder.sh refilled the memfd to 51.5 GiB after every window); queue open again"
|
|
}
|
|
trap restart_holder EXIT
|
|
note "window $LABEL: waiting for the holder to end (jobs/STOP is set), then cmp_codex_job.sh: arm=${CMP_ARM:-?} reps=[${CMP_REPS:-}] tasks=[${CMP_TASKS:-}]"
|
|
for _ in $(seq 1 1440); do
|
|
if ! pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi
|
|
sleep 5
|
|
done
|
|
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then note "window $LABEL: the holder did not end in 2 h, giving up (holder left as it is)"; trap - EXIT; exit 3; fi
|
|
sleep 5
|
|
note "window $LABEL: holder gone, MemAvailable $(awk '/^MemAvailable:/{printf "%d GiB", $2/1048576}' /proc/meminfo); starting"
|
|
bash "${2:?job script}" > "/data/leleka-e2e/spd-gap/window-$LABEL.out" 2>&1
|
|
note "window $LABEL: cmp_codex_job.sh ended rc=$?; log $C/window-$LABEL.out"
|