swift15: gate flags per engine (--kld-ref takes no corpus; --kld-out JSON parsed)
This commit is contained in:
1 parent
8220030ba1
commit
3f8531179e
1 file changed
+37
-23
+37
-23
@@ -4,26 +4,24 @@
|
|||||||
# mean KL <= 0.03 AND top-1 agreement >= 95%.
|
# mean KL <= 0.03 AND top-1 agreement >= 95%.
|
||||||
# Same engine (1.0.13) and same boot shape as the reference RECORD
|
# Same engine (1.0.13) and same boot shape as the reference RECORD
|
||||||
# (run-swift15-bf16.sh kld): disk-tier, no speculation, deterministic, fp8 KV.
|
# (run-swift15-bf16.sh kld): disk-tier, no speculation, deterministic, fp8 KV.
|
||||||
# The engine compares its own logits against /data/kld-ref and prints the
|
# --kld-ref reads its tokens from the reference (no --kld-corpus here — the
|
||||||
# score table at exit. Gate failure exits 1 (escalation owner: recipe author);
|
# engine rejects the pair); --kld-out writes the JSON report, whose .rows
|
||||||
# the script never touches the production unit.
|
# carry every position's KL/top-1. Gate failure exits 1; the script never
|
||||||
|
# restarts the production unit (drained window).
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
PIN=sha256:4c3f484564bb2872784e46b0a59cbd71becc9c1e746e301a3596ffae253c322e
|
PIN=sha256:4c3f484564bb2872784e46b0a59cbd71becc9c1e746e301a3596ffae253c322e
|
||||||
RAD=/home/dank/models/rad/qwen4exp-swift15-w4dn8-i8-hc8m.rad
|
|
||||||
C=swift15gate
|
C=swift15gate
|
||||||
LOG=/home/dank/logs/swift15_kldgate.log
|
LOG=/home/dank/logs/swift15_kldgate.log
|
||||||
KLD_REF_DIR=/home/dank/corpora/kld-ref
|
KLD_REF_DIR=/home/dank/corpora/kld-ref
|
||||||
KLD_CORPUS=/home/dank/corpora/out/kld.jsonl
|
KLD_OUT=/home/dank/radiance-state/kld-gate.json
|
||||||
KL_MAX=0.03
|
|
||||||
TOP1_MIN=95.0
|
|
||||||
|
|
||||||
[ -d "$KLD_REF_DIR" ] || { echo "missing reference: $KLD_REF_DIR"; exit 2; }
|
[ -d "$KLD_REF_DIR" ] || { echo "missing reference: $KLD_REF_DIR"; exit 2; }
|
||||||
[ -f "$KLD_CORPUS" ] || { echo "missing corpus: $KLD_CORPUS"; exit 2; }
|
: > "$KLD_OUT"
|
||||||
|
|
||||||
cp -f /home/dank/serverAppConfigs/scripts/qwen38-froggeric-v22.5.jinja \
|
cp -f /home/dank/serverAppConfigs/scripts/qwen38-froggeric-v22.5.jinja \
|
||||||
/home/dank/models/tpl.jinja 2>/dev/null || true
|
/home/dank/models/tpl.jinja 2>/dev/null || true
|
||||||
sudo systemctl stop frank-primary >/dev/null 2>&1 || true
|
sudo systemctl stop frank-primary >/dev/null 2>&1 || true
|
||||||
podman rm -f "$C" >/dev/null 2>&1 || true
|
podman rm -f "$C" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
podman run --rm --name "$C" \
|
podman run --rm --name "$C" \
|
||||||
--network host --init \
|
--network host --init \
|
||||||
--security-opt seccomp=unconfined \
|
--security-opt seccomp=unconfined \
|
||||||
@@ -31,7 +29,6 @@ podman run --rm --name "$C" \
|
|||||||
--device /dev/kfd --device /dev/dri \
|
--device /dev/kfd --device /dev/dri \
|
||||||
-v /home/dank/models:/models:ro \
|
-v /home/dank/models:/models:ro \
|
||||||
-v /home/dank/radiance-state:/data \
|
-v /home/dank/radiance-state:/data \
|
||||||
-v "$KLD_CORPUS:/data/kld.jsonl:ro" \
|
|
||||||
-v "$KLD_REF_DIR:/data/kld-ref:ro" \
|
-v "$KLD_REF_DIR:/data/kld-ref:ro" \
|
||||||
"stilldeadcode/radiance@$PIN" \
|
"stilldeadcode/radiance@$PIN" \
|
||||||
--model /models/rad/qwen4exp-swift15-w4dn8-i8-hc8m.rad \
|
--model /models/rad/qwen4exp-swift15-w4dn8-i8-hc8m.rad \
|
||||||
@@ -41,32 +38,49 @@ podman run --rm --name "$C" \
|
|||||||
--kv-cache-dtype fp8 --max-model-len 16384 \
|
--kv-cache-dtype fp8 --max-model-len 16384 \
|
||||||
--ngram-placement ram \
|
--ngram-placement ram \
|
||||||
--override-chat-template /models/tpl.jinja \
|
--override-chat-template /models/tpl.jinja \
|
||||||
--kld-ref /data/kld-ref --kld-corpus /data/kld.jsonl \
|
--kld-ref /data/kld-ref --kld-out /data/kld-gate.json \
|
||||||
--vram-kv-mib 3072 \
|
--vram-kv-mib 3072 \
|
||||||
--max-num-seqs 4 --max-num-batched-tokens 32768 \
|
--max-num-seqs 4 --max-num-batched-tokens 32768 \
|
||||||
2>&1 | tee "$LOG"
|
2>&1 | tee "$LOG"
|
||||||
rc=${PIPESTATUS[0]}
|
rc=${PIPESTATUS[0]}
|
||||||
[ "$rc" -eq 0 ] || { echo "KLD GATE BOOT FAILED rc=$rc; log: $LOG"; exit "$rc"; }
|
[ "$rc" -eq 0 ] || { echo "KLD GATE BOOT FAILED rc=$rc; log: $LOG"; exit "$rc"; }
|
||||||
|
|
||||||
# Engine prints its score table on stdout (captured in $LOG). Pull the two
|
python3 - "$KLD_OUT" "$LOG" <<'PY'
|
||||||
# gate numbers; the summary line is "mean KL"/"top-1" in the radiance
|
import json, sys, re
|
||||||
# scorecard; fall back to any numeric KL/top1 lines.
|
out, log = sys.argv[1], sys.argv[2]
|
||||||
python3 - "$LOG" <<'PY'
|
|
||||||
import re, sys
|
|
||||||
log = open(sys.argv[1], errors="replace").read()
|
|
||||||
def num(pat):
|
def num(pat):
|
||||||
m = re.findall(pat, log, re.I)
|
m = re.findall(pat, open(log, errors="replace").read(), re.I)
|
||||||
return float(m[-1]) if m else None
|
return float(m[-1]) if m else None
|
||||||
kl = num(r"mean[_ ]kl[^0-9-]*([0-9]*\.?[0-9]+(?:e[-+][0-9]+)?)")
|
kl = top1 = None
|
||||||
top1 = num(r"top[-_ ]?1[^0-9]*([0-9]*\.?[0-9]+)")
|
try:
|
||||||
|
d = json.load(open(out))
|
||||||
|
def find(obj, keys):
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
for k, v in obj.items():
|
||||||
|
if any(s in k.lower() for s in keys) and isinstance(v, (int, float)):
|
||||||
|
return float(v)
|
||||||
|
for v in obj.values():
|
||||||
|
r = find(v, keys)
|
||||||
|
if r is not None: return r
|
||||||
|
return None
|
||||||
|
kl = find(d, ("mean_kl", "mean kl", "kl_mean", "mean"))
|
||||||
|
top1 = find(d, ("top1", "top_1", "top-1", "agreement"))
|
||||||
|
if top1 is not None and top1 <= 1.0:
|
||||||
|
top1 *= 100.0
|
||||||
|
except Exception as e:
|
||||||
|
print("report JSON unusable (%s); falling back to log" % e)
|
||||||
|
if kl is None:
|
||||||
|
kl = num(r"mean[_ ]kl[^0-9]*([0-9]*\.?[0-9]+(?:e[-+][0-9]+)?)")
|
||||||
|
if top1 is None:
|
||||||
|
top1 = num(r"top[-_ ]?1[^0-9]*([0-9]*\.?[0-9]+)")
|
||||||
if kl is None or top1 is None:
|
if kl is None or top1 is None:
|
||||||
print("KLD GATE PARSE FAILED: mean_kl=%s top1=%s — inspect %s" % (kl, top1, sys.argv[1]))
|
print("KLD GATE PARSE FAILED: mean_kl=%s top1=%s — inspect %s / %s" % (kl, top1, out, log))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
print("KLD GATE: mean KL = %.4f (max %.2f) | top-1 = %.2f%% (min %.1f)" % (kl, 0.03, top1, 95.0))
|
print("KLD GATE: mean KL = %.4f (max 0.03) | top-1 = %.2f%% (min 95.0)" % (kl, top1))
|
||||||
ok = (kl <= 0.03) and (top1 >= 95.0)
|
ok = (kl <= 0.03) and (top1 >= 95.0)
|
||||||
print("KLD GATE " + ("PASS" if ok else "FAIL"))
|
print("KLD GATE " + ("PASS" if ok else "FAIL"))
|
||||||
sys.exit(0 if ok else 1)
|
sys.exit(0 if ok else 1)
|
||||||
PY
|
PY
|
||||||
gate=$?
|
gate=$?
|
||||||
echo "kld-gate complete rc=$gate; log: $LOG"
|
echo "kld-gate complete rc=$gate; log: $LOG report: $KLD_OUT"
|
||||||
exit "$gate"
|
exit "$gate"
|
||||||
Reference in new issue
Block a user