Rewrite the 5090 server model paths in 30 repo files (scripts, tools, docs) from the old locations (/home/para/leleka-gates, $HOME/leleka-gates, /data/models) to /home/para/work/leleka/models/..., add the AGENTS.md workspace rule and the move record docs/experiments/models-move.md. Not merged: the smoke test is pending. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
222 lines
14 KiB
Bash
222 lines
14 KiB
Bash
#!/usr/bin/env bash
|
|
# STRA-245 draft-tail: paired 5-turn ~245k session of ours, seed OFF, claude/speed-train (bin-speedtrain) against claude/draft-tail (bin-drafttail), same harness, same frozen
|
|
# corpus, alternating arms, three repeats each (and, optionally, vanilla Strata 0.2.6 in the same session).
|
|
# HOLDER JOB (run on rnr5090 under the holder, like speedtrain-ab.sh, which this is a copy of). Install:
|
|
# cp scripts/e2e/decode/drafttail-ab.sh /data/leleka-e2e/decode/dt/jobs/drafttail-ab.sh
|
|
# queue stub (~/work/gpu-runs/holder2/jobs/drafttail-ab.sh): #!/usr/bin/env bash / exec bash /data/leleka-e2e/decode/dt/jobs/drafttail-ab.sh (+ one line in jobs/PRIORITY)
|
|
# It takes /data/leleka-e2e/gpu.lock per arm (one arm at a time) and skips an arm when something else uses the GPU. ~12 min an arm, 6 arms by default (~75 min).
|
|
#
|
|
# ARMS="speedtrain-noseed drafttail-noseed speedtrain-noseed drafttail-noseed speedtrain-noseed drafttail-noseed" bash drafttail-ab.sh # the order IS the repeat order; this is the default
|
|
# ARMS="speedtrain-noseed drafttail-noseed drafttail-ac-noseed v-def ..." bash drafttail-ab.sh # attribution arm and vanilla, on request
|
|
#
|
|
# Arms (all seed OFF, upstream ranked profile, sm120 switches at their defaults (off), no experimental placement setting):
|
|
# speedtrain-noseed binaries dt/bin-speedtrain (claude/speed-train 47d2d389), the reference: the arm that measured 134.9 tok/s against vanilla's 135.4 in speedtrain-ab
|
|
# drafttail-noseed binaries dt/bin-drafttail (claude/draft-tail): the draft stream no longer waits for the commit event, per-round checks over the whole token history
|
|
# examine only the appended tokens, a decode token reads its PLE rows on one thread when the archive is in memory, persistent PLE scatter staging buffers
|
|
# drafttail-ac-noseed the same binaries with LELEKA_SERVE_DRAFT_AFTER_COMMIT=on (the draft waits for the commit event again): attributes the largest single change
|
|
# v-def vanilla Strata 0.2.6 from ~/work/vanilla-strata, `launch --model iq3_s --context 256k --kv int8`, defaults (same harness: dt/tools/long-session.py)
|
|
# Workload (the only valid one): the FROZEN corpus /data/leleka-e2e/decode/corpus/src/crates (MANIFEST.txt), 5 turns, target 245000 tokens, --max-output 300.
|
|
# Validity per run (VALIDITY.txt): no turn failed, 5 turns, final-turn input tokens >= 200000; for the ours arms also turn 5 PLE: the mean DBG window ple of the last request
|
|
# must be below 5 ms. An INVALID run is never used in a comparison.
|
|
# Metric: per-turn decode_tok_s of the client; per-turn mean over the repeats of an arm and the paired difference of each adjacent (reference, candidate) pair, never a single run.
|
|
# Both ours arms run the harness with LELEKA_SERVE_PROFILE=1 and the bring-up traces on (the per-round ms budget below comes from their DBG lines); vanilla runs untraced.
|
|
# Quality is NOT decided here: the generated text of a thinking turn is empty in long-session.json (reply_sha256 e3b0c442...); use drafttail-id.sh (teacher-forced replay, logprob identity).
|
|
set -uo pipefail
|
|
D=/data/leleka-e2e/decode/dt
|
|
LOCK=/data/leleka-e2e/gpu.lock
|
|
OUTR=/data/leleka-e2e/runs/draft-tail-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
|
|
ARMS=${ARMS:-"speedtrain-noseed drafttail-noseed speedtrain-noseed drafttail-noseed speedtrain-noseed drafttail-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-speedtrain/leleka-inference" "$D/bin-drafttail/leleka-inference" "$CORPUS/backend-api/src/lib.rs" \
|
|
"$HOME/work/vanilla-strata/control/bin/strata" "$HOME/.config/strata/settings.json"; 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-speedtrain E2E_OUT=$OUTR/$tag
|
|
case $arm in drafttail-*) E2E_BIN=$D/bin-drafttail ;; esac
|
|
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
|
|
unset 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
|
|
export LELEKA_ORIGINAL_SERVE_SEED=off
|
|
case $arm in
|
|
speedtrain-noseed | drafttail-noseed) ;;
|
|
drafttail-ac-noseed) export LELEKA_SERVE_DRAFT_AFTER_COMMIT=on ;;
|
|
*) echo "unknown ours 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 "$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)" )
|
|
}
|
|
|
|
vanilla() { # $1 tag
|
|
local tag=$1
|
|
local R=$OUTR/$tag; mkdir -p "$R"
|
|
( export XDG_CONFIG_HOME=$R/xdg-config XDG_STATE_HOME=$R/xdg-state
|
|
mkdir -p "$XDG_CONFIG_HOME/strata" "$XDG_STATE_HOME"
|
|
cp ~/.config/strata/settings.json "$XDG_CONFIG_HOME/strata/"
|
|
{ echo "arm=v-def tag=$tag"; date -u +%FT%TZ; free -g | sed -n 2p; head -1 /data/leleka-e2e/decode/corpus/MANIFEST.txt; env | grep -E '^(STRATA_|LELEKA_)' | sort; } > "$R/env.txt"
|
|
( 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 > "$R/memsample.txt" 2>/dev/null ) & SAMP=$!
|
|
S=$HOME/work/vanilla-strata/control/bin/strata
|
|
cd "$HOME/work/vanilla-strata/control"
|
|
T0=$(date +%s)
|
|
timeout 2400 $S launch --model iq3_s --family qwen --model-path /home/para/work/leleka/models/leleka-gates/assets/model --context 256k --kv int8 --vision off --parallel 1 --tune skip --access local --port 8090 --no-api-key --no-tui --yes > "$R/launch.out" 2>&1
|
|
echo "launch_rc=$? ready_wall_s=$(( $(date +%s) - T0 ))" >> "$R/env.txt"
|
|
if curl -fs http://127.0.0.1:8090/v1/models > "$R/models.json"; then
|
|
( while true; do echo "$(date +%T),$(nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,power.draw,clocks.sm,memory.used --format=csv,noheader)" >> "$R/mon.csv"; sleep 5; done ) & MON=$!
|
|
MODEL=$(python3 -c "import json;print(json.load(open('$R/models.json'))['data'][0]['id'])")
|
|
E2E_BASE_URL=http://127.0.0.1:8090 E2E_MODEL=$MODEL E2E_API_KEY=none E2E_OUT_DIR=$R python3 -I $D/tools/long-session.py --src $CORPUS $SESSION_ARGS > "$R/client.log" 2>&1
|
|
echo "session_rc=$?" >> "$R/env.txt"
|
|
kill $MON 2>/dev/null
|
|
cp "$XDG_STATE_HOME/strata/launch/iq3_s-256k.engine.log" "$R/engine.log"
|
|
else
|
|
echo "not ready" >> "$R/env.txt"
|
|
fi
|
|
$S launch --stop >> "$R/launch.out" 2>&1
|
|
sleep 8
|
|
kill $SAMP 2>/dev/null
|
|
date -u +%FT%TZ >> "$R/env.txt"
|
|
cut -c1-300 "$R/client.log" 2>/dev/null )
|
|
}
|
|
|
|
validity() { # $1 run dir, $2 arm kind (ours|vanilla)
|
|
python3 -I - "$1" "$2" <<'PY'
|
|
import json, os, re, sys
|
|
d, kind = sys.argv[1], sys.argv[2]
|
|
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
|
|
if kind == "ours":
|
|
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"
|
|
got=0
|
|
for _ in $(seq 1 1080); do
|
|
if mkdir "$LOCK" 2>/dev/null; then echo "draft-tail-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
|
|
v-def) vanilla "$tag"; kind=vanilla ;;
|
|
speedtrain-noseed|drafttail-noseed|drafttail-ac-noseed) ours "$tag" "$arm"; kind=ours ;;
|
|
*) echo "unknown arm $arm" >&2; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; exit 2 ;;
|
|
esac
|
|
validity "$OUTR/$tag" $kind
|
|
echo "arm done $tag $(date -u +%FT%TZ)"
|
|
rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null
|
|
sleep 15
|
|
done
|
|
|
|
# summary: decode tok/s per turn per VALID run, the per-turn mean of the repeats of each arm, each arm against the reference (per turn and over turns 1-5), adjacent pairs, and the per-round host budget of the ours arms
|
|
python3 -I - "$OUTR" <<'PY'
|
|
import glob, json, os, re, statistics, sys
|
|
root = sys.argv[1]
|
|
REF = "speedtrain-noseed"
|
|
def run_number(path):
|
|
tail = path.rsplit("-r", 1)[-1]
|
|
return int(tail) if tail.isdigit() else 0
|
|
runs, order = {}, []
|
|
for d in sorted(glob.glob(os.path.join(root, "*")), key=run_number):
|
|
v = os.path.join(d, "VALIDITY.txt")
|
|
if not os.path.exists(v) or not open(v).read().startswith("VALID"):
|
|
print(os.path.basename(d), "not used:", open(v).read().strip() if os.path.exists(v) else "no VALIDITY.txt")
|
|
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]
|
|
order.append(os.path.basename(d))
|
|
for k in order:
|
|
print(k, " ".join("%.1f" % x for x in runs[k]), "mean %.1f" % statistics.mean(runs[k]))
|
|
by = {}
|
|
for k in order:
|
|
by.setdefault(k.rsplit("-r", 1)[0], []).append(runs[k])
|
|
mean = {a: [statistics.mean(c) for c in zip(*vs)] for a, vs in by.items()}
|
|
for a, m in sorted(mean.items()):
|
|
print("%s (%d runs) per-turn mean: %s all-turn mean %.1f" % (a, len(by[a]), " ".join("%.1f" % x for x in m), statistics.mean(m)))
|
|
for base in (REF, "v-def"):
|
|
if base in mean:
|
|
for a, m in sorted(mean.items()):
|
|
if a != base:
|
|
print("%s minus %s per turn: %s mean %+.1f tok/s (%+.2f %%)" % (a, base, " ".join("%+.1f" % (x - y) for x, y in zip(m, mean[base])),
|
|
statistics.mean(m) - statistics.mean(mean[base]), 100 * (statistics.mean(m) / statistics.mean(mean[base]) - 1)))
|
|
# adjacent pairs (reference, candidate) in run order: the paired difference removes slow drift of the machine
|
|
for c in [a for a in by if a not in (REF, "v-def")]:
|
|
diffs = []
|
|
for i, k in enumerate(order[:-1]):
|
|
n = order[i + 1]
|
|
if k.rsplit("-r", 1)[0] == REF and n.rsplit("-r", 1)[0] == c:
|
|
diffs.append(100 * (statistics.mean(runs[n]) / statistics.mean(runs[k]) - 1))
|
|
if diffs:
|
|
print("%s over %s, adjacent pairs, all-turn mean tok/s: %s %% mean %+.2f %% (min %+.2f max %+.2f)" % (c, REF, " ".join("%+.2f" % x for x in diffs), statistics.mean(diffs), min(diffs), max(diffs)))
|
|
# the per-round host budget (ms per round, mean over the turns' requests) of the ours arms, from the DBG profile lines
|
|
KEYS = ["round.apply_pending", "round.run_window", "round.draft_committed", "draft.launch", "round.adapt_deferred", "commit.wait", "commit.publish", "draft.finish",
|
|
"mtp.finish_first_step", "mtp.chain_step", "round.finish", "round.verify_commit", "window.ple", "ple.read_rows", "ple.device", "window.history"]
|
|
print("per-round budget, ms per round (chain_step per call); columns: " + " ".join(k for k in KEYS) + " | sampling_setup (windows 20+)")
|
|
for k in order:
|
|
log = os.path.join(root, k, "inference.log")
|
|
if not os.path.exists(log):
|
|
continue
|
|
reqs, prof, wins, last = [], None, [], []
|
|
for ln in open(log, errors="replace"):
|
|
if ln.startswith("DBG profile request:"):
|
|
prof = {m[0]: (float(m[1].split("/")[0]), int(m[1].split("/")[1])) for m in re.findall(r"(\S+?)=([\d.]+/\d+)", ln)}
|
|
elif ln.startswith("DBG window "):
|
|
last.append(dict((a, float(b)) for a, b in re.findall(r"(\w+)=([-\d.]+)", ln)))
|
|
elif "leleka-serve request outcome" in ln:
|
|
m = re.search(r"rounds=(\d+)", ln)
|
|
if prof and m:
|
|
reqs.append((int(m.group(1)), prof))
|
|
wins.append(last); last = []
|
|
if not reqs:
|
|
continue
|
|
row = []
|
|
for key in KEYS:
|
|
vals = [(p[key][0] / (p[key][1] if key.endswith("chain_step") else r)) for r, p in reqs if key in p and p[key][1]]
|
|
row.append("%.3f" % statistics.mean(vals) if vals else "-")
|
|
ss = [statistics.mean(x.get("sampling_setup", 0) for x in w[20:]) for w in wins if len(w) > 20]
|
|
print("%-28s %s | %.3f" % (k, " ".join(row), statistics.mean(ss) if ss else float("nan")))
|
|
PY
|