Files
Pavlo RatushnyiandClaude Sonnet 5.5 dcf6e8bf5a window-policy: replay-arm policy options, floor options (default off), A/B and replay tools, harness ATTN_DAILY_MTP default, deploy env test
- AdaptiveConfig::set_option and the LELEKA_SPEC_ARMS suffix ~key=value (adaptive@0~step=0.3): policy variants inside one replay process on the same forced text
- options rowq / smooth / measured for the draft floor rule (defaults reproduce the earlier rule exactly, unit test against the kept reference)
- windowpolicy-replay.sh, -ab.sh (three arms), -analyze.py, -id.sh, -install.sh
- run-e2e.sh: LELEKA_SM120_ATTN_DAILY_MTP defaults to 1 like the rtx5090-32g profile
- deploy: the profile's engine_env reaches engine_environment() through the saved config (test)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 20:39:34 +01:00

88 lines
6.1 KiB
Bash

#!/usr/bin/env bash
# window-policy identity gate: teacher-forced replay of the 256k-class capture night5-long-256k (5 requests, recorded replies, decode capped at MAX_NEW forced tokens
# each), production shape WITH THE ADAPTIVE WINDOW (the draft-round gate ran a fixed window, LELEKA_SPEC=4, whose widths cannot move), top-16 logprobs of every row, seed OFF,
# ONE test binary (dt/$ID_BIN) for all processes, one process per setting, two arms in each (I1 I2: the A/A floor). HOLDER JOB (copy of draftround-id.sh).
# The window policy picks the widths from measured times, so two runs cut their windows differently; q_pair keys a row by (request, position, the window's inputs up to the row),
# i.e. it compares the rows whose context is the same whatever the window around them was, and the A/A floor (I2 against I1 of one process, adaptive on both) says how much of a
# difference is the run-to-run width noise alone. What is compared: the top-16 logprob rows (ids and IEEE logprobs as printed) of the common rows, and the argmax of each.
# ID_BIN test binary directory name under /data/leleka-e2e/decode/dt (required)
# P1_ENV extra env of the reference process (default: nothing)
# P2_ENV extra env of the changed process (required)
# P3_ENV, P4_ENV optional third and fourth process
# ID_OUT output directory (required) MAX_NEW (default 240) ADAPT (default 4: the adaptive tier swaps, as dt-id2)
# SKIP_P1=1 reuse $ID_OUT/idP1.full of an earlier job (same binary, same environment) as the reference instead of running it again
# ~10 GPU-min a process. Verdict: q_pair (top-16 logprob rows of the common rows: identical or not, read against the A/A floor) and q_tail_gate.
set -uo pipefail
LOCK=/data/leleka-e2e/gpu.lock
D=/data/leleka-e2e/decode/dt
DR=/data/leleka-e2e/draft-round
WP=/data/leleka-e2e/window-policy
O=${ID_OUT:?ID_OUT}
ID_BIN=${ID_BIN:?ID_BIN}
MAX_NEW=${MAX_NEW:-240}
ADAPT=${ADAPT:-4}
mkdir -p "$O"
( cd / && sha256sum --quiet -c "$DR/MANIFEST.sha256" ) || { echo "draft-round: MANIFEST.sha256 check failed" >&2; exit 3; }
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/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=30
export LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.45
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=8000 LELEKA_CHAIN=all
export LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=$ADAPT LELEKA_ORIGINAL_SERVE_SEED=off
unset LELEKA_SPEC LELEKA_SPEC_ADAPTIVE LELEKA_SPEC_SUFFIX LELEKA_SPEC_POLICY
unset LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_FOOTPRINT_LEGACY LELEKA_SM120_ATTN_DAILY_MTP LELEKA_DRAFT_FUSED_COMMIT LELEKA_DRAFT_ROUND
for f in $D/$ID_BIN $D/tools/q_pair.py $D/tools/q_tail_gate.py $DR/tools/draftround-idcmp.py $CAP/night5-long-256k; do
[ -e "$f" ] || { echo "missing $f" >&2; exit 3; }
done
sha256sum $D/$ID_BIN | tee $O/rt.sha256
shape="reply@8192/8192!orig!fast!nocluster!store!qpf!gpool!mspan"
run() { # label extra-env
got=0
for i in $(seq 1 1080); do
if mkdir $LOCK 2>/dev/null; then echo "window-policy identity $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 extra=[$2] MemAvailable GiB: $avail"
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 $2 LELEKA_SPEC_STATS=1 LELEKA_SPEC_TRACE=1 LELEKA_ORIGINAL_SERVE_REPLAY=yes 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=$MAX_NEW LELEKA_REPLAY_FORCE=1 LELEKA_REPLAY_ARMS="I1=$shape,I2=$shape" \
nice -n 5 $D/$ID_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" $O/$1.full | cut -c1-200 | tail -14
grep -a -c "^DBG spec-trace" $O/$1.full
rm -f $LOCK/owner; rmdir $LOCK 2>/dev/null
sleep 15
}
if [ "${SKIP_P1:-0}" = 1 ]; then [ -s "$O/idP1.full" ] || { echo "SKIP_P1 set but $O/idP1.full is missing" >&2; exit 3; }; else run idP1 "${P1_ENV:-LELEKA_X=1}"; fi
run idP2 "${P2_ENV:?P2_ENV}"
PROCS="idP1 idP2"
if [ -n "${P3_ENV:-}" ]; then run idP3 "$P3_ENV"; PROCS="idP1 idP2 idP3"; fi
if [ -n "${P4_ENV:-}" ]; then run idP4 "$P4_ENV"; PROCS="$PROCS idP4"; fi
T=$D/tools
for p in $PROCS; do echo "== q_tail_gate $p"; python3 $T/q_tail_gate.py $O/$p.full $CAP/night5-long-256k 2>&1 | tail -8; done
python3 - <<PY
import sys
sys.path.insert(0, "$T")
import q_pair
procs = "$PROCS".split()
rows = {p: [q_pair.rows_of("$O/%s.full" % p, i) for i in (0, 1)] for p in procs}
q_pair.compare(rows["idP1"][0], rows["idP1"][1], "reference process, arm I2 against arm I1 (A/A noise floor)")
for p in procs[1:]:
q_pair.compare(rows[p][0], rows[p][1], p + ", arm I2 against arm I1 (A/A)")
q_pair.compare(rows["idP1"][0], rows[p][0], p + " against the reference, arm I1")
q_pair.compare(rows["idP1"][1], rows[p][1], p + " against the reference, arm I2")
PY
# (the draft trace of draft-round is not compared here: a policy with another chain floor drafts other tokens by design)
sha256sum $O/*.full
date -u +%FT%TZ