test(quality): long-context retrieval check (100k/180k) with teacher forcing in the long smoke
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bd214d556f
commit
0ac97bf63a
@@ -480,7 +480,18 @@ fn original_serve_long_context_streamed_kv_smoke() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR (quality gate, docs/quality-gate.md): `answer<N>.ids` (comma-separated) holds the tokens
|
||||
// another engine answered to the N-token prompt; the request then decodes along that text (teacher forcing, see
|
||||
// `quality_force`) for exactly that many tokens, with the port's own logits and `LELEKA_TRACE_LOGPROBS` rows.
|
||||
let forced_answer: Option<Vec<i32>> = env::var_os("LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR").and_then(|dir| {
|
||||
let text = std::fs::read_to_string(PathBuf::from(dir).join(format!("answer{}.ids", prompt.len()))).ok()?;
|
||||
Some(text.trim().split(',').map(|t| t.trim().parse().expect("forced token id")).collect())
|
||||
});
|
||||
let max_new = forced_answer.as_ref().map_or(max_new, |a| a.len());
|
||||
for pass in 0..repeat {
|
||||
crate::qwen_forward::quality_force::set(forced_answer.as_ref().map(|answer| {
|
||||
prompt.iter().map(|&t| t as i32).chain(answer.iter().copied()).collect()
|
||||
}));
|
||||
let started = std::time::Instant::now();
|
||||
let mut tokens = Vec::new();
|
||||
let outcome = stack
|
||||
@@ -489,6 +500,7 @@ fn original_serve_long_context_streamed_kv_smoke() {
|
||||
Ok(())
|
||||
}, &mut || false)
|
||||
.unwrap_or_else(|e| panic!("long-context request failed: {e:?} health={:?}", stack.health()));
|
||||
crate::qwen_forward::quality_force::set(None);
|
||||
assert!(outcome.rounds >= 1 && !tokens.is_empty(), "no committed round");
|
||||
assert!(tokens.iter().all(|&t| (0..248_320).contains(&t)));
|
||||
assert_eq!(stack.health(), None);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: long-context retrieval (needle: "the secret passcode is 4817-QX") at 100k and 180k tokens on the unmodified Original, same token ids
|
||||
# as jobs 915/916 (long-180k/prompt{100000,180000}.ids). Phase 1: free greedy answer of 600 tokens per prompt (batched prefill chunk 8192, int8 KV
|
||||
# streamed, tier static). Phase 2 (new process): teacher-forced read of prompt + the first K<=100 answer tokens, the batched prompt then the answer
|
||||
# through the verify windows (--turn-token = the prompt's last token), top-16 logprobs per row. Also writes long-force/answer<N>.ids for the port.
|
||||
source ~/work/gpu-runs/quality/q-common.sh
|
||||
mem_ok 60 || { echo "abort: MemAvailable < 60 GiB"; exit 3; }
|
||||
header
|
||||
L=$G/long-180k; F=$Q/long-force; mkdir -p $F
|
||||
T=$(python3 -c "print(open('$L/prompt100000.ids').read().strip().split(',')[-1])")
|
||||
python3 - $L $Q/ret1.txt <<'PY'
|
||||
import sys
|
||||
L, out = sys.argv[1:3]
|
||||
open(out, "w").write("".join(f"GEN 600 {open(f'{L}/prompt{n}.ids').read().strip()}\n" for n in (100000, 180000)) + "QUIT\n")
|
||||
PY
|
||||
COMMON="--prefill 8192 --max-context 262144 --kv-resident 20480 --prompt-cache 1 --prompt-cache-root 0 --prompt-cache-every 0 --turn-token $T --short-read 128 --expert-cache 2048 --expert-cache-per-layer --adapt-every 0"
|
||||
orig_serve RET-orig-free $Q/ret1.txt $COMMON $(kar_args)
|
||||
python3 - $L $Q/runs/RET-orig-free/out.txt $T $F $Q/ret2.txt <<'PY'
|
||||
import sys
|
||||
L, out, T, F, req = sys.argv[1:6]; T = int(T)
|
||||
seqs, cur = [], []
|
||||
for line in open(out):
|
||||
if line.startswith("T "): cur.append(int(line.split()[1]))
|
||||
elif line.startswith("DONE"): seqs.append(cur); cur = []
|
||||
lines = []
|
||||
for n, ans in zip((100000, 180000), seqs):
|
||||
k = min(100, len(ans), next((j for j, x in enumerate(ans) if x == T), 10**9))
|
||||
open(f"{F}/answer{n}.ids", "w").write(",".join(map(str, ans[:k])))
|
||||
open(f"{F}/answer{n}.full", "w").write(",".join(map(str, ans)))
|
||||
print(n, "answer tokens", len(ans), "forced K", k)
|
||||
lines.append("GEN 1 " + open(f"{L}/prompt{n}.ids").read().strip() + "," + ",".join(map(str, ans[:k])))
|
||||
open(req, "w").write("\n".join(lines) + "\nQUIT\n")
|
||||
PY
|
||||
orig_serve RET-orig-read $Q/ret2.txt $COMMON $(kar_args)
|
||||
date -u +%FT%TZ
|
||||
@@ -0,0 +1,26 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: the port's long-context retrieval at 100k and 180k (same prompts as jobs 915/916), 600 new tokens, integrated defaults
|
||||
# (adaptive tier + prompt-routing seed), chunk 8192, windows traced (top-16). Then, if its first K tokens differ from the Original's (job 9964),
|
||||
# a second process teacher-forced along the Original's first K answer tokens.
|
||||
source ~/work/gpu-runs/quality/q-common.sh
|
||||
mem_ok 60 || { echo "abort: MemAvailable < 60 GiB"; exit 3; }
|
||||
header; sha256sum $BIN
|
||||
LONGENV="LELEKA_ORIGINAL_SERVE_LONG_TOKENS=100000,180000 LELEKA_ORIGINAL_SERVE_LONG_MAX_NEW=600 LELEKA_ORIGINAL_SERVE_MAX_CONTEXT=262144 LELEKA_ORIGINAL_SERVE_CAPACITY=8192"
|
||||
port_long RET-port-free $PORT_TIER $LONGENV
|
||||
python3 - $Q/runs/RET-port-free/port.log $Q/long-force > $Q/ret-port-diff.txt <<'PY'
|
||||
import re, sys
|
||||
log, F = sys.argv[1:3]
|
||||
outs = [[int(x) for x in m[1].split(",") if x] for m in (re.match(r"long-smoke output ids \(\d+\): ([0-9,]*)", l) for l in open(log, errors="replace")) if m]
|
||||
differ = False
|
||||
for n, o in zip((100000, 180000), outs):
|
||||
try: a = [int(x) for x in open(f"{F}/answer{n}.ids").read().split(",")]
|
||||
except OSError: print(n, "no Original answer yet"); differ = True; continue
|
||||
same = o[: len(a)] == a
|
||||
print(n, "port tokens", len(o), "first K", len(a), "identical" if same else "DIFFERENT"); differ |= not same
|
||||
print("FORCE" if differ else "SKIP")
|
||||
PY
|
||||
cat $Q/ret-port-diff.txt
|
||||
if tail -1 $Q/ret-port-diff.txt | grep -q FORCE; then
|
||||
port_long RET-port-forced $PORT_TIER $LONGENV LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR=$Q/long-force
|
||||
fi
|
||||
date -u +%FT%TZ
|
||||
@@ -36,7 +36,7 @@ kar_args() { echo "--ple-kar ${KAR_PATH:-/proc/self/fd/${LELEKA_STRA169_KAR_FD:-
|
||||
|
||||
# port_run LABEL [ENV=V ...]: the port's smoke corpus (6 prompts, 2 passes): pass 0 is teacher-forced along the Original's
|
||||
# pass-0 tokens ($Q/force/c<i>.truth), pass 1 is free; every window's top-16 logprobs are traced.
|
||||
BIN=${BIN:-$HOME/work/leleka-quality-bin/q-2}
|
||||
BIN=${BIN:-$HOME/work/leleka-quality-bin/q-3}
|
||||
port_env() {
|
||||
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
|
||||
@@ -72,3 +72,18 @@ port_long() {
|
||||
echo "rc=${PIPESTATUS[0]} port-long=$label"; date -u +%FT%TZ
|
||||
grep -a -E 'long-smoke (prefill|output ids)|test result|panicked' $d/port.log | cut -c1-200
|
||||
}
|
||||
|
||||
# orig_serve LABEL REQFILE ORIGINAL-FLAGS...: like orig_run with a ready request file (runs/LABEL/reqs.txt); same common flags.
|
||||
orig_serve() {
|
||||
local label=$1 reqs=$2; shift 2
|
||||
local d=$Q/runs/$label; rm -rf $d; mkdir -p $d; cp $reqs $d/reqs.txt
|
||||
echo "=== original $label: $*"; date -u +%FT%TZ
|
||||
STRATA_LOGPOS=$d/logpos STRATA_LOGPOS_TOPK=16 $ORIG_BIN \
|
||||
--pack $A/data/iq3_s --native $A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf \
|
||||
--ple-gguf $A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf \
|
||||
--serve --mtp $A/data/mtp-rt --kv int8 --spec 4 --suffix-draft 3 --spec-min-p 0.5 --expert-profile $PH --pcie-frac 0.55 \
|
||||
"$@" < $d/reqs.txt > $d/out.txt 2> $d/err.txt
|
||||
echo "rc=$? original=$label"; date -u +%FT%TZ
|
||||
grep -E "^DONE|^ERR" $d/out.txt | cut -c1-200
|
||||
grep -E "strata serve: prompt" $d/err.txt | tail -3 | cut -c1-220
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user