Files
leleka/scripts/e2e/decode/footprint3-gate.sh
T

80 lines
5.4 KiB
Bash

#!/usr/bin/env bash
# claude/slots-footprint3, goal (3): placement-class relative gate of the LARGER expert cache (main: 12,144 slots, + MTP dense sharing) against the previous 11,568 (LELEKA_FOOTPRINT_LEGACY=1), copy of dt-q4.sh.
# Teacher-forced replay of the 256k-class capture night5-long-256k (5 requests, recorded replies, decode capped at 240 tokens each => >= 1000 forced rows), production shape, STATIC tier
# (ADAPT_EVERY=0: the placement is reproducible), seed OFF, upstream ranked profile, EXPERT_SLOTS=auto with the card-bound budget (31 GiB), RT directory set (the product draft path), top-16 logprobs per row.
# ONE test binary (dt/rt-footprint3b) for the three processes:
# ref LELEKA_FOOTPRINT_LEGACY=1: the previous footprint (11,568 slots), arm 0 is the reference
# new defaults: the larger cache
# ph LELEKA_FOOTPRINT_LEGACY=1 with the PLACEHOLDER profile (layer-major, unranked): the CONTROL, a placement perturbation the earlier gates accepted as the yardstick
# Criterion (notes.md): rows >= 1000 in both comparisons, d_top1 p99 and max of new-vs-ref <= 1.5x those of control-vs-ref, argmax flips <= 2.8 %.
# Install: cp scripts/e2e/decode/footprint3-gate.sh /data/leleka-e2e/decode/dt/jobs/ ; stub ~/work/gpu-runs/holder2/jobs/footprint3-gate.sh (exec bash that file) ; one line in jobs/PRIORITY. ~40 GPU-min.
set -uo pipefail
LOCK=/data/leleka-e2e/gpu.lock
D=/data/leleka-e2e/decode/dt
O=/data/leleka-e2e/runs/footprint3-gate
BIN=${BIN:-$D/rt-footprint3b}
mkdir -p $O
export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-}
A=/home/para/work/leleka/models/leleka-gates/assets
G=$HOME/work/gpu-runs
CAP=/data/leleka-e2e/sm120/capture
export LELEKA_STRA169_KAR_PROVENANCE=$A/qwen-iq3-s-l2-v4.kar.provenance.json
export LELEKA_STRA169_IQ3S_SHARD0=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf
export LELEKA_STRA169_IQ3S_SHARD1=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf
export LELEKA_STRA169_MTP_PACK=$A/data/mtp-rt LELEKA_STRA169_MTP_STAGING=$G/mtp-staging-own LELEKA_ORIGINAL_SERVE_BUDGET_GIB=31
export LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.55
export LELEKA_SMOKE_PROMPT_CACHE=0 LELEKA_SERVE_PROFILE=1 LELEKA_GRAPH_EXEC_REUSE=off
export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin
export LELEKA_ORIGINAL_SERVE_RT_DIR=$A/data/mtp-rt
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto LELEKA_CHAIN=all
unset LELEKA_FOOTPRINT_LEGACY LELEKA_PROMPT_EMBED_ALIAS LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB
export LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0 LELEKA_ORIGINAL_SERVE_CPU_WORKERS=1 LELEKA_SPEC=4 LELEKA_SPEC_SUFFIX=0
sha256sum $BIN
shape="reply@8192/8192!orig!fast!nocluster!store!qpf!gpool!mspan"
run() { # label legacy(0|1) arms [profile]
PROFILE=${4:-/data/leleka-e2e/decode/assets/expert-profile-upstream.bin}
got=0
for i in $(seq 1 1080); do
if mkdir $LOCK 2>/dev/null; then echo "footprint3 gate $1 $(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)"; return 3; }
avail=$(awk '/MemAvailable/{print int($2/1048576)}' /proc/meminfo); echo "=== $1 legacy=$2 MemAvailable GiB: $avail"; free -g | sed -n 2,3p
if [ "$avail" -lt 60 ]; then echo "abort: less than 60 GiB available"; rm -f $LOCK/owner; rmdir $LOCK; return 4; fi
date -u +%FT%TZ
env LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$PROFILE LELEKA_ORIGINAL_SERVE_REPLAY=yes LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_FOOTPRINT_LEGACY=$2 LELEKA_BRINGUP_TRACE=1 LELEKA_REPLAY_DIR=$CAP/night5-long-256k LELEKA_PREFIX_TRACE=1 LELEKA_REPLAY_PREFIX_MIB=6000 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_LOGPROBS=16 \
LELEKA_REPLAY_MAX_NEW=240 LELEKA_REPLAY_FORCE=1 LELEKA_REPLAY_ARMS=$3 \
nice -n 5 $BIN --ignored --exact --test-threads=1 --nocapture backend::original_serve_replay::original_serve_replay_smoke > $O/$1.full 2>&1
echo "rc=$? label=$1"; date -u +%FT%TZ
grep -a -E "^REPLAY|test result|panicked|FAILED|expert cache [0-9]+ slots|footprint:" $O/$1.full | cut -c1-300 | tail -8
rm -f $LOCK/owner; rmdir $LOCK 2>/dev/null
sleep 15
}
shape1="$shape"
run ref 1 "G1=$shape1"
run new 0 "S1=$shape1"
run ph 1 "P1=$shape1" /data/leleka-e2e/decode/assets/profile-placeholder.bin
T=$D/tools
python3 - <<PY
import sys
sys.path.insert(0, "$T")
import q_pair, q_lib
off=q_pair.rows_of("$O/ref.full",0); on=q_pair.rows_of("$O/new.full",0); ph=q_pair.rows_of("$O/ph.full",0)
def stat(a,b,label):
common=sorted(set(a)&set(b)); d=[]; flips=0
for k in common:
if a[k].top1!=b[k].top1: flips+=1
v=b[k].lp(a[k].top1)
if v is not None and (a[k].topk[0][1]!=v): d.append(abs(a[k].topk[0][1]-v))
d.sort()
p99=q_lib.quantile(d,.99) if d else 0.0; mx=d[-1] if d else 0.0
print("%s: common %d, different %d, flips %d (%.2f%%), d_top1 p99 %.4f max %.4f"%(label,len(common),len(d),flips,100.0*flips/max(len(common),1),p99,mx))
return len(common),p99,mx,flips
c=stat(off,ph,"CONTROL placeholder placement (11,568 slots) vs upstream placement (11,568 slots)")
s=stat(off,on,"LARGER CACHE (new) vs previous (ref), upstream profile")
ok = s[0]>=1000 and c[0]>=1000 and s[1]<=1.5*c[1] and s[2]<=1.5*c[2] and s[3]/max(s[0],1)<=0.028
print("CRITERION (rows>=1000 both, p99 and max <= 1.5x control, flips <= 2.8%%):", "PASS" if ok else "FAIL/INCONCLUSIVE")
PY
sha256sum $O/*.full
date -u +%FT%TZ