diff --git a/scripts/e2e/decode/ram-inventory.sh b/scripts/e2e/decode/ram-inventory.sh index f0b00a19..6feeaa6f 100644 Binary files a/scripts/e2e/decode/ram-inventory.sh and b/scripts/e2e/decode/ram-inventory.sh differ diff --git a/scripts/e2e/decode/single-copy-holder.py b/scripts/e2e/decode/single-copy-holder.py new file mode 100644 index 00000000..3a458cf4 --- /dev/null +++ b/scripts/e2e/decode/single-copy-holder.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Lab holder, v3: the same queue protocol as ~/work/gpu-runs/holder/kar_holder2.py, but the sealed memfd is NOT filled here. + +`single-copy-holder.sh` runs `leleka seal-exec --file ARCHIVE -- python3 single-copy-holder.py {FD} JOBS`: the Rust sealer copies the archive with large +O_DIRECT blocks on many threads (docs: unattended "fast cold load"; 600 MB/s and up against 8-35 MB/s for a buffered 16 MiB read loop on this NVMe) and never +leaves the 55 GB in the page cache, which kar_holder2.py's buffered read does (a second copy of the archive in RAM, ~50 GB, until something evicts it). +This process only inherits the descriptor and runs the job scripts exactly as kar_holder2.py does: + + * queue: names listed in JOBS/PRIORITY (top first), then the oldest *.sh first; the queue is re-read after every job; files younger than 3 s are skipped; + * a job runs as `bash JOB` with LELEKA_STRA169_KAR_FD= and the fd passed; JOB.running while it runs, JOB.done (rc) after; + * JOBS/STOP (checked between jobs) ends the holder; JOBS/READY holds the fd number. +""" +import glob, os, subprocess, sys, time + +fd = int(sys.argv[1]) +jobs = sys.argv[2] +st = os.fstat(fd) +print(f"holder3 ready fd={fd} bytes={st.st_size} allocated={st.st_blocks * 512}", flush=True) +open(os.path.join(jobs, "READY"), "w").write(str(fd)) + + +def pending(): + out = [] + for job in glob.glob(os.path.join(jobs, "*.sh")): + base = job[:-3] + if os.path.exists(base + ".done") or os.path.exists(base + ".running"): + continue + try: + if time.time() - os.path.getmtime(job) < 3: + continue + out.append((os.path.getmtime(job), job)) + except OSError: + pass + return out + + +def pick(): + p = pending() + if not p: + return None + try: + prio = [l.strip() for l in open(os.path.join(jobs, "PRIORITY")) if l.strip() and not l.startswith("#")] + except OSError: + prio = [] + byname = {os.path.basename(j)[:-3]: j for _, j in p} + for name in prio: + if name in byname: + return byname[name] + return min(p)[1] + + +while not os.path.exists(os.path.join(jobs, "STOP")): + job = pick() + if job is None: + time.sleep(2) + continue + base = job[:-3] + open(base + ".running", "w").close() + env = dict(os.environ, LELEKA_STRA169_KAR_FD=str(fd)) + with open(base + ".log", "wb") as log: + rc = subprocess.run(["bash", job], stdout=log, stderr=subprocess.STDOUT, env=env, pass_fds=[fd]).returncode + os.remove(base + ".running") + open(base + ".done", "w").write(str(rc)) diff --git a/scripts/e2e/decode/single-copy-holder.sh b/scripts/e2e/decode/single-copy-holder.sh new file mode 100644 index 00000000..dc36ff57 --- /dev/null +++ b/scripts/e2e/decode/single-copy-holder.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Start the lab holder with the fast, page-cache-free seal (see single-copy-holder.py). Same MODEL.lock contract as run_holder2.sh. +# single-copy-holder.sh [BIN_DIR] BIN_DIR holds `leleka` (default /data/leleka-e2e/decode/dt/bin-singlecopy) +# Run it detached: cd ~/work/gpu-runs/holder2 && rm -f jobs/STOP && setsid nohup bash /data/leleka-e2e/single-copy/tools/single-copy-holder.sh > holder3.out 2>&1 & +set -u +BIN=${1:-/data/leleka-e2e/decode/dt/bin-singlecopy} +T=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +KAR=/home/para/work/leleka/models/leleka-gates/assets/qwen-iq3-s-l2-v4.kar +JOBS=$HOME/work/gpu-runs/holder2/jobs +until mkdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null; do sleep 20; done +trap 'rmdir "$HOME/work/gpu-runs/MODEL.lock"' EXIT +cd "$HOME/work/gpu-runs/holder2" || exit 1 +rm -f "$JOBS/READY" +exec_start=$(date +%s) +"$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS" +echo "holder3 ended rc=$? after $(( $(date +%s) - exec_start )) s"