Files
leleka/scripts/numerics/num_lp_oo.py
T
Pavlo RatushnyiandClaude Opus 5.5 84a6817a5a diag(numerics): ladder comparison tools, CPU-expert Original arm, logprob comparators
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>
2026-10-16 11:57:00 +02:00

24 lines
1.1 KiB
Python

import sys, statistics
N = "/home/para/work/gpu-runs/numerics"
def load(d):
cases = []; prev = None
for ln in open(f"{N}/{d}/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}
return cases
a, b = load(sys.argv[1]), load(sys.argv[2])
ds = []; flips = 0
for ci in range(3):
plen = len(open(f"{N}/cases_lad/c{ci}.ids").read().strip().split(","))
for pos in a[ci]:
if pos < plen - 1 or pos not in b[ci]: continue # generation rows only, as in the port comparison
x, y = a[ci][pos], b[ci][pos]
com = [t for t in x if t in y]
if com: ds.append(max(abs(x[t] - y[t]) for t in com))
flips += max(x, key=x.get) != max(y, key=y.get)
print("rows", len(ds), "median %.3f mean %.3f max %.3f top1 differs %d" % (statistics.median(ds), statistics.mean(ds), max(ds), flips))