37 lines
2.9 KiB
Bash
37 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
# A holder-free window for single-copy-ab.sh, started DETACHED by a holder job stub (the stub touches jobs/STOP, closes the holder's descriptor and launches this).
|
|
# single-copy-window.sh LABEL environment (PHASES, BLOCKS, ARMS_SET, RUN_TAG, OUTR) is passed through to single-copy-ab.sh
|
|
# 1. waits until the holder process has ended and its 51.5 GiB memfd is gone (the holder ends after the stub returns because jobs/STOP exists);
|
|
# 2. runs single-copy-ab.sh (it takes MODEL.lock and gpu.lock itself);
|
|
# 3. ALWAYS restarts the lab holder afterwards, with the fast seal (single-copy-holder.sh: O_DIRECT, no page cache), so the queue goes on.
|
|
# The A/B ends early (between runs) when /data/leleka-e2e/single-copy/STOP exists.
|
|
set -u
|
|
LABEL=${1:-window}
|
|
SC=/data/leleka-e2e/single-copy
|
|
H=$HOME/work/gpu-runs/holder2
|
|
NOTES=/data/leleka-e2e/decode/notes.md
|
|
note() { echo "[$(date -u +%FT%TZ)] [DEV single-copy] $*" >> "$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 A/B died holding it
|
|
rm -f "$H/jobs/STOP" "$H/jobs/READY"
|
|
( cd "$H" && setsid nohup bash "$SC/tools/single-copy-holder.sh" > "$H/holder3.out" 2>&1 < /dev/null & )
|
|
note "window $LABEL over: holder restarted with the fast seal (holder3.out); queue open again"
|
|
}
|
|
trap restart_holder EXIT
|
|
note "window $LABEL: waiting for the holder to end (jobs/STOP is set), then single-copy-ab.sh PHASES='${PHASES:-cold id e2e}' BLOCKS=${BLOCKS:-6}"
|
|
for _ in $(seq 1 240); 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 20 min, giving up (holder left as it is)"; trap - EXIT; exit 3; fi
|
|
# the file arm needs the archive as a read-only file (what `leleka up` does for kar_source=file: mode 0400; changes its ctime once)
|
|
KAR=$HOME/work/leleka/models/leleka-gates/assets/qwen-iq3-s-l2-v4.kar
|
|
if [ -w "$KAR" ]; then chmod 0400 "$KAR" && note "window $LABEL: chmod 0400 on the KAR archive (file arm; the product's own step; ctime moved once)"; fi
|
|
# the holder's 51.5 GiB must really be gone
|
|
sleep 5
|
|
note "window $LABEL: holder gone, MemAvailable $(awk '/^MemAvailable:/{printf "%d GiB", $2/1048576}' /proc/meminfo); starting"
|
|
# gentler on the model volume than the default (32 threads, 8 MiB blocks): the server hung on 2026-11-02 while heavy O_DIRECT reads of that volume were around
|
|
LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} LELEKA_LOAD_CHUNK_MIB=${LELEKA_LOAD_CHUNK_MIB:-8} bash "$SC/tools/${AB_SCRIPT:-single-copy-ab.sh}" > "$SC/window-$LABEL.out" 2>&1
|
|
note "window $LABEL: single-copy-ab.sh ended rc=$?; outputs under ${OUTR:-/data/leleka-e2e/runs/single-copy-ab}, log $SC/window-$LABEL.out"
|