fix(serve): the Original serve path stops on <|endoftext|> as the Original does; quality-gate retrieval and ladder jobs
generate.cpp stops on {248044, 248046}; the GGUF eos_token_id is only 248046, so the port ran on
past an <|endoftext|> (up to max_new, emitting <|im_start|> loops). The stop set is now the model's EOS
plus <|endoftext|> in the serve backend, the smokes and the laptop probe.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
d3962493b7
commit
97227d8c8e
@@ -328,8 +328,9 @@ mod runner {
|
||||
sampler.as_ref(),
|
||||
clock_seed(),
|
||||
spec_min_p,
|
||||
vec![eos as i32],
|
||||
crate::qwen_forward::original_serve_request::original_stop_tokens(eos),
|
||||
);
|
||||
let stop_tokens = crate::qwen_forward::original_serve_request::original_stop_tokens(eos);
|
||||
let cancelled = || cancel.load(Ordering::Acquire) || shared.shutdown.load(Ordering::Acquire) || sink.is_closed();
|
||||
let start = Instant::now();
|
||||
let mut utf8 = Utf8Pending::default();
|
||||
@@ -340,8 +341,8 @@ mod runner {
|
||||
let mut emit = |tokens: &[i32]| -> Result<(), ForwardError> {
|
||||
let mut deliver = |token: i32| -> Result<(), GenerationFailure> {
|
||||
count += 1;
|
||||
if token as u32 == eos {
|
||||
// the authoritative EOS counts as an output token and carries no text
|
||||
if stop_tokens.contains(&token) {
|
||||
// the authoritative EOS (<|im_end|> or <|endoftext|>) counts as an output token and carries no text
|
||||
return Ok(());
|
||||
}
|
||||
let bytes = tokenizer
|
||||
|
||||
@@ -138,7 +138,7 @@ fn original_serve_laptop_bench() {
|
||||
for rep in 0..repeat {
|
||||
for (k, &index) in order.iter().enumerate() {
|
||||
for arm in super::original_serve_arms::arms_for(&arms, k + rep) {
|
||||
let request = ServeRequest::new(prompts[index].clone(), max_new, None, 7, spec_min_p, vec![eos as i32]);
|
||||
let request = ServeRequest::new(prompts[index].clone(), max_new, None, 7, spec_min_p, crate::qwen_forward::original_serve_request::original_stop_tokens(eos));
|
||||
super::original_serve_arms::serve_arm(&mut stack, &arm, &request, &format!("p{} rep{rep}", index + 1), &format!("prompt={}", prompts[index].len()));
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ fn original_serve_laptop_bench() {
|
||||
}
|
||||
for pass in 0..repeat {
|
||||
for (index, ids) in prompts.iter().enumerate() {
|
||||
let request = ServeRequest::new(ids.clone(), max_new, None, 7, spec_min_p, vec![eos as i32]);
|
||||
let request = ServeRequest::new(ids.clone(), max_new, None, 7, spec_min_p, crate::qwen_forward::original_serve_request::original_stop_tokens(eos));
|
||||
let mut out = Vec::new();
|
||||
let begun = std::time::Instant::now();
|
||||
let mut first = None;
|
||||
|
||||
@@ -39,7 +39,7 @@ fn required_path(name: &str) -> PathBuf {
|
||||
}
|
||||
|
||||
fn request(prompt: &[u32], max_new: usize, sampler: Option<&leleka_sampler_ref::SamplerParams>, eos: u32) -> ServeRequest {
|
||||
ServeRequest::new(prompt.iter().map(|&t| t as i32).collect(), max_new, sampler, 7, 0.0, vec![eos as i32])
|
||||
ServeRequest::new(prompt.iter().map(|&t| t as i32).collect(), max_new, sampler, 7, 0.0, crate::qwen_forward::original_serve_request::original_stop_tokens(eos))
|
||||
}
|
||||
|
||||
fn report_timing(stack: &OriginalServeStack<'_, '_>, label: &str, produced: usize) {
|
||||
@@ -226,7 +226,7 @@ fn original_serve_smoke_prompt_decode_mtp_verify_commit_reset_cancel_sample() {
|
||||
eprintln!("DBG corpus {index} prompt_ids ({}): {}", ids.len(), ids.iter().map(|t| t.to_string()).collect::<Vec<_>>().join(","));
|
||||
}
|
||||
for arm in super::original_serve_arms::arms_for(&arms, k + rep) {
|
||||
let corpus_request = ServeRequest::new(ids.iter().map(|&t| t as i32).collect(), max_new, None, 7, min_p, vec![eos as i32]);
|
||||
let corpus_request = ServeRequest::new(ids.iter().map(|&t| t as i32).collect(), max_new, None, 7, min_p, crate::qwen_forward::original_serve_request::original_stop_tokens(eos));
|
||||
super::original_serve_arms::serve_arm(&mut stack, &arm, &corpus_request, &format!("p{index} rep{rep}"), &format!("prompt={}", ids.len()));
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ fn original_serve_smoke_prompt_decode_mtp_verify_commit_reset_cancel_sample() {
|
||||
top_k: 20, top_p: 0.95, min_p: 0.0, temperature: 0.7, min_keep: 1, penalty_last_n: 64, penalty_repeat: 1.1,
|
||||
penalty_freq: 0.0, penalty_present: 0.0, seed: 1234, counter: 0, greedy: false,
|
||||
};
|
||||
let corpus_request = ServeRequest::new(ids.iter().map(|&t| t as i32).collect(), max_new, sampled.then_some(&sampler), 7, min_p, vec![eos as i32]);
|
||||
let corpus_request = ServeRequest::new(ids.iter().map(|&t| t as i32).collect(), max_new, sampled.then_some(&sampler), 7, min_p, crate::qwen_forward::original_serve_request::original_stop_tokens(eos));
|
||||
let started = std::time::Instant::now();
|
||||
let mut first: Option<std::time::Duration> = None;
|
||||
let served = stack.serve(&corpus_request, &mut |round| {
|
||||
|
||||
@@ -14,6 +14,16 @@ use super::{
|
||||
};
|
||||
use leleka_cuda_driver::{SamplerParams, SamplerPath};
|
||||
|
||||
/// `<|endoftext|>`: the Original's `--eos-ids` default is {248044, 248046}; the GGUF's `tokenizer.ggml.eos_token_id` is only 248046
|
||||
/// (`<|im_end|>`), so a request that stops on the metadata id alone runs on past an `<|endoftext|>` (quality gate, docs/quality-gate.md).
|
||||
pub(crate) const ENDOFTEXT_TOKEN: i32 = 248_044;
|
||||
|
||||
/// The stop set of a request on the Original serve path: generate.cpp's `eos_ids` ({248044, 248046}) plus the model's own EOS id.
|
||||
pub(crate) fn original_stop_tokens(eos: u32) -> Vec<i32> {
|
||||
let eos = eos as i32;
|
||||
if eos == ENDOFTEXT_TOKEN { vec![eos] } else { vec![eos, ENDOFTEXT_TOKEN] }
|
||||
}
|
||||
|
||||
/// Cells a request keeps free beyond `n + max_new`: the last verify window may overshoot by up to this.
|
||||
pub(in crate::qwen_forward) const CONTEXT_SLACK: usize = 8;
|
||||
|
||||
@@ -187,6 +197,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_stop_set_is_the_originals_endoftext_and_im_end() {
|
||||
assert_eq!(original_stop_tokens(248_046), vec![248_046, 248_044]);
|
||||
assert_eq!(original_stop_tokens(248_044), vec![248_044]);
|
||||
assert!(original_stop_tokens(248_046).contains(&ENDOFTEXT_TOKEN), "generate.cpp stops on <|endoftext|> as well");
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Fake {
|
||||
fresh: bool,
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: phase 2 of the retrieval check, only queued when the port's answer differs from the Original's (see 9964/9966): the Original reads
|
||||
# prompt + the first K<=100 answer tokens (ret2.txt written by 9964): batched prompt (--turn-token = the prompt's last token), the answer through the
|
||||
# verify windows, top-16 logprobs per row (STRATA_LOGPOS).
|
||||
source ~/work/gpu-runs/quality/q-common.sh
|
||||
mem_ok 60 || { echo "abort: MemAvailable < 60 GiB"; exit 3; }
|
||||
header
|
||||
L=$G/long-180k
|
||||
T=$(python3 -c "print(open('$L/prompt100000.ids').read().strip().split(',')[-1])")
|
||||
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-read $Q/ret2.txt $COMMON $(kar_args)
|
||||
date -u +%FT%TZ
|
||||
@@ -1,12 +1,12 @@
|
||||
set -uo pipefail
|
||||
# Quality gate job: the Original's logits for the first generated tokens of corpus prompts 2 and 0 (the Original diverges from itself at token 4 / 6 there) with the prompt read by the BATCHED path
|
||||
# Quality gate job: the Original's logits for the first generated tokens of corpus prompts 1, 2 and 0 (the Original diverges from itself at token 2 / 4 / 6 there) with the prompt read by the BATCHED path
|
||||
# (the path of a real request; the other reads put the whole path through the verify windows). Per prompt one process:
|
||||
# path = prompt + up to 40 of the Original's pass-0 tokens, --turn-token = the prompt's last token (absent from those 40), so the prompt
|
||||
# is read batched up to its last token and the generated part goes through the windows (--short-read 40), where STRATA_LOGPOS logs it.
|
||||
source ~/work/gpu-runs/quality/q-common.sh
|
||||
mem_ok 60 || { echo "abort: MemAvailable < 60 GiB"; exit 3; }
|
||||
header
|
||||
for i in 2 0; do
|
||||
for i in 1 2 0; do
|
||||
T=$(python3 - $Q $i <<'PY'
|
||||
import sys, json
|
||||
q, i = sys.argv[1], int(sys.argv[2])
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: phase 2 of the retrieval check (job 9964 gave the Original's answers: 83 tokens at 100k, 63 at 180k; the port's differ from token 61 / 30).
|
||||
# Per prompt two requests in one process: (1) the bare prompt (batched prefill chunk 8192; --turn-token = its last token, so a checkpoint is kept at
|
||||
# the last prompt token), (2) prompt + the Original's whole answer (<=120 tokens): it resumes from that checkpoint and the answer goes through the verify
|
||||
# windows (--short-read 128), where STRATA_LOGPOS logs top-16 per row. Writes long-force/answer<N>.ids (the whole answer) for the port's forced run.
|
||||
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
|
||||
T=$(python3 -c "print(open('$L/prompt100000.ids').read().strip().split(',')[-1])")
|
||||
python3 - $L $Q/runs/RET-orig-free/out.txt $F $Q/ret3.txt <<'PY'
|
||||
import sys
|
||||
L, out, F, req = sys.argv[1:5]
|
||||
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):
|
||||
ans = ans[:120]
|
||||
open(f"{F}/answer{n}.ids", "w").write(",".join(map(str, ans)))
|
||||
ids = open(f"{L}/prompt{n}.ids").read().strip()
|
||||
lines += [f"GEN 1 {ids}", f"GEN 1 {ids}," + ",".join(map(str, ans))]
|
||||
print(n, "answer tokens forced", len(ans))
|
||||
open(req, "w").write("\n".join(lines) + "\nQUIT\n")
|
||||
PY
|
||||
orig_serve RET-orig-read $Q/ret3.txt --prefill 8192 --max-context 262144 --kv-resident 20480 --prompt-cache 2 --prompt-cache-root 0 --prompt-cache-every 0 --turn-token $T --short-read 128 --expert-cache 2048 --expert-cache-per-layer --adapt-every 0 $(kar_args)
|
||||
grep -E "^RESUME|^REUSED" $Q/runs/RET-orig-read/out.txt | tr "\n" " "
|
||||
date -u +%FT%TZ
|
||||
@@ -0,0 +1,11 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: the port's retrieval at 100k / 180k AFTER the stop-set fix (<|endoftext|> now stops like the Original's eos_ids {248044, 248046}):
|
||||
# a free run (600 new tokens allowed; compare with RET-port-free of job 9966, which ran 600 tokens at 180k), then a run teacher-forced along the
|
||||
# Original's answers (long-force/answer<N>.ids from job 9968), top-16 logprobs per window row.
|
||||
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-fixed $PORT_TIER $LONGENV
|
||||
port_long RET-port-forced $PORT_TIER $LONGENV LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR=$Q/long-force
|
||||
date -u +%FT%TZ
|
||||
@@ -0,0 +1,24 @@
|
||||
set -uo pipefail
|
||||
# Quality gate: where does the one outlier row (prompt 1, generated token 2, input token <think> 248068, position 66) leave the Original?
|
||||
# Both engines dump the residual after every layer half ("ladder": 96 frames x rows x 4*2560 f32) for the same path B1 (prompt 1 + its first 22 Original tokens):
|
||||
# the port teacher-forced (static tier, seed off, LELEKA_TRACE_RESIDUAL/LADDER), the numerics-orig build of the Original through the verify windows
|
||||
# (STRATA_NUM_RESID_DIR / STRATA_NUM_LADDER, same configuration as R1). Compared offline by q_ladder.py.
|
||||
source ~/work/gpu-runs/quality/q-common.sh
|
||||
mem_ok 60 || { echo "abort: MemAvailable < 60 GiB"; exit 3; }
|
||||
header; sha256sum $BIN
|
||||
D=$Q/ladder; rm -rf $D; mkdir -p $D/port $D/orig $D/force
|
||||
sed -n '2p' $G/prompts.txt > $D/prompts.txt
|
||||
cp $Q/cases/B1.ids $D/force/c0.truth
|
||||
port_env
|
||||
echo "=== port ladder"; date -u +%FT%TZ
|
||||
env LELEKA_ORIGINAL_SERVE_SMOKE=yes LELEKA_SMOKE_PROMPTS=$D/prompts.txt LELEKA_SMOKE_MAX_NEW=128 LELEKA_SMOKE_MIN_P=0.5 LELEKA_SMOKE_REPEAT=1 \
|
||||
LELEKA_SMOKE_FORCE_DIR=$D/force LELEKA_SMOKE_FORCE_PASSES=1 $PORT_TIER LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0 LELEKA_ORIGINAL_SERVE_SEED=off \
|
||||
LELEKA_TRACE_RESIDUAL=$D/port LELEKA_TRACE_LADDER=1 LELEKA_TRACE_PLE=1 \
|
||||
$BIN --ignored --test-threads=1 --nocapture original_serve_smoke_prompt_decode 2>&1 \
|
||||
| grep -a -E '^[0-9]+ |^DBG (corpus|logprobs|residual|forced)|test result|panicked|FAILED' > $D/port.log
|
||||
echo "rc=${PIPESTATUS[0]}"; date -u +%FT%TZ
|
||||
grep -a -c "DBG residual window" $D/port.log; ls $D/port | wc -l
|
||||
export ORIG_BIN=$HOME/work/numerics-orig/build/strata STRATA_NUM_RESID_DIR=$D/orig STRATA_NUM_LADDER=1
|
||||
orig_run ladder-orig B1 0 "" --prefill 2048 --max-context 4096 --short-read 4096 --prompt-cache 0 $(kar_args) --expert-cache 2048 --expert-cache-per-layer --adapt-every 0
|
||||
ls $D/orig | wc -l; du -sh $D
|
||||
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-3}
|
||||
BIN=${BIN:-$HOME/work/leleka-quality-bin/q-4}
|
||||
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
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Layer-by-layer comparison of the port's and the Original's residual stream on one token path (docs/quality-gate.md).
|
||||
|
||||
usage: q_ladder.py LADDER_DIR TARGET_POS [CASE_IDS_FILE]
|
||||
|
||||
LADDER_DIR holds what job 9970 wrote: port.log (the port's `DBG residual window seq= first= rows= inputs=[..]` lines) and port/l_win*.f32,
|
||||
orig/l_win*.f32 plus ../runs/ladder-orig/err.txt (the Original's `NUMRESID seq= pos0= T= tokens=` lines). A dump is
|
||||
[96 frames][rows][4*2560] f32, frame = 2*layer + half. For every position both engines computed on the path, the relative L2 distance
|
||||
|port - orig| / |orig| per frame is formed; the report lists, per frame, the value at TARGET_POS next to the median over all other positions.
|
||||
"""
|
||||
import array, math, os, re, statistics, sys
|
||||
|
||||
W = 4 * 2560
|
||||
|
||||
|
||||
def rd(path):
|
||||
a = array.array("f")
|
||||
with open(path, "rb") as f:
|
||||
a.frombytes(f.read())
|
||||
return a
|
||||
|
||||
|
||||
def windows_port(log):
|
||||
out = []
|
||||
for line in open(log, errors="replace"):
|
||||
m = re.match(r"DBG residual window seq=(\d+) first=(\d+) rows=(\d+) inputs=\[([0-9, ]+)\]", line)
|
||||
if m:
|
||||
out.append((int(m[2]), [int(x) for x in m[4].split(",")], int(m[1])))
|
||||
return out
|
||||
|
||||
|
||||
def windows_orig(err):
|
||||
out = []
|
||||
for line in open(err, errors="replace"):
|
||||
m = re.match(r"NUMRESID seq=(\d+) pos0=(\d+) T=(\d+) tokens=([0-9,]+)", line)
|
||||
if m:
|
||||
out.append((int(m[2]), [int(x) for x in m[4].split(",")], int(m[1])))
|
||||
return out
|
||||
|
||||
|
||||
def valid(wins, truth):
|
||||
out = {}
|
||||
for wi, (p0, toks, _) in enumerate(wins):
|
||||
for k in range(len(toks)):
|
||||
if p0 + k < len(truth) and toks[: k + 1] == truth[p0: p0 + k + 1]:
|
||||
out.setdefault(p0 + k, (wi, k))
|
||||
else:
|
||||
break
|
||||
return out
|
||||
|
||||
|
||||
def main(argv):
|
||||
d, target = argv[0], int(argv[1])
|
||||
truth = [int(x) for x in open(argv[2] if len(argv) > 2 else os.path.join(d, "..", "cases", "B1.ids")).read().strip().split(",")]
|
||||
pw = windows_port(os.path.join(d, "port.log"))
|
||||
ow = windows_orig(os.path.join(d, "..", "runs", "ladder-orig", "err.txt"))
|
||||
pv, ov = valid(pw, truth), valid(ow, truth)
|
||||
common = sorted(set(pv) & set(ov))
|
||||
print(f"port windows {len(pw)}, Original windows {len(ow)}, rows on the path: port {len(pv)} Original {len(ov)} common {len(common)}")
|
||||
cache = {}
|
||||
|
||||
def frames(path):
|
||||
if path not in cache:
|
||||
cache[path] = rd(path)
|
||||
return cache[path]
|
||||
|
||||
rel = {} # pos -> [96 relL2]
|
||||
for pos in common:
|
||||
(pwi, pk), (owi, ok) = pv[pos], ov[pos]
|
||||
pl = os.path.join(d, "port", f"l_win{pw[pwi][2]:05d}_pos{pw[pwi][0]}.f32")
|
||||
ol = os.path.join(d, "orig", f"l_win{ow[owi][2]:05d}_pos{ow[owi][0]}.f32")
|
||||
if not (os.path.exists(pl) and os.path.exists(ol)):
|
||||
continue
|
||||
pT, oT = len(pw[pwi][1]), len(ow[owi][1])
|
||||
a, b = frames(pl), frames(ol)
|
||||
row = []
|
||||
for fr in range(96):
|
||||
x = a[(fr * pT + pk) * W: (fr * pT + pk + 1) * W]
|
||||
y = b[(fr * oT + ok) * W: (fr * oT + ok + 1) * W]
|
||||
num = sum((u - v) ** 2 for u, v in zip(x, y))
|
||||
den = sum(v * v for v in y)
|
||||
row.append(math.sqrt(num / den) if den else float("nan"))
|
||||
rel[pos] = row
|
||||
if len(cache) > 4:
|
||||
cache.pop(next(iter(cache)))
|
||||
if target not in rel:
|
||||
print("target position not compared; positions:", sorted(rel)[:5], "...", sorted(rel)[-5:])
|
||||
return
|
||||
others = [p for p in rel if p != target]
|
||||
print(f"positions compared {len(rel)} (target {target}, input token {truth[target]}); relL2 per frame (frame = 2*layer+half)")
|
||||
print("frame layer.half target median(others) ratio rank among rows")
|
||||
first = None
|
||||
for fr in range(96):
|
||||
med = statistics.median(rel[p][fr] for p in others)
|
||||
t = rel[target][fr]
|
||||
rank = 1 + sum(1 for p in others if rel[p][fr] > t)
|
||||
ratio = t / med if med else float("nan")
|
||||
if first is None and ratio > 3 and fr > 0:
|
||||
first = fr
|
||||
if fr < 8 or fr % 8 == 0 or fr == 95 or (first is not None and fr <= first + 2):
|
||||
print(f"{fr:4d} {fr // 2:2d}.{fr % 2} {t:.3e} {med:.3e} {ratio:6.2f} {rank}/{len(rel)}")
|
||||
print("first frame with target > 3x the median of the other rows:", first)
|
||||
worst = sorted(((statistics.mean(rel[p][8:]), p) for p in rel), reverse=True)[:5]
|
||||
print("rows with the largest mean relL2 over frames 8..95:", [(p, f"{v:.3f}") for v, p in worst])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
+16
-10
@@ -1,6 +1,6 @@
|
||||
"""Port sections of the quality-gate report (see q_analyze.py): port vs Original, port envelope, divergence positions, verdict."""
|
||||
import math
|
||||
from q_lib import compare, summary, valid_rows
|
||||
from q_lib import compare, summary, valid_rows, load_case
|
||||
|
||||
EOS = 248046
|
||||
|
||||
@@ -204,20 +204,26 @@ def batched_reference(q, out, result, head, row_line):
|
||||
out.append("")
|
||||
|
||||
|
||||
def parse_long_port(path):
|
||||
"""{pos: Row} of the first window that carried each position in a port long-context log."""
|
||||
def parse_long_port(path, prompt):
|
||||
"""{pos: Row} of the port's rows that lie on its own path (prompt + its output) in a long-context log: a row after a draft token that
|
||||
was rejected is conditioned on text that is not on the path and is skipped."""
|
||||
import re
|
||||
from q_lib import parse_row
|
||||
rows, win = {}, None
|
||||
from q_lib import parse_row, valid_rows
|
||||
windows, win, output = [], None, None
|
||||
for line in open(path, errors="replace"):
|
||||
m = re.match(r"DBG logprobs window position=(\d+) inputs=\[([0-9, -]*)\]", line)
|
||||
if m:
|
||||
win = [int(m[1]), 0]
|
||||
win = (int(m[1]), [int(x) for x in m[2].split(",") if x.strip()], [])
|
||||
windows.append(win)
|
||||
continue
|
||||
m = re.match(r"long-smoke output ids \(\d+\): ([0-9,]*)", line)
|
||||
if m and output is None:
|
||||
output = [int(x) for x in m[1].split(",") if x]
|
||||
continue
|
||||
r = parse_row(line)
|
||||
if r is not None and win is not None:
|
||||
rows.setdefault(r.pos, r)
|
||||
return rows
|
||||
if r is not None and win is not None and len(win[2]) < len(win[1]):
|
||||
win[2].append(r)
|
||||
return valid_rows(windows, prompt + (output or []))
|
||||
|
||||
|
||||
def long_section(q, out, result):
|
||||
@@ -237,7 +243,7 @@ def long_section(q, out, result):
|
||||
for c in chunks:
|
||||
p = os.path.join(q.d, "runs", f"PL-c{c}", "port.log")
|
||||
if os.path.exists(p):
|
||||
port[c] = parse_long_port(p)
|
||||
port[c] = parse_long_port(p, load_case(q.cases, "L16")[:16000])
|
||||
if not orig and not port:
|
||||
return
|
||||
out.append("## L. 16,000-token prompt: logits at the three generated positions, by prefill chunk\n")
|
||||
|
||||
Reference in New Issue
Block a user