From 953984d719e87af9175079df4121e0bff54485ac Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sun, 1 Nov 2026 23:16:35 +0100 Subject: [PATCH 1/4] scripts: baseline-pair part e, one arm per fresh boot (laptop-driven reboot series, cycle hook, ENTRIES) Co-Authored-By: Claude Sonnet 5.5 --- scripts/e2e/decode/baseline-install.sh | 2 +- scripts/e2e/decode/baseline-pair-ab.sh | 4 +- scripts/e2e/decode/baseline-reboot-series.sh | 116 +++++++++++++++++++ scripts/e2e/decode/cycle-hook.sh | 16 +++ 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 scripts/e2e/decode/baseline-reboot-series.sh create mode 100644 scripts/e2e/decode/cycle-hook.sh diff --git a/scripts/e2e/decode/baseline-install.sh b/scripts/e2e/decode/baseline-install.sh index a5595393..ea52b1a2 100644 --- a/scripts/e2e/decode/baseline-install.sh +++ b/scripts/e2e/decode/baseline-install.sh @@ -10,7 +10,7 @@ D=/data/leleka-e2e/decode/dt SRC=$(cd "$(dirname "$0")" && pwd) mkdir -p "$BP/tools" chmod -R u+w "$BP/tools" 2>/dev/null || true -for f in baseline-pair-ab.sh baseline-sampler.py ts-wrap.sh; do install -m 0444 "$SRC/$f" "$BP/tools/$f"; done +for f in baseline-pair-ab.sh baseline-sampler.py ts-wrap.sh cycle-hook.sh; do install -m 0444 "$SRC/$f" "$BP/tools/$f"; done chmod a-w "$BP/tools" ENG=$(ls -d /home/para/.local/share/strata/components/engine/*/strata | head -1) { diff --git a/scripts/e2e/decode/baseline-pair-ab.sh b/scripts/e2e/decode/baseline-pair-ab.sh index 3db20026..95c0ddeb 100644 --- a/scripts/e2e/decode/baseline-pair-ab.sh +++ b/scripts/e2e/decode/baseline-pair-ab.sh @@ -164,7 +164,9 @@ PY # the run list: "block:pos:arm" entries. Default = permutations of BLOCKS. SEQ="v2 v2 ours ..." runs exactly that sequence instead (SEQ_GROUP arms per block, default 3), used by # the predecessor test of job bp-b (VV O repeated: a vanilla run directly after ours against a vanilla run directly after vanilla, interleaved in time). LIST="" -if [ -n "${SEQ:-}" ]; then +if [ -n "${ENTRIES:-}" ]; then + LIST="$ENTRIES" # explicit "block:pos:arm" entries (one reboot cycle = one entry) +elif [ -n "${SEQ:-}" ]; then i=0; for arm in $SEQ; do LIST="$LIST $((BLOCK_BASE + i / ${SEQ_GROUP:-3} + 1)):$((i % ${SEQ_GROUP:-3} + 1)):$arm"; i=$((i + 1)); done else for b in $BLOCKS; do pos=0; for arm in $(perm "$b" | sed "s/v1/${SUBST_V1:-v1}/"); do pos=$((pos + 1)); LIST="$LIST $((BLOCK_BASE + b)):$pos:$arm"; done; done diff --git a/scripts/e2e/decode/baseline-reboot-series.sh b/scripts/e2e/decode/baseline-reboot-series.sh new file mode 100644 index 00000000..6e2ef5d1 --- /dev/null +++ b/scripts/e2e/decode/baseline-reboot-series.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# baseline-pair part e: ONE ARM PER FRESH BOOT. Runs on the LAPTOP (git bash), drives rnr5090 over ssh. Owner-authorised (chat, 2026-11-01): rebooting rnr5090 between runs. +# Allowed on the server: `sudo -n systemctl reboot` and nothing else privileged (no systemd units, sysctl, grub; sudo -n dmesg is read-only). +# +# bash baseline-reboot-series.sh [BLOCKS="1 2 3 4 5 6"] env: SERIES_LOG (local log), STOPFILE (touch it to stop after the current cycle) +# +# Per cycle: (1) nothing foreign may run (jobs pending/running other than our stubs, gpu.lock, a GPU process); wait otherwise, never reboot under a job; +# (2) `sync`, reboot, wait for ssh (new boot_id) up to 10 min; on timeout try the rescue sshd (:2222, `rboot`) once, then STOP; (3) safety net check (rescue sshd :2222, /dev/watchdog0, +# hung_task_panic=1, swap off, no NVMe errors in dmesg): any failure STOPs the series; (4) restart the KAR holder the way decode/notes.md did after a boot (remove the empty stale +# MODEL.lock, delete jobs/READY, `setsid nohup bash run_holder2.sh`), wait for READY; (5) queue ONE holder job (the arm) via ENTRIES, wait for its .done, read VALIDITY.txt; (6) next reboot. +# Arms: ours = dt/bin-main-ffd9322 (main d29e3dba2, same code outside docs/scripts), PCIe 0.45 pinned, defaults; v1 = vanilla shipped defaults; v2 = tail skip off + prefill CPU share 0. +# The job (baseline-pair-ab.sh) records settle.txt, pre.jsonl (uptime = time since boot, buddyinfo, meminfo), state.jsonl, post.jsonl, hook.txt (cycle-hook.sh: boot id/time, safety net, nvme dmesg hits). +set -uo pipefail +BLOCKS=${1:-"1 2 3 4 5 6"} +SSH="ssh -o ConnectTimeout=6 -o BatchMode=yes rnr5090" +OUTR=/data/leleka-e2e/runs/baseline-pair-e +JOBS='$HOME/work/gpu-runs/holder2/jobs' +SERIES_LOG=${SERIES_LOG:-./baseline-reboot-series.log} +STOPFILE=${STOPFILE:-./baseline-reboot-series.STOP} +perm() { case $1 in 1) echo "ours v1 v2";; 2) echo "v2 v1 ours";; 3) echo "v1 v2 ours";; 4) echo "ours v2 v1";; 5) echo "v2 ours v1";; 6) echo "v1 ours v2";; esac; } +CYLOG="" +log() { local l="[$(date -u +%FT%TZ)] $*"; echo "$l" | tee -a "$SERIES_LOG"; CYLOG="$CYLOG$l"$'\n'; } +die() { log "STOP SERIES: $*"; push_log; exit 1; } +push_log() { [ -n "$CYLOG" ] && printf '%s' "$CYLOG" | $SSH "mkdir -p $OUTR/_cycles && cat >> $OUTR/_cycles/series.log" 2>/dev/null; CYLOG=""; } + +foreign() { # prints what is running/queued that is not ours + $SSH 'cd ~/work/gpu-runs/holder2/jobs 2>/dev/null || exit 0 + for f in *.sh; do b=${f%.sh}; case $b in 220-expert-tier|decode-sass-trace2|bpe-*) continue;; esac; [ -e $b.done ] || echo "job:$b"; done + for r in *.running; do b=${r%.running}; case $b in 220-expert-tier|decode-sass-trace2|bpe-*) continue;; esac; echo "running:$b"; done + [ -d /data/leleka-e2e/gpu.lock ] && echo "gpu.lock:$(cat /data/leleka-e2e/gpu.lock/owner 2>/dev/null)" + nvidia-smi --query-compute-apps=pid --format=csv,noheader | sed "s/^/gpu-pid:/" + pgrep -f "leleka-inference|strata-next|/strata --serve" | sed "s/^/proc:/"' 2>/dev/null +} +wait_quiet() { # up to 4 h + local n=0 f + while :; do + f=$(foreign | tr '\n' ' ') + [ -z "${f// /}" ] && return 0 + n=$((n + 1)); [ $((n % 5)) = 1 ] && log "waiting for foreign work to finish: $f" + [ $n -gt 240 ] && die "foreign work still present after 4 h: $f" + sleep 60 + done +} +wait_boot() { # $1 old boot_id ; up to 10 min after the reboot command + local t0=$SECONDS id + sleep 30 + while [ $((SECONDS - t0)) -lt 600 ]; do + id=$($SSH 'cat /proc/sys/kernel/random/boot_id' 2>/dev/null) && [ -n "$id" ] && [ "$id" != "$1" ] && { log "ssh back after $((SECONDS - t0)) s, new boot_id $id"; return 0; } + sleep 10 + done + log "no ssh within 10 min; trying the rescue sshd :2222" + ssh -o ConnectTimeout=10 -o BatchMode=yes -p 2222 -l root rnr5090 'uptime; dmesg | tail -15' 2>&1 | tail -20 | while read -r l; do log "rescue: $l"; done + ssh -o ConnectTimeout=10 -o BatchMode=yes -p 2222 -l root rnr5090 'rboot' >/dev/null 2>&1 + t0=$SECONDS; sleep 30 + while [ $((SECONDS - t0)) -lt 600 ]; do + id=$($SSH 'cat /proc/sys/kernel/random/boot_id' 2>/dev/null) && [ -n "$id" ] && [ "$id" != "$1" ] && { log "ssh back after rboot, $((SECONDS - t0)) s"; return 2; } + sleep 10 + done + die "server did not come back after reboot and rboot" +} + +mkdir -p "$(dirname "$SERIES_LOG")" 2>/dev/null +$SSH 'sudo -n true' || die "passwordless sudo not available" +cyc=0 +for b in $BLOCKS; do + pos=0 + for arm in $(perm "$b"); do + pos=$((pos + 1)); cyc=$((cyc + 1)); tag=$(printf "b%02dp%d-%s" "$b" "$pos" "$arm") + [ -e "$STOPFILE" ] && die "stop file present before $tag" + tries=0 + while :; do + tries=$((tries + 1)); [ $tries -gt 3 ] && die "cycle $cyc ($tag) kept getting foreign work" + log "=== cycle $cyc $tag (try $tries)" + wait_quiet + old=$($SSH 'cat /proc/sys/kernel/random/boot_id') || die "ssh failed before reboot" + $SSH 'sudo -n true' || die "passwordless sudo vanished" + log "sync + reboot (old boot_id $old, uptime $($SSH 'uptime -p'))" + timeout 30 $SSH 'sync; sudo -n systemctl reboot' >/dev/null 2>&1 + wait_boot "$old"; rc=$? + [ $rc = 2 ] && die "needed the rescue sshd (rboot) to come back: report to the owner" + # safety net after boot (retry briefly: services come up a little after sshd) + ok=0 + for _ in 1 2 3 4 5 6; do + net=$($SSH 'echo rescue=$(ss -ltn | grep -c ":2222 ") wd=$(ls /dev/watchdog0 2>/dev/null | wc -l) hung=$(sysctl -n kernel.hung_task_panic) swap=$(swapon --show --noheadings | wc -l) nvme=$(sudo -n dmesg 2>/dev/null | grep -i -c -E "nvme.*(timeout|reset|abort|error)") up=$(cut -d" " -f1 /proc/uptime)') + case "$net" in *"rescue=1 "*"wd=1 hung=1 swap=0 nvme=0 "*) ok=1; break;; esac + sleep 10 + done + log "safety net: $net" + [ $ok = 1 ] || die "safety net check failed after boot ($net)" + # KAR holder, as after the boot of 2026-10-29 (notes.md): stale empty MODEL.lock removed, ONE holder started, READY rewritten + $SSH 'pgrep -f kar_holder2 >/dev/null && echo HOLDER_ALREADY_RUNNING; rm -f '"$JOBS"'/READY; [ -d $HOME/work/gpu-runs/MODEL.lock ] && { rmdir $HOME/work/gpu-runs/MODEL.lock || echo MODEL_LOCK_NOT_EMPTY; } + cd $HOME/work/gpu-runs/holder2 && { setsid nohup bash run_holder2.sh >> holder2.out 2>&1 < /dev/null & } ; sleep 1; pgrep -f kar_holder2 | head -1 >/dev/null; echo started' | while read -r l; do log "holder: $l"; done + for _ in $(seq 1 90); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done + $SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 15 min" + log "holder READY: $($SSH 'cat '"$JOBS"'/READY; echo " uptime_s=$(cut -d" " -f1 /proc/uptime)"')" + f=$(foreign | grep -v '^proc:' | tr '\n' ' ') + if [ -n "${f// /}" ]; then log "foreign work appeared after boot ($f): waiting for it, then redoing the reboot for a fresh state"; wait_quiet; continue; fi + stub="bpe-$(printf '%02d' $cyc)" + $SSH "mkdir -p $OUTR; cat > $JOBS/$stub.sh </dev/null && break; sleep 10; done + $SSH "test -e $JOBS/$stub.done" || die "$stub did not finish within 45 min" + log "$stub done rc=$($SSH "cat $JOBS/$stub.done") validity: $($SSH "cat $OUTR/$tag/VALIDITY.txt 2>&1 | cut -c1-160")" + $SSH "mkdir -p $OUTR/_cycles; cp $JOBS/$stub.log $OUTR/_cycles/$stub.log" 2>/dev/null + push_log + break + done + done +done +log "series complete: $cyc cycles" +push_log diff --git a/scripts/e2e/decode/cycle-hook.sh b/scripts/e2e/decode/cycle-hook.sh new file mode 100644 index 00000000..24530bf8 --- /dev/null +++ b/scripts/e2e/decode/cycle-hook.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# PRE_ARM_HOOK of the reboot series (baseline-pair part e): record the post-boot state of this cycle before the arm starts. Read-only. $1 = arm. +echo "arm=$1" +echo "boot_id=$(cat /proc/sys/kernel/random/boot_id)" +echo "boot_time=$(uptime -s)" +echo "uptime_s_at_hook=$(cut -d' ' -f1 /proc/uptime)" +echo "rescue_sshd_2222_listeners=$(ss -ltn | grep -c ':2222 ')" +echo "watchdog0=$(ls /dev/watchdog0 2>&1)" +echo "hung_task_panic=$(sysctl -n kernel.hung_task_panic)" +echo "swap_lines=$(swapon --show --noheadings | wc -l)" +echo "nvme_dmesg_hits=$(sudo -n dmesg 2>/dev/null | grep -i -c -E 'nvme.*(timeout|reset|abort|error)')" +echo "holder_pids=$(pgrep -f kar_holder2 | tr '\n' ' ')" +echo "ready_file_mtime=$(stat -c %y "$HOME/work/gpu-runs/holder2/jobs/READY" 2>&1)" +echo "thp=$(cat /sys/kernel/mm/transparent_hugepage/enabled) defrag=$(cat /sys/kernel/mm/transparent_hugepage/defrag)" +grep -E "MemFree|MemAvailable|^Cached|Shmem:|AnonHugePages" /proc/meminfo | tr -s ' ' | tr '\n' ';'; echo +echo "buddyinfo:"; cat /proc/buddyinfo From bcdb5f92f99dd55f0b35f6846398bd0e9633a06e Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sun, 1 Nov 2026 23:27:11 +0100 Subject: [PATCH 2/4] scripts: reboot series, pgrep must not match its own ssh command --- scripts/e2e/decode/baseline-reboot-series.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e/decode/baseline-reboot-series.sh b/scripts/e2e/decode/baseline-reboot-series.sh index 6e2ef5d1..8d0b82aa 100644 --- a/scripts/e2e/decode/baseline-reboot-series.sh +++ b/scripts/e2e/decode/baseline-reboot-series.sh @@ -29,7 +29,7 @@ foreign() { # prints what is running/queued that is not ours for r in *.running; do b=${r%.running}; case $b in 220-expert-tier|decode-sass-trace2|bpe-*) continue;; esac; echo "running:$b"; done [ -d /data/leleka-e2e/gpu.lock ] && echo "gpu.lock:$(cat /data/leleka-e2e/gpu.lock/owner 2>/dev/null)" nvidia-smi --query-compute-apps=pid --format=csv,noheader | sed "s/^/gpu-pid:/" - pgrep -f "leleka-inference|strata-next|/strata --serve" | sed "s/^/proc:/"' 2>/dev/null + pgrep -f "[l]eleka-inference|[s]trata-next|[/]strata --serve" | sed "s/^/proc:/"' 2>/dev/null } wait_quiet() { # up to 4 h local n=0 f From ca3eb4f8fa06b6e5552bcba1feab28e44b955ebb Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Mon, 2 Nov 2026 00:11:14 +0100 Subject: [PATCH 3/4] scripts: reboot series, prefetch of the KAR file and model shard (cold buffered reads run at ~30 MB/s on this NVMe), START_CYCLE Co-Authored-By: Claude Sonnet 5.5 --- scripts/e2e/decode/baseline-install.sh | 2 +- scripts/e2e/decode/baseline-prefetch.py | 40 ++++++++++++++++++++ scripts/e2e/decode/baseline-reboot-series.sh | 12 ++++-- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 scripts/e2e/decode/baseline-prefetch.py diff --git a/scripts/e2e/decode/baseline-install.sh b/scripts/e2e/decode/baseline-install.sh index ea52b1a2..8c1c5055 100644 --- a/scripts/e2e/decode/baseline-install.sh +++ b/scripts/e2e/decode/baseline-install.sh @@ -10,7 +10,7 @@ D=/data/leleka-e2e/decode/dt SRC=$(cd "$(dirname "$0")" && pwd) mkdir -p "$BP/tools" chmod -R u+w "$BP/tools" 2>/dev/null || true -for f in baseline-pair-ab.sh baseline-sampler.py ts-wrap.sh cycle-hook.sh; do install -m 0444 "$SRC/$f" "$BP/tools/$f"; done +for f in baseline-pair-ab.sh baseline-sampler.py ts-wrap.sh cycle-hook.sh baseline-prefetch.py; do install -m 0444 "$SRC/$f" "$BP/tools/$f"; done chmod a-w "$BP/tools" ENG=$(ls -d /home/para/.local/share/strata/components/engine/*/strata | head -1) { diff --git a/scripts/e2e/decode/baseline-prefetch.py b/scripts/e2e/decode/baseline-prefetch.py new file mode 100644 index 00000000..791891e7 --- /dev/null +++ b/scripts/e2e/decode/baseline-prefetch.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Pre-read files into the page cache with large asynchronous readahead (posix_fadvise WILLNEED, a sliding window 3 GiB ahead of the reader). Read-only. + python3 -I baseline-prefetch.py FILE_OR_DIR [...] (a directory = every regular file in it, largest first) +Why: after a reboot the page cache is cold and the server's NVMe serves the plain buffered 128 KiB-readahead pattern of the holder / loaders at only ~30 MB/s (r_await 4 ms, queue +depth 1; measured 2026-11-01: 31 GB of the 55 GB KAR file in 15 min), while the same file read with large or WILLNEED requests runs at ~600 MB/s. Without this a reboot cycle +costs about an hour of cold loading. The reads change no data; the page cache ends up in the state a normal run starts from (model files cached). +""" +import mmap, os, sys, time +W = 1 << 30 +AHEAD = 3 +def files(args): + for a in args: + if os.path.isdir(a): + fs = [os.path.join(a, f) for f in os.listdir(a) if os.path.isfile(os.path.join(a, f))] + for f in sorted(fs, key=os.path.getsize, reverse=True): + yield f + else: + yield a +for path in files(sys.argv[1:]): + size = os.path.getsize(path) + if size == 0: + continue + fd = os.open(path, os.O_RDONLY) + t0 = time.time() + for o in range(0, min(size, AHEAD * W), W): + os.posix_fadvise(fd, o, min(W, size - o), os.POSIX_FADV_WILLNEED) + off = 0 + while off < size: + n = min(W, size - off) + nxt = off + AHEAD * W + if nxt < size: + os.posix_fadvise(fd, nxt, min(W, size - nxt), os.POSIX_FADV_WILLNEED) + m = mmap.mmap(fd, n, prot=mmap.PROT_READ, offset=off) + for i in range(0, n, 1 << 20): + m[i] + m.close() + off += n + os.close(fd) + dt = time.time() - t0 + print("prefetch %s %.1f GiB in %.0f s (%.0f MB/s)" % (path, size / 2**30, dt, size / 1e6 / max(dt, 1e-6)), flush=True) diff --git a/scripts/e2e/decode/baseline-reboot-series.sh b/scripts/e2e/decode/baseline-reboot-series.sh index 8d0b82aa..6d5cc5dd 100644 --- a/scripts/e2e/decode/baseline-reboot-series.sh +++ b/scripts/e2e/decode/baseline-reboot-series.sh @@ -14,6 +14,7 @@ set -uo pipefail BLOCKS=${1:-"1 2 3 4 5 6"} SSH="ssh -o ConnectTimeout=6 -o BatchMode=yes rnr5090" OUTR=/data/leleka-e2e/runs/baseline-pair-e +PF=/data/leleka-e2e/baseline-pair/tools/baseline-prefetch.py JOBS='$HOME/work/gpu-runs/holder2/jobs' SERIES_LOG=${SERIES_LOG:-./baseline-reboot-series.log} STOPFILE=${STOPFILE:-./baseline-reboot-series.STOP} @@ -66,6 +67,7 @@ for b in $BLOCKS; do pos=0 for arm in $(perm "$b"); do pos=$((pos + 1)); cyc=$((cyc + 1)); tag=$(printf "b%02dp%d-%s" "$b" "$pos" "$arm") + [ $cyc -lt ${START_CYCLE:-1} ] && continue # resume after a stopped series [ -e "$STOPFILE" ] && die "stop file present before $tag" tries=0 while :; do @@ -87,14 +89,18 @@ for b in $BLOCKS; do done log "safety net: $net" [ $ok = 1 ] || die "safety net check failed after boot ($net)" + # cold page cache + this NVMe = ~30 MB/s for buffered reads (measured); pre-read the KAR file with large WILLNEED requests (~600 MB/s) before the holder reads it + $SSH "python3 -I $PF /home/para/work/leleka/models/leleka-gates/assets/qwen-iq3-s-l2-v4.kar" 2>&1 | while read -r l; do log "prefetch: $l"; done # KAR holder, as after the boot of 2026-10-29 (notes.md): stale empty MODEL.lock removed, ONE holder started, READY rewritten - $SSH 'pgrep -f kar_holder2 >/dev/null && echo HOLDER_ALREADY_RUNNING; rm -f '"$JOBS"'/READY; [ -d $HOME/work/gpu-runs/MODEL.lock ] && { rmdir $HOME/work/gpu-runs/MODEL.lock || echo MODEL_LOCK_NOT_EMPTY; } - cd $HOME/work/gpu-runs/holder2 && { setsid nohup bash run_holder2.sh >> holder2.out 2>&1 < /dev/null & } ; sleep 1; pgrep -f kar_holder2 | head -1 >/dev/null; echo started' | while read -r l; do log "holder: $l"; done - for _ in $(seq 1 90); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done + $SSH 'pgrep -f "[k]ar_holder2" >/dev/null && echo HOLDER_ALREADY_RUNNING; rm -f '"$JOBS"'/READY; [ -d $HOME/work/gpu-runs/MODEL.lock ] && { rmdir $HOME/work/gpu-runs/MODEL.lock || echo MODEL_LOCK_NOT_EMPTY; } + cd $HOME/work/gpu-runs/holder2 && { setsid nohup bash run_holder2.sh >> holder2.out 2>&1 < /dev/null & } ; sleep 1; echo started' | while read -r l; do log "holder: $l"; done + for _ in $(seq 1 150); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done $SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 15 min" log "holder READY: $($SSH 'cat '"$JOBS"'/READY; echo " uptime_s=$(cut -d" " -f1 /proc/uptime)"')" f=$(foreign | grep -v '^proc:' | tr '\n' ' ') if [ -n "${f// /}" ]; then log "foreign work appeared after boot ($f): waiting for it, then redoing the reboot for a fresh state"; wait_quiet; continue; fi + # same page-cache state for every arm: the model shard that holds the experts, the MTP files, the vanilla pack + $SSH "python3 -I $PF /home/para/work/leleka/models/leleka-gates/assets/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf \$HOME/.local/share/strata/Strata-data/mtp \$HOME/.local/share/strata/Strata-data/packs/iq3_s" 2>&1 | while read -r l; do log "prefetch: $l"; done stub="bpe-$(printf '%02d' $cyc)" $SSH "mkdir -p $OUTR; cat > $JOBS/$stub.sh < Date: Mon, 2 Nov 2026 01:27:05 +0100 Subject: [PATCH 4/4] baseline-pair part e: reboot-per-run series stopped after cycle 1 (cold-read cost), fresh-boot vanilla finding, owner readahead script Co-Authored-By: Claude Sonnet 5.5 --- docs/experiments/baseline-pair-5090.md | 22 ++++++++++++++++++++ scripts/e2e/decode/baseline-prefetch.py | 20 ++++++++++++++++++ scripts/e2e/decode/baseline-reboot-series.sh | 6 +++--- scripts/e2e/decode/owner-readahead.sh | 17 +++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 scripts/e2e/decode/owner-readahead.sh diff --git a/docs/experiments/baseline-pair-5090.md b/docs/experiments/baseline-pair-5090.md index 5578c0e0..6d6f19cc 100644 --- a/docs/experiments/baseline-pair-5090.md +++ b/docs/experiments/baseline-pair-5090.md @@ -151,3 +151,25 @@ Caveats of part d: the first build of this binary came from a CRLF checkout and ## 8. Reproduce `scripts/e2e/decode/baseline-install.sh` (on the server) installs the tools; stubs `bp-a.sh`, `bp-b2.sh`, `bp-c.sh`, `bp-d2.sh` in `~/work/gpu-runs/holder2/jobs/` hold the environment of each part (`BLOCKS`, `SEQ`, `OUTR`, `BINDIR`, `SUBST_V1`). Analysis: `baseline-analyze.py`, `baseline-turns.py`, `baseline-compact.py`, `baseline-pred.py` (outputs in `/data/leleka-e2e/baseline-pair/analysis/`). Data: `/data/leleka-e2e/runs/baseline-pair{,-b,-c,-d}//` (`long-session.json`, `client.ts.log`, `engine.log` or `inference.log`, `pre/state/post.jsonl`, `startup.txt`, `VALIDITY.txt`). + +## 9. Part e: one arm per fresh boot (owner-authorised reboots, 2026-11-01/02): STOPPED after cycle 1, cost problem + +Driver: `scripts/e2e/decode/baseline-reboot-series.sh` (runs on the laptop; per cycle: wait until no foreign job, `sync`, `sudo -n systemctl reboot`, wait for a new boot id, check the safety net, pre-read the KAR file, restart the holder the way `notes.md` did after the boot of 2026-10-29, pre-read the model shard / MTP / pack, queue one holder job with `ENTRIES`, wait for it). Arms: ours = `dt/bin-main-ffd9322` (main d29e3dba2 has the same code outside docs/scripts), PCIe 0.45 pinned, defaults; v1; v2. Per run the job also writes `hook.txt` (boot id and time, uptime at the hook, rescue sshd :2222, `/dev/watchdog0`, `hung_task_panic`, swap, NVMe dmesg hits, holder pid and READY time, buddyinfo) next to the usual `pre/state/post.jsonl`. + +What happened (M): + +* Safety net after every boot checked: rescue sshd on :2222 up, `/dev/watchdog0` present, `kernel.hung_task_panic=1`, swap off, no NVMe timeout / reset / abort / error line in dmesg. Boots took 253-255 s to ssh, no hang, no rescue needed. +* **A cold start is dominated by reading the 55 GB KAR file into the holder memfd.** The holder reads with plain buffered `read()`: on this NVMe that runs at 8-35 MB/s (iostat r_await 4-15 ms, 112-128 KiB requests, queue depth 1-2): 2003.8 s (33 min) for the first holder after the first reboot. The same drive does 600 MB/s with 32 MiB `O_DIRECT` reads and 0.6-2.4 GB/s with `posix_fadvise(WILLNEED)` readahead. The pre-read (`baseline-prefetch.py`) helped in one cycle (holder READY about 8 min after start) and not in the next (the unread tail of the file was not resident; holder still at 8-25 MB/s after 26 minutes); I did not find out why. +* Cycle durations: cycle 1 (reboot, pre-read, holder, run) 25 min; cycle 2 more than 45 min and stopped by my own 15-minute holder timeout (raised to 90 min). At that pace 18 cycles take 10-14 h, so I stopped the series after cycle 1 and did not resume it. +* Owner option (not done by me, it is a runtime sysfs setting): `scripts/e2e/decode/owner-readahead.sh set 4096` raises the device readahead from 128 KiB; expected to bring holder and model loads down to minutes, which would make a cycle about 15 min. Resume with `START_CYCLE=2 bash scripts/e2e/decode/baseline-reboot-series.sh "1 2 3 4 5 6"` on the laptop after it (the stop file is `baseline-reboot-series.STOP`). + +Results so far (only ours ran on fresh boots): + +| run | boot age at start | tok/s T1..T5 | all-turn | tok/round | ms/round | state | +| --- | ---: | --- | ---: | ---: | ---: | --- | +| pilot (pipeline test, `runs/baseline-pair-e-pilot/b00p1-ours`) | 0.6 h | 157.7 153.9 178.0 148.8 150.7 | 157.8 | 2.16 | 13.70 | valid | +| cycle 1 (`runs/baseline-pair-e/b01p1-ours`) | 0.3 h | 159.9 151.1 173.8 151.7 148.9 | 157.1 | 2.15 | 13.71 | valid, hook.txt in the run dir | + +Ours on a fresh boot is 157.1-157.8 against 155.6 (sd 1.6, n=6) at 42-44 h uptime in part d: boot state moves ours by about 1 %, inside its own spread. The vanilla arms, which are the ones that depend on the boot state (section 5), have not been run on fresh boots, so the question "is fresh-boot vanilla in its good state (arena THP >= 46.4 GiB)" is **not answered here**: on the fresh boots the free memory in 2 MiB+ blocks was recorded in `pre.jsonl` / `hook.txt` but no vanilla launch followed. Cycle 2's boot was not used. + +**One vanilla run on a fresh boot (`runs/baseline-pair-e/b01p2-v1`, boot age 0.74 h, same boot as cycle 1, holder up, model shard pre-read; the cycle-2 slot, not a clean cycle):** valid, **130.6 tok/s** (113.9 147.9 138.1 125.9 127.4; 1.84 tokens/round, 14.13 ms/round). Its engine log says "expert arena: ... transparent huge pages NOT requested: only 0 GiB of free 2 MiB blocks for a 46 GiB arena": vanilla checks the free 2 MiB blocks before asking for huge pages, and with the holder's 55 GB memfd plus the page cache that the KAR read and the pre-read leave behind (Cached 115 GB, MemFree 10 GB, buddyinfo order 9+ about 8 GiB) there were none. AnonHugePages of the process was 0 (Rss 65.7 GiB), the worst vanilla state seen in 36 runs. So **fresh-boot vanilla is not in its good state when the holder has just been loaded**: a fresh boot is not an unfragmented machine, it is a machine whose RAM is full of page cache. This also reads back on the partial-coverage class of section 5: that class is vanilla's own guard (huge pages only where free 2 MiB blocks exist) meeting the page-cache and 4 KiB-page footprint an ours run leaves behind, not a defect of the launch. I did not test dropping the cache of the KAR file after the holder load (a read-only `posix_fadvise(DONTNEED)` on that one file would be the obvious next step) and did not run vanilla on a boot without the pre-read. diff --git a/scripts/e2e/decode/baseline-prefetch.py b/scripts/e2e/decode/baseline-prefetch.py index 791891e7..ea506ff6 100644 --- a/scripts/e2e/decode/baseline-prefetch.py +++ b/scripts/e2e/decode/baseline-prefetch.py @@ -8,6 +8,26 @@ costs about an hour of cold loading. The reads change no data; the page cache en import mmap, os, sys, time W = 1 << 30 AHEAD = 3 + +def shmem_bytes(): + for ln in open("/proc/meminfo"): + if ln.startswith("Shmem:"): + return int(ln.split()[1]) * 1024 + return 0 + +if sys.argv[1] == "--follow": + # --follow FILE READYFILE : the holder reads FILE sequentially into a memfd (Shmem grows with its position); keep 8 GiB of FILE ahead of that position in the page cache until + # READYFILE exists. Needed because the pages read ahead by a plain pre-read are partly evicted again before the holder gets to them. + path, ready = sys.argv[2], sys.argv[3] + size = os.path.getsize(path); fd = os.open(path, os.O_RDONLY); base = shmem_bytes(); t0 = time.time() + while not (os.path.exists(ready) and os.path.getsize(ready) > 0) and time.time() - t0 < 3600: + cur = max(0, shmem_bytes() - base) + lo = max(0, cur - (64 << 20)); hi = min(size, cur + (8 << 30)) + if hi > lo: + os.posix_fadvise(fd, lo, hi - lo, os.POSIX_FADV_WILLNEED) + time.sleep(0.5) + print("follow %s done after %.0f s" % (path, time.time() - t0), flush=True) + sys.exit(0) def files(args): for a in args: if os.path.isdir(a): diff --git a/scripts/e2e/decode/baseline-reboot-series.sh b/scripts/e2e/decode/baseline-reboot-series.sh index 6d5cc5dd..eb431bca 100644 --- a/scripts/e2e/decode/baseline-reboot-series.sh +++ b/scripts/e2e/decode/baseline-reboot-series.sh @@ -2,7 +2,7 @@ # baseline-pair part e: ONE ARM PER FRESH BOOT. Runs on the LAPTOP (git bash), drives rnr5090 over ssh. Owner-authorised (chat, 2026-11-01): rebooting rnr5090 between runs. # Allowed on the server: `sudo -n systemctl reboot` and nothing else privileged (no systemd units, sysctl, grub; sudo -n dmesg is read-only). # -# bash baseline-reboot-series.sh [BLOCKS="1 2 3 4 5 6"] env: SERIES_LOG (local log), STOPFILE (touch it to stop after the current cycle) +# [START_CYCLE=2] bash baseline-reboot-series.sh [BLOCKS="1 2 3 4 5 6"] env: SERIES_LOG (local log), STOPFILE (touch it to stop after the current cycle), START_CYCLE (resume) # # Per cycle: (1) nothing foreign may run (jobs pending/running other than our stubs, gpu.lock, a GPU process); wait otherwise, never reboot under a job; # (2) `sync`, reboot, wait for ssh (new boot_id) up to 10 min; on timeout try the rescue sshd (:2222, `rboot`) once, then STOP; (3) safety net check (rescue sshd :2222, /dev/watchdog0, @@ -94,8 +94,8 @@ for b in $BLOCKS; do # KAR holder, as after the boot of 2026-10-29 (notes.md): stale empty MODEL.lock removed, ONE holder started, READY rewritten $SSH 'pgrep -f "[k]ar_holder2" >/dev/null && echo HOLDER_ALREADY_RUNNING; rm -f '"$JOBS"'/READY; [ -d $HOME/work/gpu-runs/MODEL.lock ] && { rmdir $HOME/work/gpu-runs/MODEL.lock || echo MODEL_LOCK_NOT_EMPTY; } cd $HOME/work/gpu-runs/holder2 && { setsid nohup bash run_holder2.sh >> holder2.out 2>&1 < /dev/null & } ; sleep 1; echo started' | while read -r l; do log "holder: $l"; done - for _ in $(seq 1 150); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done - $SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 15 min" + for _ in $(seq 1 480); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done + $SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 90 min" log "holder READY: $($SSH 'cat '"$JOBS"'/READY; echo " uptime_s=$(cut -d" " -f1 /proc/uptime)"')" f=$(foreign | grep -v '^proc:' | tr '\n' ' ') if [ -n "${f// /}" ]; then log "foreign work appeared after boot ($f): waiting for it, then redoing the reboot for a fresh state"; wait_quiet; continue; fi diff --git a/scripts/e2e/decode/owner-readahead.sh b/scripts/e2e/decode/owner-readahead.sh new file mode 100644 index 00000000..117b7e9d --- /dev/null +++ b/scripts/e2e/decode/owner-readahead.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# OWNER-RUN (root), NOT run by agents. Runtime-only, reversible (lost at the next boot). claude/baseline-pair part e, 2026-11-02. +# Finding (M): after a reboot the page cache is cold and the NVMe (Lexar NM610PRO, /dev/nvme0n1) serves the buffered 128 KiB readahead pattern of the KAR holder and of the model +# loaders at 8-35 MB/s (iostat: r_await 4-15 ms, queue depth 1-2, 112-128 KiB requests; the holder needed 33 min to read the 55 GB KAR file), while 32 MiB O_DIRECT reads of the same +# file run at ~600 MB/s and WILLNEED readahead at 0.6-2.4 GB/s when it sticks. read_ahead_kb is 128 (mq-deadline scheduler, none for nvme). A reboot-per-run series therefore costs 40-60 min a run. +# Raising the device readahead is expected to bring the holder load and the model loads to a few minutes. It changes no data. +# +# sudo bash owner-readahead.sh show # print the current value (default action) +# sudo bash owner-readahead.sh set 4096 # runtime only; 2048-8192 are reasonable +# sudo bash owner-readahead.sh reset # back to 128 +dev=/sys/block/nvme0n1/queue/read_ahead_kb +case "${1:-show}" in + show) echo "read_ahead_kb=$(cat $dev)";; + set) echo "${2:?usage: set KB}" > $dev; echo "read_ahead_kb=$(cat $dev)";; + reset) echo 128 > $dev; echo "read_ahead_kb=$(cat $dev)";; + *) echo "usage: show | set KB | reset" >&2; exit 2;; +esac