aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / evidence / QUANTUM_EFFICIENCY / 2026-10-22 / sparsity_followup.py
| 1 | """Follow up an unexpected low numerical rank in the first selected expert. |
| 2 | Static checkpoint inspection only. Does not claim execution equivalence or speed. |
| 3 | """ |
| 4 | import json |
| 5 | import pathlib |
| 6 | import numpy as np |
| 7 | from weight_probe import fetch, SELECTION |
| 8 | |
| 9 | rows = [] |
| 10 | for layer, expert, proj in SELECTION + [(0,0,'up_proj'),(0,0,'down_proj')]: |
| 11 | ww, provenance = fetch(layer,expert,proj) |
| 12 | unique_rows = np.unique(ww,axis=0).shape[0] |
| 13 | rows.append({'layer':layer,'expert':expert,'projection':proj,'shape':list(ww.shape), |
| 14 | 'zero_elements':int(np.sum(ww==0)), 'elements':int(ww.size), |
| 15 | 'all_zero_rows':int(np.sum(np.all(ww==0,axis=1))), |
| 16 | 'all_zero_columns':int(np.sum(np.all(ww==0,axis=0))), |
| 17 | 'unique_rows':int(unique_rows), 'provenance':provenance}) |
| 18 | print(json.dumps(rows[-1]),flush=True) |
| 19 | pathlib.Path(__file__).with_name('sparsity-followup-results.json').write_text(json.dumps({'scope':'Checkpoint-only static counts, five selected matrices; no inference or timing','rows':rows},indent=2)+'\n') |