Download tools/report_size.py from RightNowAI/RightNow-Mini: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/RightNowAI/RightNow-Mini/resolve/main/tools/report_size.py
- Command line
-
hf download hf://RightNowAI/RightNow-Mini/tools/report_size.py
-
curl -L -o report_size.py https://huggingface.co/RightNowAI/RightNow-Mini/resolve/main/tools/report_size.py
4.14 kB
| """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() | |