scripts: expert_stats_report.py, what a --expert-stats file says per layer

--expert-stats (merged) writes per-layer expert selection counts. Reading
them one number at a time hides the thing that decides where bits go: a
layer's total is the same at every layer, because top-k routing spends
the same number of selections whatever it picks, so the totals rank
nothing. What differs is the concentration inside a layer and whether
decode and prefill disagree about which experts matter.

Prints per routed layer the top-5/10/20% share, the Gini coefficient, the
experts never selected, and decode against prefill (each one's top-20%
share, the share of decode landing on prefill's top-20%, Jaccard and TVD),
then a skew verdict. The self-check line compares each layer's selections
with its observed tokens x top_k, exact unless the drain lost histograms.

No argument about which layer deserves more bits is made here; the report
is the evidence a person (or a search) spends them against.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-11-11 22:36:27 +01:00
1 parent f3e4d11872
commit 7da9ccf38b
2 files changed
+220

No files matched your search

+1
View File
@@ -47,6 +47,7 @@ header lists its own. Scripts that only attach to a live server need `curl` and
| `statsdump.py` | Records `/stats` to a JSONL file, one row per poll (`--every`, default 1 s), so the dashboard's figures can be read back over time on a machine without a Prometheus scraper. A row is the engine's snapshot verbatim plus the poll's time `t` and the gap since the last good poll `dt_s`; nothing is derived. The file is appended to and rotated at `--max-mib` (default 256, five generations). A failed poll leaves no row; a run that wrote no row, or can no longer write its file, exits 1. The key is taken from `--api-key` or `RADIANCE_API_KEY`. |
| `stampgaps.py` | Reads the CSV that `RADIANCE_AQL_STAMP=N` writes (every dispatch of one recorded pass in N on card 0, start and end) and prints per kind of pass (told apart by tape length) the median wall, the busy time as the union over the queues, the idle share, the gap before an ordered start (p50, p90, sum) and the kernels by share of the dispatch time. The idle share is what chained launches could win at most, the gaps what they would remove. Stamping costs throughput of its own when passes are short (one in 50: 0.3 % at one GLM-5.3 stream, 4 % at eight), so take N larger at high concurrency. |
| `oracle.sh` | Every op compared against libref on the operands the model issued, which rad-kbench cannot do: its operands are its own (dense, rank 2), while the engine's are arena slices and weights loaded from a file. Starts its own server on :8302. Read it for `MISMATCH` lines, and for `NOT CHECKED` lines naming rows whose weight layout has no published inverse and so cannot be compared. |
| `expert_stats_report.py` | Reads the file `--expert-stats` writes and prints, per routed layer, the share of selections taken by the top 5/10/20 % of experts, the Gini coefficient, the experts never selected, and decode against prefill: each one's top-20 % share, the share of decode selections landing on prefill's top-20 % experts, the Jaccard overlap and the total-variation distance. The self-check line compares each layer's selections with its observed tokens × top_k, which is exact unless the drain lost histograms. Read it before spending expert bits or pinning a hot set: a layer's total is the same at every layer (top-k routing), so the totals rank nothing — the concentration and the decode/prefill disagreement do. Two layers with the same total can need opposite spending. |
## Regression checks against a live server