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
1.9 KiB44 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.py DUMP_L [--pos P] [--dim 5120] [--hc 4] - one run's DS4_DUMP_L records: each layer's residual stream at
4position P against the other positions (its norm over the median norm, its largest |value| and where, non-finite
5values) - where a position's stream blows up or goes non-finite."""
6import argparse
7import sys
8
9import numpy as np
10
11
12def main():
13    ap = argparse.ArgumentParser()
14    ap.add_argument("dump")
15    ap.add_argument("--pos", type=int, default=0)
16    ap.add_argument("--dim", type=int, default=5120)
17    ap.add_argument("--hc", type=int, default=4)
18    a = ap.parse_args()
19    n = a.dim * a.hc
20    print("%-10s %10s %10s %12s %10s %10s %s" % ("record", "|h| pos", "median", "pos / med", "max|v| pos", "max|v| all",
21                                                "non-finite (pos / all)"))
22    with open(a.dump, "rb") as f:
23        while True:
24            h = f.read(24)
25            if len(h) < 24:
26                break
27            il, p0, t = (int(v) for v in np.frombuffer(h, dtype=np.int64))
28            v = np.frombuffer(f.read(t * n * 4), dtype=np.float32).reshape(t, n)
29            p = a.pos - p0
30            if not 0 <= p < t:
31                continue
32            fin = np.isfinite(v)
33            vv = np.where(fin, v, 0).astype(np.float64)
34            nr = np.linalg.norm(vv, axis=1)
35            med = float(np.median(nr))
36            mx = np.abs(vv[p])
37            j = int(np.argmax(mx))
38            print("L%-4d@%-3d %10.3e %10.3e %12.2f %10.3e %10.3e %d / %d   (max at stream %d dim %d)" % (
39                il, p0, nr[p], med, nr[p] / max(med, 1e-30), mx[j], float(np.abs(vv).max()),
40                int((~fin[p]).sum()), int((~fin).sum()), j // a.dim, j % a.dim))
41
42
43if __name__ == "__main__":
44    sys.exit(main())