code wiki / _hdl_build / nx_research_flip_scale_gate.nx
nx_research_flip_scale_gate.nx
buildroot/runtime/_hdl_build/nx_research_flip_scale_gate.nx
about
nx_research_flip_scale_gate.nx -- does the sovereign flip-graph discoverer SCALE past the 2x2 toy case?
Generalize the engine to arbitrary <m,n,p> matmul (multiply mxn by nxp) and DISCOVER a non-trivial rank
reduction in a NEW shape: <2,2,3> has naive rank 12 and proven optimum 11 (Hopcroft-Kerr). The flip/reduce
mechanics are dimension-agnostic (GF(2) mask XORs); only the tensor + naive builder + Brent loop need the dims.
Anchored on <2,2,2> (known: 8->7) to prove the generalized engine still works, then attempts <2,2,3> (12->11).
HONEST: 7 and 11 are the proven optima for these shapes (cited); discovered sovereignly, no AlphaTensor-record
claim. GREEN iff 7/7. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 10 | func 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 } |
| 11 | func 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 } |
| 12 | func 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 } |
| 14 | func bitof(x: i64, i: i64) -> i64 { return (x>>i)&1 } called by 1: brent_gf2 |
| 15 | func xrng(s: *i64) -> i64 { var x: i64=s[0]; x = x ^ (x << 13); x = x ^ (x >> 7); x = x ^ (x << 17); s[0]=x; return x } called by 1: rpos |
| 16 | func rpos(s: *i64) -> i64 { let v: i64 = xrng(s); return v & 0x3FFFFFFFFFFFFFFF } |
| 19 | func build_t(t: *i64, m: i64, n: i64, p: i64) -> i64 called by 1: main |
| 31 | func build_naive(U: *i64, V: *i64, W: *i64, m: i64, n: i64, p: i64) -> i64 |
| 40 | func brent_gf2(U: *i64, V: *i64, W: *i64, R: i64, t: *i64, da: i64, db: i64, dc: i64) -> i64 |
| 53 | func copy_scheme(sU: *i64, sV: *i64, sW: *i64, dU: *i64, dV: *i64, dW: *i64, R: i64) -> i64 { var i: i64=0; while i<R { dU[i]=sU[i]; dV[i]=sV[i]; dW[i]=sW[i]; i=i+1 } return 0 } |
| 55 | func reduce_pass(U: *i64, V: *i64, W: *i64, rp: *i64) -> i64 called by 1: run_search |
| 84 | func do_flip(U: *i64, V: *i64, W: *i64, rp: *i64, st: *i64, cand: *i64) -> i64 |
| 107 | func run_search(m: i64, n: i64, p: i64, da: i64, db: i64, dc: i64, t: *i64, bU: *i64, bV: *i64, bW: *i64, brp: *i64, seed: i64, steps: i64, target: i64) -> i64 |
| 123 | func discover(m: i64, n: i64, p: i64, da: i64, db: i64, dc: i64, t: *i64, dU: *i64, dV: *i64, dW: *i64, drp: *i64, steps: i64, target: i64, nseeds: i64) -> i64 |
| 139 | func main() -> i64 |