Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/evidence/FLASH-NEXT-WEIGHT-WASTE-20261118/analyze.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / evidence / FLASH-NEXT-WEIGHT-WASTE-20261118 / analyze.py` 33 lines · 2230 bytes Raw Blame History 1 import numpy as np,zlib,lzma,sys 2 Z=np.load(sys.argv[1]) 3 c=np.arange(256); s=np.where(c&128,-1.0,1.0); e=(c>>3)&15; m=c&7 4 T=s*np.where(e==0,2.0**-6*(m/8),2.0**(e-7.0)*(1+m/8)); T[(c&127)==127]=np.nan 5 def H(x,n=256): 6 p=np.bincount(x.ravel(),minlength=n).astype(float); p=p[p>0]/x.size; return -(p*np.log2(p)).sum() 7 def deq(k): 8 w=T[Z[k]]; sc=Z[k+'.s'].view(np.uint16).astype(np.uint32) 9 f=(sc<<16).astype(np.uint32).view(np.float32).astype(np.float64) 10 return w*np.kron(f,np.ones((128,128)))[:w.shape[0],:w.shape[1]] 11 ex=sorted({int(k.split('.')[0]) for k in Z.files}) 12 for mname in ('gate_proj','up_proj','down_proj'): 13 allb=np.concatenate([Z[f'{x}.{mname}'].ravel() for x in ex]) 14 h0=H(allb); mag=H(allb&127,128); used=np.unique(allb).size 15 # per-block adaptive order-0 entropy 16 hb=[] 17 for x in ex: 18 a=Z[f'{x}.{mname}']; r,cc=a.shape 19 for i in range(0,r,128): 20 for j in range(0,cc,128): hb.append(H(a[i:i+128,j:j+128])) 21 raw=allb.tobytes() 22 print(f'{mname}: bytes={allb.size} order0={h0:.3f} bits mag7={mag:.3f} distinct={used} zero_codes={np.mean((allb&127)==0):.4f} nan={np.mean((allb&127)==127):.5f} perblock_H={np.mean(hb):.3f} zlib9={8*len(zlib.compress(raw,9))/allb.size:.3f} xz={8*len(lzma.compress(raw[:`20000000`],preset=6))/min(allb.size,`20000000`):.3f} maxcode_used={np.mean((allb&127)>=120):.5f}') 23 # neuron importance and structure 24 for x in ex[:4]: 25 g,u,d=deq(f'{x}.gate_proj'),deq(f'{x}.up_proj'),deq(f'{x}.down_proj') 26 imp=np.linalg.norm(g,axis=1)*np.linalg.norm(u,axis=1)*np.linalg.norm(d,axis=0); imp/=imp.sum() 27 si=np.sort(imp) 28 sv=[np.linalg.svd(a,compute_uv=False) for a in (g,u,d)] 29 rk=[int(np.searchsorted(np.cumsum(v**2)/np.sum(v**2),q))+1 for v in sv for q in (0.99,)] 30 print(f'expert {x}: neuron-importance min/median/max ratio={si[0]/np.median(si):.3f}/1/{si[-1]/np.median(si):.2f} bottom10%share={si[:64].sum():.4f} exact-zero-neurons={(imp==0).sum()} rank@99%energy g,u,d={rk} of 640 | rms g,u,d={g.std():.4f},{u.std():.4f},{d.std():.4f}') 31 D=[deq(f'{x}.down_proj').ravel() for x in ex] 32 C=np.corrcoef(np.stack(D)); off=C[~np.eye(len(ex),dtype=bool)] 33 print('cross-expert down_proj cosine: mean %.4f max %.4f'%(off.mean(),off.max()))