okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-dsv41-rel (0be62ccad) into v0.2.3.1: DeepSeek V4.1-Flash on top of the released 0.2.3 line28ce98bf1

main
2.0 KiB42 linesraw
1"""pilot_summary.py - tables from the jsonl of pilot.py.
2  python3 tools/trellis/pilot_summary.py pilot1.jsonl
3"""
4import collections
5import json
6import math
7import sys
8
9rows = [json.loads(l) for l in open(sys.argv[1])]
10print("records:", len(rows), "layers:", sorted({r["layer"] for r in rows}), "experts:", sorted({r["expert"] for r in rows}),
11      "rows per matrix:", sorted({r["rows"] for r in rows}))
12print("activation columns are PLACEHOLDERS (iso gaussian / synthetic outlier channels), not calibration data\n")
13
14
15def db(x):
16    return -10 * math.log10(x)
17
18
19def table(keyf, title, cols=("mse", "act_iso", "act_syn")):
20    g = collections.defaultdict(list)
21    for r in rows:
22        g[keyf(r)].append(r)
23    print(title)
24    for k in sorted(g):
25        v = g[k]
26        print("  %-40s n=%-3d " % (k, len(v)) + "  ".join("%s %.4f (%.2f dB)" % (c, sum(x[c] for x in v) / len(v), db(sum(x[c] for x in v) / len(v))) for c in cols))
27    print()
28
29
30rate_bpw = {"K4": 1.125, "K5": 1.375, "K6": 1.625, "K7": 1.875}
31table(lambda r: "%s %.3f bpw %s" % (r["rate"], rate_bpw[r["rate"]], "hadamard" if r["had"] else "plain   "), "mean over everything")
32table(lambda r: "%s %s %s" % (r["role"], r["rate"], "had" if r["had"] else "plain"), "by projection")
33table(lambda r: "L%02d %s %s" % (r["layer"], r["rate"], "had" if r["had"] else "plain"), "by layer")
34# spread of the weight mse across experts for K5 plain
35v = [r["mse"] for r in rows if r["rate"] == "K5" and not r["had"]]
36print("K5 plain weight mse over all %d matrices: min %.4f max %.4f" % (len(v), min(v), max(v)))
37# hadamard gain on the synthetic outlier activations
38print("\nHadamard effect on act_syn (relative error, plain / hadamard), per rate")
39for rate in ("K4", "K5", "K6", "K7"):
40    a = [r["act_syn"] for r in rows if r["rate"] == rate and not r["had"]]
41    b = [r["act_syn"] for r in rows if r["rate"] == rate and r["had"]]
42    print("  %s plain %.4f had %.4f ratio %.3f" % (rate, sum(a) / len(a), sum(b) / len(b), (sum(a) / len(a)) / (sum(b) / len(b))))