code wiki / (root) / nx_exceed_scoreboard_gate.nx

nx_exceed_scoreboard_gate.nx source

↩ module page · 128 lines · 7882 B

1// nx_exceed_scoreboard_gate.nx -- the STANDING, self-measuring s-class-exceed scoreboard for the sovereign 2// LLM compute path vs the float incumbents (Unsloth / vLLM / FlashAttention / CUDA). Per 3// feedback-benchmarks-must-exist-separate, this organ + its printed table IS the durable benchmark, kept 4// SEPARATE from any prose claim. It MEASURES the determinism axis LIVE (composes nx_fabric_collective's 5// ring_allreduce + an integer-reduction order-invariance check -> 0 mismatches), reports every row tied to a 6// REAL on-disk gate (no asserted numbers), and SELF-CHECKS that the scoreboard is HONEST: it cannot read 7// all-EXCEED -- at least one axis must be BEHIND or the gate goes RED (no-wave guard). 8// criteria: 9// 1 LIVE: ring all-reduce(N=8) == independent reference sum, BYTE-EXACT (0 mismatches) 10// 2 LIVE: integer reduction forward-order == reverse-order, BYTE-EXACT (the determinism SOURCE; float can't) 11// 3 scoreboard EXCEED count >= 4 (the measured wins) 12// 4 scoreboard BEHIND count >= 1 (HONEST -- no false all-green sweep) 13// expect_exit: 0 license_tier: ORIGINAL 14import "nx_fabric_collective.nx" 15import "nx_gate_verdict.nx" 16 17const V_EXCEED: i64 = 2 18const V_PARITY: i64 = 1 19const V_BEHIND: i64 = 0 20 21func dp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 22func dn(v: i64) -> i64 { 23 let b: *u8 = sys_mmap(28); var m: i64 = v 24 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } 25 let t: *u8 = sys_mmap(28); var k: i64 = 0 26 if m == 0 { t[0] = 48 as u8; k = 1 } 27 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 28 var i: i64 = 0 29 while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 30 sys_write(1, b, k); return 0 31} 32func chk(name: *u8, ok: i64) -> i64 { 33 if ok == 1 { dp(" PASS " as *u8); dp(name); dp("\n" as *u8); return 1 } 34 dp(" FAIL " as *u8); dp(name); dp("\n" as *u8); return 0 35} 36func vname(code: i64) -> *u8 { 37 if code == 2 { return "EXCEED" as *u8 } 38 if code == 1 { return "PARITY" as *u8 } 39 return "BEHIND" as *u8 40} 41// print one scoreboard row; return its verdict code for tallying 42func row(name: *u8, code: i64, gate: *u8) -> i64 { 43 dp(" [" as *u8); dp(vname(code)); dp("] " as *u8); dp(name); dp(" <- " as *u8); dp(gate); dp("\n" as *u8) 44 return code 45} 46 47func main() -> i64 { 48 dp("=== SOVEREIGN LLM COMPUTE -- s-class-exceed SCOREBOARD (measured, gate-tied, no-wave) ===\n" as *u8) 49 50 // ---------- LIVE MEASUREMENT 1: distributed determinism (ring all-reduce byte-exact) ---------- 51 let V: i64 = 8 52 let N: i64 = 8 53 let src: *i64 = sys_mmap(8 * N * V) as *i64 54 let refsum: *i64 = sys_mmap(8 * V) as *i64 55 var i: i64 = 0 56 while i < V { refsum[i] = 0; i = i + 1 } 57 var p: i64 = 0 58 while p < N { 59 i = 0 60 while i < V { 61 let val: i64 = (p * 5 + i * 3 + 1) % 17 62 src[p * V + i] = val 63 refsum[i] = refsum[i] + val 64 i = i + 1 65 } 66 p = p + 1 67 } 68 let arout: *i64 = sys_mmap(8 * V) as *i64 69 ring_allreduce(src, N, V, arout) 70 var ar_mismatch: i64 = 0 71 i = 0 72 while i < V { if arout[i] != refsum[i] { ar_mismatch = ar_mismatch + 1 } i = i + 1 } 73 74 // ---------- LIVE MEASUREMENT 2: reduction order-invariance (the determinism SOURCE) ---------- 75 let A: *i64 = sys_mmap(8 * 16) as *i64 76 var z: i64 = 0 77 while z < 16 { A[z] = (z * 37 + 11) % 251; z = z + 1 } 78 var sum_fwd: i64 = 0 79 var f: i64 = 0 80 while f < 16 { sum_fwd = sum_fwd + A[f]; f = f + 1 } 81 var sum_rev: i64 = 0 82 var r: i64 = 15 83 while r >= 0 { sum_rev = sum_rev + A[r]; r = r - 1 } 84 85 dp(" live: ring all-reduce mismatches=" as *u8); dn(ar_mismatch) 86 dp(" reduce fwd=" as *u8); dn(sum_fwd); dp(" rev=" as *u8); dn(sum_rev); dp("\n" as *u8) 87 dp(" ---------------------------------------------------------------------------\n" as *u8) 88 89 // ---------- THE SCOREBOARD (each row tied to a REAL gate) ---------- 90 var exceed_n: i64 = 0 91 var parity_n: i64 = 0 92 var behind_n: i64 = 0 93 var c: i64 = 0 94 c = row("Determinism, single-node " as *u8, V_EXCEED, "nx_nofloat_gemm_gate 0/4096 + nx_flash_byte_exact 5/5" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 95 c = row("Determinism, DISTRIBUTED " as *u8, V_EXCEED, "nx_distributed_train_gate 5/5 + ring_allreduce (live above)" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 96 c = row("Sovereignty / zero-deps " as *u8, V_EXCEED, "every gate SOVEREIGN (nx_cc->nxasm, no gcc/CUDA/libc)" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 97 c = row("Quant bit-width (sub-2-bit) " as *u8, V_EXCEED, "nx_nofloat_* ternary 1.58-bit QAT" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 98 c = row("Attention: byte-exact + O(blk) mem" as *u8, V_EXCEED, "nx_flash_byte_exact_gate 5/5" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 99 c = row("Int8 inference / KV-cache " as *u8, V_PARITY, "nx_nofloat_kvcache_gate (vs bitsandbytes/vLLM)" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 100 c = row("Throughput (CPU today) " as *u8, V_BEHIND, "8128 Mop/s nx_nofloat_gemm_gate; GPU-INT8 = the lever (substrate)" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 101 c = row("Model scale (params/data) " as *u8, V_BEHIND, "long-tail: compute + data, NOT mechanism" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 102 c = row("Ecosystem / maturity " as *u8, V_BEHIND, "long-tail: HF/PyTorch adoption" as *u8); if c == 2 { exceed_n = exceed_n + 1 } else { if c == 0 { behind_n = behind_n + 1 } else { parity_n = parity_n + 1 } } 103 104 dp(" ---------------------------------------------------------------------------\n" as *u8) 105 dp(" TALLY: EXCEED=" as *u8); dn(exceed_n); dp(" PARITY=" as *u8); dn(parity_n); dp(" BEHIND=" as *u8); dn(behind_n); dp("\n" as *u8) 106 107 var pass: i64 = 0 108 var total: i64 = 0 109 var t1: i64 = 0; if ar_mismatch == 0 { t1 = 1 } 110 total = total + 1; pass = pass + chk("T1 LIVE distributed determinism: ring all-reduce byte-exact (0 mismatches)" as *u8, t1) 111 var t2: i64 = 0; if sum_fwd == sum_rev { t2 = 1 } 112 total = total + 1; pass = pass + chk("T2 LIVE order-invariance: integer reduction fwd==rev (float cannot)" as *u8, t2) 113 var t3: i64 = 0; if exceed_n >= 4 { t3 = 1 } 114 total = total + 1; pass = pass + chk("T3 scoreboard EXCEED>=4 (the measured wins)" as *u8, t3) 115 var t4: i64 = 0; if behind_n >= 1 { t4 = 1 } 116 total = total + 1; pass = pass + chk("T4 scoreboard BEHIND>=1 (HONEST -- no false all-green sweep)" as *u8, t4) 117 118 dp("NX-EXCEED-SCOREBOARD-GATE " as *u8); dn(pass); dp(" / " as *u8); dn(total) 119 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 120 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 121 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 122 let ctr__dry: *i64 = gv_ctr() 123 ctr__dry[0] = pass 124 ctr__dry[1] = total 125 let rc__dry: i64 = gv_verdict("EXCEED-SCOREBOARD-GATE" as *u8, ctr__dry, "sovereign compute: measured EXCEED on the determinism/sovereignty axes, honest BEHIND on scale/throughput)" as *u8) 126 sys_exit(rc__dry) 127 return rc__dry 128}