okami.mom/strata

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

waveringanaserve: restore the DeepSeek V4.1 server paths, tools and headers removed upstream, keeping the native picture tower firstba8745e13

main
2.2 KiB50 linesraw
1# Copyright (c) 2026 Peasant Smith and the Project Maya contributors (MIT; https://github.com/mw00/project-maya, v1.1.17).
2# Ported into Strata (third_party/project-maya/NOTICE.md, LICENSE); changes are in the git history of this file.
3"""dumpscan_y.py DUMP_Y DUMP_R --pos P [--layers a-b] - one run's expert set rows (DS4_DUMP_Y, DS4_DUMP_R): position
4P's rows a layer - its experts, their rows and P's place in them, |h| and |y| against the layer's median row."""
5import argparse
6import sys
7
8import numpy as np
9
10sys.path.insert(0, __file__.rsplit("/", 1)[0] if "/" in __file__ else ".")
11from dumpcmp import read_r, read_y, row_keys  # noqa: E402
12
13
14def main():
15    ap = argparse.ArgumentParser()
16    ap.add_argument("dump_y")
17    ap.add_argument("dump_r")
18    ap.add_argument("--pos", type=int, required=True)
19    ap.add_argument("--layers", default="0-99")
20    ap.add_argument("--dim", type=int, default=5120)
21    ap.add_argument("--ff", type=int, default=2304)
22    a = ap.parse_args()
23    l0, l1 = (int(v) for v in a.layers.split("-"))
24    R = read_r(a.dump_r)
25    for il, pieces in read_y(a.dump_y, a.ff, a.dim):
26        if not l0 <= il <= l1:
27            continue
28        r = [v for (l2, _), v in R.items() if l2 == il]
29        if len(r) != 1:
30            continue
31        keys = row_keys(r[0])
32        hn, yn, mine = [], [], []
33        for d in pieces:
34            for i in range(d["n"]):
35                t, e, n, pl = keys[d["a"] + i]
36                h = float(np.linalg.norm(d["h"][i].astype(np.float64)))
37                y = float(np.linalg.norm(d["y"][i].astype(np.float64)))
38                hm = float(np.abs(d["h"][i].astype(np.float32)).max())
39                hn.append(h)
40                yn.append(y)
41                if t == a.pos:
42                    mine.append((e, n, pl, h, hm, y, d["ring"], "%d+%d/%dx%d" % (d["a"], d["n"], d["ne"], d["mr"])))
43        mh, my = float(np.median(hn)), float(np.median(yn))
44        print("L%-3d median |h| %.3e |y| %.3e; pos %d: %s" % (il, mh, my, a.pos, "; ".join(
45            "e%d (%d rows, #%d) |h| %.2e max %.2e |y| %.2e (x%.1f) ring %d %s" % (e, n, pl, h, hm, y, y / max(my, 1e-30), rg, pc)
46            for e, n, pl, h, hm, y, rg, pc in mine)))
47
48
49if __name__ == "__main__":
50    sys.exit(main())