okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0408f0921
main
1"""q36_lgcmp.py A.bin B.bin : two --dump-full-logits files (float32 [steps][248320]) compared: max |dlogit|, mean / max KL(A||B), top-1 agreement. 2Used for the prompt-chunk and the kernel checks of docs/QWEN36.md.""" 3import sys ,numpy as np 4V = 248320 5a = np .fromfile (sys .argv [1 ],dtype = np .float32 ).reshape (- 1 ,V ) 6b = np .fromfile (sys .argv [2 ],dtype = np .float32 ).reshape (- 1 ,V ) 7n = min (len (a ),len (b )) 8def lsm (x ): 9m = x .max (axis = 1 ,keepdims = True ) 10return x - m - np .log (np .exp (x - m ).sum (axis = 1 ,keepdims = True )) 11pa ,pb = lsm (a [:n ].astype (np .float64 )),lsm (b [:n ].astype (np .float64 )) 12kl = (np .exp (pa )* (pa - pb )).sum (axis = 1 ) 13"steps %d max|dlogit| %.4f mean KL(a||b) %.3e max KL %.3e top1 same %d/%d" % (n ,np .abs (a [:n ]- b [:n ]).max (),kl .mean (),kl .max (), (a [:n ].argmax (1 )== b [:n ].argmax (1 )).sum (),n ))