okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
28ce98bf1
main
1"""pilot_summary.py - tables from the jsonl of pilot.py. 2python3 tools/trellis/pilot_summary.py pilot1.jsonl 3""" 4import collections 5import json 6import math 7import sys 8 9rows = [json .loads (l )for l in open (sys .argv [1 ])] 10"records:" ,len (rows ),"layers:" ,sorted ({r ["layer" ]for r in rows }),"experts:" ,sorted ({r ["expert" ]for r in rows }), 11"rows per matrix:" ,sorted ({r ["rows" ]for r in rows })) 12"activation columns are PLACEHOLDERS (iso gaussian / synthetic outlier channels), not calibration data\n" ) 13 14 15def db (x ): 16return - 10 * math .log10 (x ) 17 18 19def table (keyf ,title ,cols = ("mse" ,"act_iso" ,"act_syn" )): 20g = collections .defaultdict (list ) 21for r in rows : 22g [keyf (r )].append (r ) 23title ) 24for k in sorted (g ): 25v = g [k ] 26" %-40s n=%-3d " % (k ,len (v ))+ " " .join ("%s %.4f (%.2f dB)" % (c ,sum (x [c ]for x in v )/ len (v ),db (sum (x [c ]for x in v )/ len (v )))for c in cols )) 27rate_bpw = {"K4" :1.125 ,"K5" :1.375 ,"K6" :1.625 ,"K7" :1.875 } 31table (lambda r :"%s %.3f bpw %s" % (r ["rate" ],rate_bpw [r ["rate" ]],"hadamard" if r ["had" ]else "plain " ),"mean over everything" ) 32table (lambda r :"%s %s %s" % (r ["role" ],r ["rate" ],"had" if r ["had" ]else "plain" ),"by projection" ) 33table (lambda r :"L%02d %s %s" % (r ["layer" ],r ["rate" ],"had" if r ["had" ]else "plain" ),"by layer" ) 34# spread of the weight mse across experts for K5 plain 35v = [r ["mse" ]for r in rows if r ["rate" ]== "K5" and not r ["had" ]] 36"K5 plain weight mse over all %d matrices: min %.4f max %.4f" % (len (v ),min (v ),max (v ))) 37# hadamard gain on the synthetic outlier activations 38"\nHadamard effect on act_syn (relative error, plain / hadamard), per rate" ) 39for rate in ("K4" ,"K5" ,"K6" ,"K7" ): 40a = [r ["act_syn" ]for r in rows if r ["rate" ]== rate and not r ["had" ]] 41b = [r ["act_syn" ]for r in rows if r ["rate" ]== rate and r ["had" ]] 42" %s plain %.4f had %.4f ratio %.3f" % (rate ,sum (a )/ len (a ),sum (b )/ len (b ), (sum (a )/ len (a ))/ (sum (b )/ len (b ))))