code wiki / _hdl_build / nx_research_flip_discover_gate.nx
nx_research_flip_discover_gate.nx
buildroot/runtime/_hdl_build/nx_research_flip_discover_gate.nx
about
nx_research_flip_discover_gate.nx -- the FLAGSHIP discovery: genuinely DISCOVER a faster matrix-multiplication
scheme by SEARCH (not certify a supplied one), the modern AlphaTensor-class method done sovereignly.
Exhaustive search can't reach Strassen's rank-7 for <2,2,2> (the coefficient space is astronomical). The
FLIP-GRAPH local search (Kauers & Moosbauer 2022 -- how recent matmul rank records were set WITHOUT RL) can:
a decomposition of the matmul tensor T over GF(2) is a multiset of rank-1 triples (u_r,v_r,w_r) summing to T.
FLIP : two triples sharing one factor, e.g. (a,v1,w1)+(a,v2,w2) = (a,v1,w1+w2)+(a,v1+v2,w2) over GF(2)
-- rank-preserving (2 terms -> 2 terms), a random-walk neighbor.
REDUCE : when a flip makes a factor 0 (term vanishes) or two triples coincide (cancel over GF(2)), the
rank DROPS. Flips never raise rank, reductions only lower it -> rank is monotone non-increasing,
so the walk only needs to find ONE 8->7 reduction (easy for <2,2,2>; 6 is impossible -> floor 7).
Start from the naive rank-8 scheme, random-walk with a deterministic PRNG until rank 7 is DISCOVERED, then the
Brent-equation verifier (over GF(2)) certifies the discovered scheme computes <2,2,2> exactly + a random-input
cross-check. LIAR-KILL: a broken scheme is rejected. HONEST SCOPE: 7 is the proven optimum for 2x2
(Hopcroft-Kerr/Winograd, cited); we discover it sovereignly -- we do NOT claim AlphaTensor's larger records.
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
| 19 | 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 } |
| 20 | 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 } |
| 21 | 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 } |
| 23 | func bitof(x: i64, i: i64) -> i64 { return (x>>i)&1 } |
| 24 | 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 |
| 25 | func rpos(s: *i64) -> i64 { let v: i64 = xrng(s); return v & 0x3FFFFFFFFFFFFFFF } |
| 28 | func build_t(t: *i64) -> i64 called by 1: main |
| 40 | func build_naive(U: *i64, V: *i64, W: *i64) -> i64 |
| 50 | func brent_gf2(U: *i64, V: *i64, W: *i64, R: i64, t: *i64) -> i64 |
| 63 | 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 } |
| 66 | func reduce_pass(U: *i64, V: *i64, W: *i64, rp: *i64) -> i64 called by 1: run_search |
| 96 | func do_flip(U: *i64, V: *i64, W: *i64, rp: *i64, st: *i64, cand: *i64) -> i64 |
| 120 | func run_search(t: *i64, bU: *i64, bV: *i64, bW: *i64, brp: *i64, seed: i64, steps: i64) -> i64 |
| 136 | func mm_verify_gf2(U: *i64, V: *i64, W: *i64, R: i64, st: *i64) -> i64 |
| 158 | func main() -> i64 |