Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
182 lines
11 KiB
Bash
182 lines
11 KiB
Bash
#!/usr/bin/env bash
|
|
# claude/slots-footprint2: paired, interleaved 5-turn ~245k session (seed OFF, frozen corpus, upstream ranked profile, auto expert slots) of ONE binary (dt/bin-footprint2, code 1a993970)
|
|
# with and without its footprint change, so that the only variable is the change itself:
|
|
# fp2-base-noseed LELEKA_FOOTPRINT_LEGACY=1: the pinned MTP pack's expert bank (675 MiB) next to the RT-directory copy and the 12 eager QSA index-key mirrors (384 MiB) are
|
|
# held as on main (221801b3): the baseline
|
|
# fp2-new-noseed defaults: neither is held; the auto expert cache grows by the freed VRAM (placement CLASS change, not bit-identical per se; bit-identity at an equal slot
|
|
# count is the job footprint2-id.sh)
|
|
# fp2-alias-noseed (optional, on request) new + LELEKA_PROMPT_EMBED_ALIAS=1: the prompt-path token table (324 MiB) aliased onto the native embedding's host mapping, as vanilla
|
|
# Everything else is identical: bin-footprint2, E2E_GPU_BUDGET 31,299 MiB (the product profile), EXPERT_SLOTS=auto, prefix cache auto/reply, capacity 8192, chain=all, same corpus.
|
|
# HOLDER JOB (rnr5090). Install: cp scripts/e2e/decode/footprint2-ab.sh /data/leleka-e2e/decode/dt/jobs/footprint2-ab.sh ; stub ~/work/gpu-runs/holder2/jobs/footprint2-ab.sh
|
|
# (#!/usr/bin/env bash / exec bash /data/leleka-e2e/decode/dt/jobs/footprint2-ab.sh) ; one line in jobs/PRIORITY. It takes /data/leleka-e2e/gpu.lock per arm. ~12 min an arm.
|
|
# ARMS="fp2-base-noseed fp2-new-noseed fp2-new-noseed fp2-base-noseed fp2-base-noseed fp2-new-noseed" bash footprint2-ab.sh # the default: 3 pairs, order alternated; pair k = runs 2k-1, 2k
|
|
# Validity per run (VALIDITY.txt): no turn failed, 5 turns, final-turn input tokens >= 200000, turn-5 mean window.ple < 5 ms. An INVALID run is never used in a comparison.
|
|
# Reported per run and per arm: decode tok/s per turn, tokens/round (output tokens / rounds of the request), ms/round (decode wall time / rounds) and the dt_agg ms/round
|
|
# (verify_commit + finish), expert slots ("expert cache N slots"), the lowest free VRAM seen. Vanilla is not run here and no parity with it is claimed.
|
|
set -uo pipefail
|
|
D=/data/leleka-e2e/decode/dt
|
|
LOCK=/data/leleka-e2e/gpu.lock
|
|
OUTR=/data/leleka-e2e/runs/footprint2-ab
|
|
CORPUS=/data/leleka-e2e/decode/corpus/src/crates
|
|
UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin # ranked upstream profile; run-e2e.sh refuses any other digest
|
|
RUN_TAG=${RUN_TAG:-} # suffix of the run directories (a rerun next to earlier ones)
|
|
ARMS=${ARMS:-"fp2-base-noseed fp2-new-noseed fp2-new-noseed fp2-base-noseed fp2-base-noseed fp2-new-noseed"}
|
|
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-footprint2/leleka-inference" "$CORPUS/backend-api/src/lib.rs"; do
|
|
[ -r "$f" ] || { echo "missing $f" >&2; exit 3; }
|
|
done
|
|
|
|
ours() { # $1 tag, $2 arm
|
|
local tag=$1 arm=$2
|
|
( export E2E_BIN=$D/bin-footprint2 E2E_OUT=$OUTR/$tag
|
|
mkdir -p "$E2E_OUT"
|
|
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1
|
|
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800}
|
|
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
|
|
unset LELEKA_FOOTPRINT_LEGACY LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_PERF LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB
|
|
export LELEKA_ORIGINAL_SERVE_SEED=off
|
|
case $arm in
|
|
fp2-base-noseed) export LELEKA_FOOTPRINT_LEGACY=1 ;;
|
|
fp2-new-noseed) ;;
|
|
fp2-alias-noseed) export LELEKA_PROMPT_EMBED_ALIAS=1 ;;
|
|
*) echo "unknown ours arm $arm" >&2; exit 2 ;;
|
|
esac
|
|
{ echo "arm=$arm tag=$tag"; date -u +%FT%TZ; free -g | sed -n 2p; uptime; sha256sum "$UP" "$E2E_BIN"/leleka-inference "$E2E_BIN"/leleka-daemon "$E2E_BIN"/leleka-cli "$E2E_BIN"/strata-next
|
|
cat "$E2E_BIN/COMMIT.txt" 2>/dev/null; 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"
|
|
( while sleep 5; do echo "$(date +%T) $(grep -E "SwapFree|MemAvailable|^Cached|Shmem:|Dirty" /proc/meminfo | tr -s " " | tr "
|
|
" " ") $(head -1 /proc/pressure/io) $(head -1 /proc/pressure/memory) $(awk "/pswpin|pgmajfault/{printf \"%s=%s \",\$1,\$2}" /proc/vmstat)"; done > "$E2E_OUT/memsample.txt" 2>/dev/null ) & SAMP=$!
|
|
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
|
|
kill $SAMP 2>/dev/null
|
|
echo "run-e2e done $tag $(date -u +%FT%TZ)" )
|
|
}
|
|
|
|
validity() { # $1 run dir
|
|
python3 -I - "$1" <<'PY'
|
|
import json, os, re, 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
|
|
wins, last = [], []
|
|
for ln in open(os.path.join(d, "inference.log"), errors="replace"):
|
|
if ln.startswith("DBG window "):
|
|
last.append(dict((k, float(v)) for k, v in re.findall(r"(\w+)=([-\d.]+)", ln)))
|
|
elif "leleka-serve request outcome" in ln:
|
|
wins.append(last); last = []
|
|
w = wins[-1] if wins else []
|
|
ple = sum(x.get("ple", 0) for x in w) / max(len(w), 1)
|
|
verdict += "; turn-5 window.ple mean %.2f ms over %d windows" % (ple, len(w))
|
|
if not w:
|
|
verdict = "INVALID: no turn-5 window lines (trace env missing?)"
|
|
elif ple >= 5:
|
|
verdict = "INVALID: turn-5 window.ple mean %.2f ms >= 5 ms (PLE scan back?)" % ple
|
|
open(os.path.join(d, "VALIDITY.txt"), "w").write(verdict + "\n")
|
|
print(os.path.basename(d), verdict)
|
|
PY
|
|
}
|
|
|
|
n=0
|
|
for arm in $ARMS; do
|
|
n=$((n + 1)); tag="$arm-r$n$RUN_TAG"
|
|
got=0
|
|
for _ in $(seq 1 1080); do
|
|
if mkdir "$LOCK" 2>/dev/null; then echo "footprint2-ab $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
|
|
case $arm in
|
|
fp2-base-noseed|fp2-new-noseed|fp2-alias-noseed) ours "$tag" "$arm" ;;
|
|
*) echo "unknown arm $arm" >&2; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; exit 2 ;;
|
|
esac
|
|
validity "$OUTR/$tag"
|
|
echo "arm done $tag $(date -u +%FT%TZ)"
|
|
rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null
|
|
sleep 15
|
|
done
|
|
|
|
# summary: per run and per arm, then the adjacent pairs (run numbers 2k-1 and 2k, one base and one candidate, in whatever order)
|
|
python3 -I - "$OUTR" <<'PY'
|
|
import glob, json, os, re, statistics, sys
|
|
root = sys.argv[1]
|
|
def run_number(path):
|
|
tail = path.rsplit("-r", 1)[-1]
|
|
tail = re.sub(r"\D+$", "", tail)
|
|
return int(tail) if tail.isdigit() else 0
|
|
def load(d):
|
|
sess = json.load(open(os.path.join(d, "long-session.json")))
|
|
reqs, prof = [], None
|
|
slots, lowest = None, None
|
|
for ln in open(os.path.join(d, "inference.log"), errors="replace"):
|
|
if ln.startswith("DBG profile request:"):
|
|
prof = {m[0]: float(m[1].split("/")[0]) for m in re.findall(r"(\S+?)=([\d.]+/\d+)", ln)}
|
|
elif "leleka-serve request outcome" in ln:
|
|
m = re.search(r"produced=(\d+) rounds=(\d+)", ln)
|
|
reqs.append((int(m.group(1)), int(m.group(2)), prof)); prof = None
|
|
elif "leleka-serve expert cache" in ln and slots is None:
|
|
slots = int(re.search(r"expert cache (\d+) slots", ln).group(1))
|
|
m = re.search(r"DBG vram .*lowest note so far (\d+) MiB", ln)
|
|
if m:
|
|
lowest = int(m.group(1)) if lowest is None else min(lowest, int(m.group(1)))
|
|
rows = []
|
|
for i, t in enumerate(sess):
|
|
produced, rounds, p = reqs[i] if i < len(reqs) else (0, 0, None)
|
|
tps = t.get("decode_tok_s") or 0.0
|
|
out = t.get("output_tokens") or produced
|
|
agg = float("nan")
|
|
if p and rounds and "round.verify_commit" in p and "round.finish" in p:
|
|
agg = (p["round.verify_commit"] + p["round.finish"]) / rounds
|
|
rows.append(dict(tps=tps, tok_round=(produced / rounds if rounds else float("nan")),
|
|
ms_round=(1000.0 * out / tps / rounds if rounds and tps else float("nan")), ms_agg=agg))
|
|
return rows, slots, lowest
|
|
def arm(n): return re.sub(r"-r\d+.*$", "", n)
|
|
runs = {}
|
|
for d in sorted(glob.glob(os.path.join(root, "*-r[0-9]*")), key=run_number):
|
|
name = os.path.basename(d)
|
|
v = os.path.join(d, "VALIDITY.txt")
|
|
if not os.path.exists(v) or not open(v).read().startswith("VALID"):
|
|
print(name, "not used:", open(v).read().strip() if os.path.exists(v) else "no VALIDITY.txt")
|
|
continue
|
|
runs[name] = load(d)
|
|
for n, (rows, slots, lowest) in runs.items():
|
|
print("%-26s slots %s lowest-free-VRAM %s MiB | tok/s %s | tok/round %s | ms/round %s | ms/round(dt_agg) %s" % (n, slots, lowest,
|
|
" ".join("%.1f" % r["tps"] for r in rows), " ".join("%.2f" % r["tok_round"] for r in rows),
|
|
" ".join("%.2f" % r["ms_round"] for r in rows), " ".join("%.2f" % r["ms_agg"] for r in rows)))
|
|
by = {}
|
|
for n in runs: by.setdefault(arm(n), []).append(n)
|
|
for a, ns in sorted(by.items()):
|
|
allrows = [runs[n][0] for n in ns]
|
|
mean = lambda f: [statistics.mean(f(r[t]) for r in allrows) for t in range(5)]
|
|
print("ARM %s (%d runs, slots %s): tok/s per turn %s all-turn %.1f | tokens/round %s | ms/round %s" % (a, len(ns), sorted({runs[n][1] for n in ns}),
|
|
" ".join("%.1f" % x for x in mean(lambda r: r["tps"])), statistics.mean(mean(lambda r: r["tps"])),
|
|
" ".join("%.2f" % x for x in mean(lambda r: r["tok_round"])), " ".join("%.2f" % x for x in mean(lambda r: r["ms_round"]))))
|
|
for cand in [a for a in by if a != "fp2-base-noseed"]:
|
|
diffs, per_turn = [], []
|
|
for k in range(1, 40):
|
|
pair = [n for n in runs if (run_number(n) + 1) // 2 == k]
|
|
b = [n for n in pair if arm(n) == "fp2-base-noseed"]; c = [n for n in pair if arm(n) == cand]
|
|
if len(b) == 1 and len(c) == 1:
|
|
rb, rc = runs[b[0]][0], runs[c[0]][0]
|
|
mb, mc = statistics.mean(x["tps"] for x in rb), statistics.mean(x["tps"] for x in rc)
|
|
diffs.append(100 * (mc / mb - 1)); per_turn.append([100 * (y["tps"] / x["tps"] - 1) for x, y in zip(rb, rc)])
|
|
print("pair %d %s vs base: all-turn tok/s %.1f vs %.1f (%+.2f %%), slots %s vs %s" % (k, cand, mc, mb, diffs[-1], runs[c[0]][1], runs[b[0]][1]))
|
|
if diffs:
|
|
print("%s over fp2-base-noseed: %d pairs, mean %+.2f %% (min %+.2f max %+.2f); per-turn mean %s" % (cand, len(diffs), statistics.mean(diffs), min(diffs), max(diffs),
|
|
" ".join("%+.2f" % statistics.mean(c[t] for c in per_turn) for t in range(5))))
|
|
PY
|