Results (3 prompts x 41 teacher-forced rows): port vs Original agree exactly at the embedding and the first GDN half; relL2 of the residual then grows smoothly with depth (1e-3 after layer 0 FFN, ~1e-2 by layers 8-13, 5-15e-2 by layers 28-44). The Original's own GPU-expert-cache vs CPU-expert arms show the same profile and the same logprob spread (median 0.287 vs port 0.292). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
2.1 KiB
Python
40 lines
2.1 KiB
Python
import re, sys, statistics
|
|
N = "/home/para/work/gpu-runs/numerics"
|
|
J = "/home/para/work/gpu-runs/holder2/jobs/100-numerics-ladder.log"
|
|
orig_dir = sys.argv[1]
|
|
# original logpos: split into cases at position resets
|
|
cases = []; prev = None
|
|
for ln in open(f"{N}/{orig_dir}/serve.logpos", errors="replace"):
|
|
f = ln.rstrip("\n").split("\t")
|
|
if len(f) < 9 or not f[0].isdigit(): continue
|
|
pos = int(f[0])
|
|
if prev is None or pos < prev: cases.append({})
|
|
prev = pos
|
|
cases[-1][pos] = {int(a.split(":")[0]): float(a.split(":")[1]) for a in f[8:] if ":" in a}
|
|
log = open(J, errors="replace").read().split("\n")
|
|
allds = []; flips = 0; nrows = 0
|
|
for ci in range(len(cases)):
|
|
c = f"c{ci}"
|
|
truth = [int(x) for x in open(f"{N}/cases_lad/{c}.ids").read().strip().split(",")] + [int(x) for x in open(f"{N}/cases_lad/{c}.port").read().split()]
|
|
s = [i for i, l in enumerate(log) if l.startswith(f"DBG corpus {ci} prompt_ids")][0]
|
|
e = [i for i, l in enumerate(log) if l.startswith(f"DBG corpus {ci} output")][0]
|
|
port = {}; wpos = None
|
|
for ln in log[s:e]:
|
|
m = re.match(r"DBG logprobs window position=(\d+) inputs=\[([0-9, ]+)\]", ln)
|
|
if m: wpos = int(m[1]); winputs = [int(x) for x in m[2].split(",")]; j = 0; continue
|
|
f = ln.split("\t")
|
|
if wpos is not None and len(f) > 8 and f[0].lstrip("-").isdigit():
|
|
pos = int(f[0]); valid = all(truth[wpos + k] == winputs[k] for k in range(j + 1) if wpos + k < len(truth)); j += 1
|
|
if valid and pos not in port: port[pos] = {int(a.split(":")[0]): float(a.split(":")[1]) for a in f[8:] if ":" in a}
|
|
ds = []
|
|
for pos, pr in port.items():
|
|
o = cases[ci].get(pos)
|
|
if not o: continue
|
|
com = [t for t in pr if t in o]
|
|
if com: ds.append(max(abs(pr[t] - o[t]) for t in com))
|
|
nrows += 1
|
|
if max(pr, key=pr.get) != max(o, key=o.get): flips += 1
|
|
allds += ds
|
|
print(c, "rows", len(ds), "median %.3f max %.3f" % (statistics.median(ds), max(ds)))
|
|
print("all rows", len(allds), "median %.3f mean %.3f max %.3f top1 differs %d/%d" % (statistics.median(allds), statistics.mean(allds), max(allds), flips, nrows))
|