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
1.4 KiB32 linesraw
1"""merge_dumps.py - add STRATA_ACT_DUMP files (int64 n, int64 count, double sum x^2 [n]) of several runs into one directory, and
2print the per-layer summary.
3
4  python3 tools/trellis/merge_dumps.py OUT_DIR IN_DIR [IN_DIR ...]
5"""
6import pathlib
7import sys
8
9import numpy as np
10
11out = pathlib.Path(sys.argv[1])
12out.mkdir(parents=True, exist_ok=True)
13names = sorted({p.name for d in sys.argv[2:] for p in pathlib.Path(d).glob("act_L*_*.bin") if p.name.startswith("act_L") and p.stat().st_size < 400_000_000})
14for name in names:
15    tot, cnt, n0, cov = None, 0, None, None
16    for d in sys.argv[2:]:
17        p = pathlib.Path(d) / name
18        if not p.exists():
19            continue
20        raw = p.read_bytes()
21        n, c = np.frombuffer(raw[:16], dtype=np.int64)
22        sq = np.frombuffer(raw[16:16 + 8 * n], dtype=np.float64)
23        tot = sq.copy() if tot is None else tot + sq
24        if len(raw) >= 16 + 8 * n + 8 * n * n:
25            cv = np.frombuffer(raw[16 + 8 * n:16 + 8 * n + 8 * n * n], dtype=np.float64)
26            cov = cv.copy() if cov is None else cov + cv
27        cnt += int(c)
28        n0 = int(n)
29    (out / name).write_bytes(np.array([n0, cnt], dtype=np.int64).tobytes() + tot.astype(np.float64).tobytes()
30                             + (cov.tobytes() if cov is not None else b""))
31    m = tot / cnt
32    print("%-16s n %d count %d  mean E[x^2] %.4g  cv over channels %.3f  max/mean %.1f" % (name, n0, cnt, m.mean(), m.std() / m.mean(), m.max() / m.mean()))