File size: 4,136 Bytes
5ce45af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"""Write results/size.md from the files on the node. Every figure is read from a file; a missing one is said.

    python tools/report_size.py /data/train/mini > results/size.md
"""
import glob
import json
import statistics
import sys

R = sys.argv[1] if len(sys.argv) > 1 else "/data/train/mini"


def load(p):
    try:
        return json.load(open(p))
    except Exception:
        return None


def scores(tag):
    out = []
    for d in sorted(glob.glob(f"{R}/results/{tag}/att-*")):
        s = load(d + "/summary.json")
        if s:
            out.append(s["resolved"])
    return out


def main():
    out = []
    w = out.append
    u = load(f"{R}/runs/expert_usage.json") or {}
    w("# Size: fewer experts per layer")
    w("")
    w("Measured on 2026-12-01 on the node. The model routes every token to 8 of 128 experts in each layer. On coding")
    w("traffic some experts are chosen rarely, so the least-used ones of each layer were dropped. In the released")
    w("checkpoint every expert tensor and the router have the expert as their first dimension, so dropping an expert is")
    w("dropping its rows: nothing is re-quantized and no kept weight changes (`train/prune_experts.py`).")
    w("")
    if u:
        L = u["layers"]
        s96 = sorted(v["share_of_top_96"] for v in L.values())
        s64 = sorted(v["share_of_top_64"] for v in L.values())
        w(f"Usage was counted on {u['conversations']} of the kept training conversations ({u['tokens']:,} tokens, `train/expert_usage.py`), "
          f"{len(L)} layers. Share of all routing choices that go to the experts kept:")
        w("")
        w("| Experts kept per layer | Lowest layer | Median layer | Highest layer |")
        w("|---|---|---|---|")
        w(f"| 96 of 128 | {100 * s96[0]:.1f}% | {100 * s96[len(s96) // 2]:.1f}% | {100 * s96[-1]:.1f}% |")
        w(f"| 64 of 128 | {100 * s64[0]:.1f}% | {100 * s64[len(s64) // 2]:.1f}% | {100 * s64[-1]:.1f}% |")
        w("")
    w("## What it costs")
    w("")
    w("Nothing was retrained after pruning (the fine-tune in `train.md` did not move the model, so there was nothing to heal with).")
    w("Scores are single attempts on the 100-task evaluation subset at temperature 0.8, at most 100 steps and 8,192 new")
    w("tokens a step, on the engine of `speed.md`: the same settings as the unpruned model's attempts in `deep.md`.")
    w("")
    w("| Variant | Folder size | Single attempts, resolved of 100 | One stream on the engine, tokens per second |")
    w("|---|---|---|---|")
    base = scores("deep")
    sp = load(f"{R}/results/raw/speed-engine/dflash.json")
    w(f"| 128 experts (the released model) | 20.19 GB | {', '.join(map(str, base)) or 'not scored'} | "
      f"{(sp or {}).get('levels', {}).get('1', {}).get('per_stream_decode_tps_median', 'not measured')} |")
    verdict = {}
    for k in (96, 64):
        rep = load(f"{R}/models/RightNow-Mini-e{k}/prune_report.json")
        sc = scores(f"prune{k}")
        spk = load(f"{R}/results/raw/speed-prune/e{k}.json")
        if not rep:
            w(f"| {k} experts | not built | | |")
            continue
        w(f"| {k} experts | {rep['gb']} GB | {', '.join(map(str, sc)) or 'not scored'} | "
          f"{(spk or {}).get('levels', {}).get('1', {}).get('per_stream_decode_tps_median', 'not measured')} |")
        if sc and base:
            verdict[k] = (min(sc) >= min(base), sc)
    w("")
    if base:
        w(f"Gate (the brief's): the pruned model's score within noise of the unpruned model. The unpruned model's {len(base)} attempts "
          f"range from {min(base)} to {max(base)} (median {statistics.median(base)}). Read as: every attempt of the pruned variant inside that range or above it.")
        w("")
        for k, (ok, sc) in verdict.items():
            w(f"- {k} experts: attempts {sc}. **{'Passed' if ok else 'Not passed'}.**")
        w("")
    w("The speed column is with drafting. The draft model was made for the released model; a pruned model disagrees with")
    w("it more often, so fewer drafted tokens are accepted.")
    print("\n".join(out))


if __name__ == "__main__":
    main()