code wiki / _hdl_build / nx_research_discover_matmul_gate.nx

nx_research_discover_matmul_gate.nx

buildroot/runtime/_hdl_build/nx_research_discover_matmul_gate.nx

14596 B256 linesdepth 10pulls 12 transitivereach 0 importersview sourcekind gate/prooftopic research
docsdependenciesstructsconstsfunctions

about

nx_research_discover_matmul_gate.nx -- DISCOVERY widened to the matrix-multiplication family, the direct AlphaTensor analog (operator: "widen discovery ... search candidate low-mult MATMUL schemes a la AlphaTensor"). A fast matmul = a LOW-RANK BILINEAR TENSOR DECOMPOSITION. For an R-term scheme {(u_r,v_r,w_r)}: m_r = (u_r . a)(v_r . b) (R scalar multiplications) c_k = sum_r w_r[k] * m_r (only +/- of the m_r when coeffs are in {-1,0,1}) It computes the bilinear map exactly <=> Brent's equations hold: for all i,j,k: sum_r u_r[i] v_r[j] w_r[k] == T[i][j][k] (T = the problem's tensor) R = the multiplication count. Naive 2x2 matmul is rank 8; Strassen is rank 7. This gate: SUBSTRATE : a sovereign Brent-equation VERIFIER -- the exact certifier a discovery search rides on. MATMUL : the verifier certifies naive 2x2 (rank 8) AND Strassen (rank 7) as correct <2,2,2> schemes, and REJECTS a broken Strassen (liar-kill). Ties the substrate to real matrix multiplication. DISCOVERY : on a TRACTABLE bilinear problem -- complex multiplication, tensor (a+bi)(c+di) -- an EXHAUSTIVE {-1,0,1} search DISCOVERS a rank-3 scheme (3 mults < naive 4: the Gauss/Karatsuba speedup) it was never given, proves it MINIMAL (no rank-2 exists), and the same verifier + random-input check certify it exact. A broken rank-3 is rejected. HONEST SCOPE: the SEARCH discovers on the small problem; for <2,2,2> matmul we CERTIFY the known rank-7 via the same verifier -- we do NOT claim a blind AlphaTensor-scale rank-7 search. Pure integer, no float, deterministic, reproducible. GREEN iff 8/8. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_library.nx nx_research_discover_matmul_ga

imports: nx_syscalls.nxnx_library.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap g_w sys_write rs_lib_contains sys_mmap ↻ lib_list cat_list ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat sys_fstatat ssc_streq ss_open ss_open2 ssc_retire_handle cat_idx_load sys_mmap ↻ ss_hget sys_mmap ↻ ss_idx_find cat_idx_key lib_get cat_get ar_get_by_cid ss_open_cached ↻ ss_hget ↻ rs_has build_t222 build_naive222 build_strassen set4 brent_check build_t_complex build_naive_complex search222 sys_mmap ↻ pow3

structs

none

consts

none

functions

25func g_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 3: g_ng_rowmain calls 1: sys_write
26func g_n(v: i64) -> i64 { var m: i64=v; if m<0{g_w("-");m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1}; sys_write(1,o,k); return 0 }
called by 1: main calls 3: g_wsys_mmapsys_write
27func g_row(id: *u8, ok: i64, pass: *i64) -> i64 { g_w(" "); g_w(id); g_w(": "); if ok==1 { g_w("OK\n"); pass[0]=pass[0]+1 } else { g_w("FAIL\n") } return 0 }
called by 1: main calls 1: g_w
30func rs_has(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: rs_lib_contains
37func rs_lib_contains(needle: *u8) -> i64
called by 1: main calls 4: sys_mmaplib_listlib_getrs_has
48func rs_rng(state: *i64) -> i64 { var x: i64 = state[0]; x = x ^ (x << 13); x = x ^ (x >> 7); x = x ^ (x << 17); state[0] = x; return x }
called by 1: verify_cm
49func pow3(n: i64) -> i64 { var p: i64=1; var i: i64=0; while i<n { p=p*3; i=i+1 } return p }
called by 2: solve_wcolsearch222
51func decode_vec(code: i64, len: i64, out: *i64) -> i64 { var c: i64=code; var i: i64=0; while i<len { out[i]=(c%3)-1; c=c/3; i=i+1 } return 0 }
called by 2: solve_wcolsearch222
54func brent_check(u: *i64, v: *i64, w: *i64, R: i64, na: i64, nb: i64, nc: i64, t: *i64) -> i64
called by 1: main
70func solve_wcol(P: *i64, R: i64, tcol: *i64, wout: *i64, wc: *i64) -> i64
called by 1: search222 calls 2: pow3decode_vec
89func search222(R: i64, t: *i64, fu: *i64, fv: *i64, fw: *i64, recordFirst: i64) -> i64
120func cm_eval(u: *i64, v: *i64, w: *i64, R: i64, a0: i64, a1: i64, b0: i64, b1: i64, out: *i64) -> i64
called by 1: verify_cm
132func verify_cm(u: *i64, v: *i64, w: *i64, R: i64) -> i64
called by 1: main calls 3: sys_mmaprs_rngcm_eval
149func build_t_complex(t: *i64) -> i64 { var z: i64=0; while z<8 { t[z]=0; z=z+1 } t[(0*2+0)*2+0]=1; t[(1*2+1)*2+0]=-1; t[(0*2+1)*2+1]=1; t[(1*2+0)*2+1]=1; return 0 }
called by 1: main
150func build_naive_complex(u: *i64, v: *i64, w: *i64) -> i64
called by 1: main
158func build_t222(t: *i64) -> i64
called by 1: main
169func build_naive222(u: *i64, v: *i64, w: *i64) -> i64
called by 1: main
179func set4(arr: *i64, row: i64, a: i64, b: i64, c: i64, d: i64) -> i64 { arr[row*4+0]=a; arr[row*4+1]=b; arr[row*4+2]=c; arr[row*4+3]=d; return 0 }
called by 1: build_strassen
181func build_strassen(u: *i64, v: *i64, w: *i64) -> i64
called by 1: main calls 1: set4
188func main() -> i64