#!/usr/bin/env bash # 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 # the order IS the repeat order; default ARMS below # # 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 OUTROOT=/data/leleka-e2e/runs/parity-audit 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" got=0 for _ in $(seq 1 1080); do if mkdir "$LOCK" 2>/dev/null; then echo "parity-audit $tag $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi sleep 5 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 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 export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=32212254720 export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p 0" export E2E_SAMPLE_S=10 LELEKA_CHAIN=all export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP case $arm in pa-base) ;; pa-pcie35) export LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.35 ;; pa-pcie40) export LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.40 ;; pa-notrace) unset LELEKA_BRINGUP_TRACE LELEKA_PREFIX_TRACE ;; pa-dres100) export LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=100 ;; pa-gather) export STRATA_IQ_GATHER=1 ;; pa-lto) : "${LTO_BIN:?pa-lto needs LTO_BIN=}"; export E2E_BIN=$LTO_BIN ;; *) echo "unknown arm $arm" >&2; exit 2 ;; esac { 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, VALID runs only, and the per-turn mean difference of every arm against the pa-base runs python3 -I - "$OUTROOT" <<'PY' import glob, json, os, statistics, sys root = sys.argv[1] runs = {} for d in sorted(glob.glob(os.path.join(root, "*"))): 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(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