scripts: parity A/B job on the frozen corpus with the long-session guard, VALID/INVALID verdict per arm, experimental placement arms

Uses /data/leleka-e2e/decode/corpus/src/crates (the old leleka-head corpus is gone and gives a ~300-token session), the guarded long-session.py
(--min-final-tokens 200000), re-checks final-turn input tokens >= 200000 and marks an arm INVALID otherwise; all comparisons are ours against ours on the same corpus.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-10-29 01:42:24 +01:00
co-authored by Claude Sonnet 5.5
parent 82fca1f691
commit 49be10eaa5
+77 -30
View File
@@ -1,29 +1,38 @@
#!/usr/bin/env bash
# STRA-245 parity audit (docs/experiments/parity-audit-5090.md): paired settings A/B on the 5-turn 245k Codex-shaped session of the 5090 decode gap.
# One arm = one engine start (load ~9 min) + the session (~2 min). It is a HOLDER JOB: run it through the holder queue (it needs the sealed KAR memfd
# fd and MODEL.lock exactly like run-e2e.sh), after the DEV decode-tail dt-profile-ab arms. It takes /data/leleka-e2e/gpu.lock per arm, never two arms at once.
# STRA-245 parity audit (docs/experiments/parity-audit-5090.md): paired settings A/B, ours against ours, on the 5-turn 245k Codex-shaped session of the 5090 decode gap.
# HOLDER JOB. Queue stub: ~/work/gpu-runs/holder2/jobs/parity-audit-ab.sh = `exec bash /data/leleka-e2e/parity-audit/jobs/parity-audit-ab.sh`, entry LAST in jobs/PRIORITY
# (after dt-ab3, dt-profile-ab, sm120-replay-id, sm120-e2e-ab). It needs the sealed KAR memfd fd of the holder exactly like run-e2e.sh; no second holder is ever started.
# It takes /data/leleka-e2e/gpu.lock per arm (one arm at a time) and skips an arm when something else uses the GPU.
#
# ARMS="pa-base pa-pcie35 pa-base pa-pcie35 pa-base pa-pcie35" bash parity-audit-ab.sh # interleaved pairs, 3 repeats (the order IS the repeat order)
# ARMS="pa-base pa-pcie35 pa-base pa-pcie35 pa-base pa-pcie35" bash parity-audit-ab.sh # the order IS the repeat order; default ARMS below
#
# Every arm starts from the SAME base as s1-decode/o-def (pinned bin-e2e4, shipped-shape env) EXCEPT that the expert profile is the ranked upstream one
# (the run-e2e.sh default is a placeholder, see the DEV decode-tail note of 2026-10-29T00:07Z). Only the listed variable changes per arm.
# pa-base reference: upstream profile, trace env as o-def (BRINGUP_TRACE, PREFIX_TRACE)
# pa-pcie35 LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.35 vanilla 0.2.6 PcieAuto settles at 0.35 on this machine (v-def-t, v-nsk-prof engine logs); ours is a fixed 0.45
# pa-pcie40 LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.40
# pa-notrace no LELEKA_BRINGUP_TRACE / LELEKA_PREFIX_TRACE (run-e2e.sh still exports LELEKA_SERVE_PROFILE=1; span timing only)
# pa-dres100 LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=100 (ours leaves 563 MiB free at decode, vanilla 315-389; about +100 expert slots)
# pa-gather STRATA_IQ_GATHER=1 (AVX-512 grid gathers in the CPU IQ kernels; upstream default is ON only on Intel server cores; same words, same results)
# pa-lto E2E_BIN=$LTO_BIN (a build with `cargo build --profile release-lto`, directory with the four binaries; required for this arm)
# Lossless class: pa-notrace, pa-lto, pa-gather are bitwise/no placement change; pa-pcie*, pa-dres100 move which device computes an expert or how many
# are resident (placement class, "unknown-until-q_pair" in docs/experiments/2026-10-28-s6-1-lossy-audit.md): a quality result (q_tail_gate) is required
# before either becomes a default.
# Metric: per-turn decode_tok_s of the client (long-session.json), same prompts per turn index; compare means of the repeats per turn, never a single run.
# Workload (the only valid one): the FROZEN corpus /data/leleka-e2e/decode/corpus/src/crates (MANIFEST.txt, sha256 1152f45a...), 5 turns, target 245000 tokens, --max-output 300.
# The old ~/work/leleka-head corpus no longer exists: a run on it is a ~300-token session. Guards in this script: long-session.py is the DEV decode-tail guarded copy
# (refuses an empty corpus, exits 3 when the final turn has fewer than --min-final-tokens input tokens) and this script re-checks the final-turn input tokens >= 200000
# and "no error in any turn" from long-session.json and marks the arm INVALID otherwise. An INVALID arm is never used in a comparison.
# Base for every arm = ours, pinned bin-e2e4 (hardlinks of the DEV decode-tail copy), the shipped-shape env of s1-decode/o-def, the RANKED upstream expert profile
# (run-e2e.sh refuses any other digest). Comparisons are only between arms of this job (same corpus, same binary, same profile). One variable changes per arm:
# pa-base reference (trace env as o-def: BRINGUP_TRACE, PREFIX_TRACE)
# pa-pcie35 LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.35 vanilla 0.2.6 PcieAuto settles at 0.35 on this machine; ours is a fixed 0.45 EXPERIMENTAL, placement class
# pa-pcie40 LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.40 EXPERIMENTAL, placement class
# pa-dres100 LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=100 (ours leaves 563 MiB free at decode, vanilla 315-389; about +100 expert slots) EXPERIMENTAL, placement class
# pa-notrace no LELEKA_BRINGUP_TRACE / LELEKA_PREFIX_TRACE (run-e2e.sh still exports LELEKA_SERVE_PROFILE=1; span timing only) lossless
# pa-gather STRATA_IQ_GATHER=1 (AVX-512 grid gathers in the CPU IQ kernels; same words, same results) lossless
# pa-lto E2E_BIN=$LTO_BIN, a `cargo build --profile release-lto` build (only if one exists; none is built on the server) lossless
# Placement-class arms (PCIe share, decode reserve) change which device computes an expert or how many experts are resident. They are experimental flags: they stay OFF by
# default in every profile and in the engine until a q_tail_gate result exists for them (docs/experiments/2026-10-28-s6-1-lossy-audit.md, finding F4).
# Metric: per-turn decode_tok_s of the client (long-session.json), same prompts per turn index; compare per-turn means of the repeats, never a single run.
set -uo pipefail
D=/data/leleka-e2e/parity-audit
LOCK=/data/leleka-e2e/gpu.lock
ARMS=${ARMS:?set ARMS, e.g. "pa-base pa-pcie35 pa-base pa-pcie35 pa-base pa-pcie35"}
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin # sha256 8f59b4aa..., the file crates/deploy pins as EXPERT_PROFILE_SHA256
OUTROOT=/data/leleka-e2e/runs/parity-audit
[ -r "$UP" ] || { echo "missing $UP" >&2; exit 3; }
CORPUS=/data/leleka-e2e/decode/corpus/src/crates
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin # sha256 8f59b4aa..., the file crates/deploy pins as EXPERT_PROFILE_SHA256
ARMS=${ARMS:-"pa-base pa-pcie35 pa-base pa-pcie35 pa-base pa-pcie35 pa-notrace pa-base pa-dres100 pa-base pa-gather pa-base"}
SESSION_ARGS="--turns 5 --target-tokens 245000 --max-output 300 --min-final-tokens 200000"
for f in "$UP" "$D/tools/long-session.py" "$D/scripts/e2e/run-e2e.sh" "$D/bin-e2e4/leleka-inference" "$CORPUS/backend-api/src/lib.rs"; do
[ -r "$f" ] || { echo "missing $f" >&2; exit 3; }
done
n=0
for arm in $ARMS; do
n=$((n + 1)); tag="$arm-r$n"
@@ -34,7 +43,10 @@ for arm in $ARMS; do
done
[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; }
echo "=== $tag $(date -u +%FT%TZ)"; free -g | sed -n 2p
( export E2E_BIN=$HOME/work/leleka-rest/bin-e2e4
if [ -n "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader)" ]; then
echo "GPU busy, skipping $tag"; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; continue
fi
( export E2E_BIN=$D/bin-e2e4
export E2E_OUT=$OUTROOT/$tag
mkdir -p "$E2E_OUT"
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1
@@ -52,21 +64,56 @@ for arm in $ARMS; do
pa-lto) : "${LTO_BIN:?pa-lto needs LTO_BIN=<dir with leleka-inference leleka-daemon leleka-cli strata-next>}"; export E2E_BIN=$LTO_BIN ;;
*) echo "unknown arm $arm" >&2; exit 2 ;;
esac
{ echo "arm=$arm tag=$tag"; date -u +%FT%TZ; sha256sum "$UP" "$E2E_BIN/leleka-inference"; env | grep -E '^(LELEKA_|STRATA_|E2E_)' | sort; } >"$E2E_OUT/env-arm.txt"
export E2E_RUN_CMD="python3 -I $HOME/work/codex-e2e/long-session.py --src $HOME/work/leleka-head/src/crates --turns 5 --target-tokens 245000 --max-output 300"
bash "$HOME/work/leleka-e2e/scripts/e2e/run-e2e.sh" 2>&1 | grep -a -E "^\{|expert cache|PREFILL-PROFILE|request outcome|ready after|rc=|refus|error|Error" | cut -c1-400
{ echo "arm=$arm tag=$tag"; date -u +%FT%TZ; free -g | sed -n 2p; sha256sum "$UP" "$E2E_BIN/leleka-inference"; head -1 /data/leleka-e2e/decode/corpus/MANIFEST.txt
env | grep -E '^(LELEKA_|STRATA_|E2E_)' | sort; } >"$E2E_OUT/env-arm.txt"
export E2E_RUN_CMD="python3 -I $D/tools/long-session.py --src $CORPUS $SESSION_ARGS"
bash "$D/scripts/e2e/run-e2e.sh" 2>&1 | grep -a -E "^\{|expert cache|request outcome|ready after|rc=|refus|error|Error|long_session|client exit" | cut -c1-300
echo "run-e2e done $tag $(date -u +%FT%TZ)" )
# validity: the final turn must be a long prompt and no turn may have failed
python3 -I - "$OUTROOT/$tag" <<'PY'
import json, os, sys
d = sys.argv[1]
f = os.path.join(d, "long-session.json")
verdict = "INVALID: no long-session.json"
if os.path.exists(f):
t = json.load(open(f))
final = (t[-1].get("input_tokens") or 0) if t else 0
if any("error" in r for r in t):
verdict = "INVALID: a turn failed"
elif len(t) < 5 or final < 200000:
verdict = "INVALID: %d turns, final-turn input tokens %d < 200000 (short corpus?)" % (len(t), final)
else:
verdict = "VALID: 5 turns, final-turn input tokens %d" % final
open(os.path.join(d, "VALIDITY.txt"), "w").write(verdict + "\n")
print(os.path.basename(d), verdict)
PY
rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null
sleep 15
done
# summary: decode tok/s per turn per run
# summary: decode tok/s per turn per run, VALID runs only, and the per-turn mean difference of every arm against the pa-base runs
python3 -I - "$OUTROOT" <<'PY'
import json, sys, glob, os
import glob, json, os, statistics, sys
root = sys.argv[1]
runs = {}
for d in sorted(glob.glob(os.path.join(root, "*"))):
f = os.path.join(d, "long-session.json")
if not os.path.exists(f):
v = os.path.join(d, "VALIDITY.txt")
if not os.path.exists(v) or not open(v).read().startswith("VALID"):
continue
t = json.load(open(f))
print(os.path.basename(d), " ".join(f"{x.get('decode_tok_s', 0):.1f}" for x in t))
t = json.load(open(os.path.join(d, "long-session.json")))
runs[os.path.basename(d)] = [x.get("decode_tok_s") or 0.0 for x in t]
for k, v in runs.items():
print(k, " ".join("%.1f" % x for x in v), "mean %.1f" % statistics.mean(v))
by = {}
for k, v in runs.items():
by.setdefault(k.rsplit("-r", 1)[0], []).append(v)
base = by.get("pa-base")
if base:
bm = [statistics.mean(c) for c in zip(*base)]
for arm, vs in sorted(by.items()):
if arm == "pa-base":
continue
am = [statistics.mean(c) for c in zip(*vs)]
print("%s (%d runs) minus pa-base (%d runs), per turn: %s mean %+.1f tok/s (%+.1f %%)" % (
arm, len(vs), len(base), " ".join("%+.1f" % (a - b) for a, b in zip(am, bm)),
statistics.mean(am) - statistics.mean(bm), 100 * (statistics.mean(am) / statistics.mean(bm) - 1)))
PY