Commit Graph
2 Commits
Author SHA1 Message Date
fl0l0u 70be48c6fa scripts: the expert report never prints an untrusted string raw
The stats file a colleague hands over is data, not the operator's own:
its model, arch and map strings are printed straight to the terminal, and
a ESC in one starts an OSC sequence that retitles the window, moves the
cursor, or worse in terminals that honour it. Malformed numbers beneath a
well-formed format header crashed the report with a raw Python traceback
the operator has to read past.

Strings for display now pass through safe(), which turns every control
character -- C0, DEL, and the C1 range -- into '?', on model, arch and
the map list alike. The whole run is wrapped so a file that passes the
format check but is malformed underneath exits with one line naming the
fault instead of a stack. --json output is untouched: it is data, not a
terminal.
2026-11-15 20:38:10 +00:00
baKon 7da9ccf38b 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.
2026-11-11 22:36:27 +01:00