code wiki / _hdl_build / nx_nofloat_hwladder.nx
nx_nofloat_hwladder.nx source
↩ module page · 62 lines · 6448 B
1// nx_nofloat_hwladder.nx -- CAP-NF-HWLADDER: the HARDWARE-RUNG-UP ladder, silicon -> AI, each rung grounded on a
2// real organ, with the HARDWARE-CONDITIONAL exceed stated honestly (asterisk-disciplined). The reframe that makes
3// the exceed genuine rather than a niche: on INTEGER-ONLY / NO-FPU hardware (MCUs, FPGAs, RISC-V base ISA, edge)
4// float is a LIABILITY -- it needs an FPU or slow soft-float (hw_fpu: runs "without floating[-point]"; hw_cortexm:
5// Cortex-M0 has no FPU; hw_riscv: integer base ISA, F/D optional; hw_cmsisnn/hw_tflite: the field runs INTEGER on
6// this silicon). Our stack's compiler has NO float type at all -> the AI binary needs ZERO FPU -> NATIVE there.
7// Rungs: R0 SILICON (integer ALU, no-FPU, NEVER-BRICK by construction) -> R1 TOOLCHAIN -> R2 INTEGER MATH ->
8// R3 AUTOGRAD -> R4 TRANSFORMER -> R5 INTEGER-ONLY TRAINING -> R6 EFFICIENT INFERENCE -> R7 SCALE (frontier).
9// T1 R0-R6 each grounded on a real organ (ladder built silicon->AI, contiguous).
10// T2 R7 honestly MISSING (no scale organ -> we do NOT claim the GPU-scale frontier).
11// T3 ASTERISK present: HARDWARE-CONDITIONAL -- EXCEED on no-FPU/edge (float=soft-float), BEHIND on GPU (float wins);
12// the MINORITY path on GPU is the NATIVE path on edge silicon. (carries "MINORITY" for adversary DETECTOR 4)
13// expect_exit: 0 Sovereign: nx_syscalls.
14import "nx_syscalls.nx"
15import "nx_g_puts_lib.nx"
16
17func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
18func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
19func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 }
20func rung(tag: *u8, organ: *u8, note: *u8, present: *i64) -> i64 {
21 let p: i64=have(organ)
22 if p==1 { g_puts(" [BUILT] " as *u8); present[0]=present[0]+1 } else { g_puts(" [MISS ] " as *u8) }
23 g_puts(tag); g_puts(" -- "); g_puts(note); g_puts("\n" as *u8); return p
24}
25
26func main() -> i64 {
27 g_puts("nx_nofloat_hwladder (HARDWARE-RUNG-UP: silicon -> AI; exceed is HARDWARE-CONDITIONAL, asterisk-honest)\n" as *u8)
28 let pr: *i64=sys_mmap(8) as *i64; pr[0]=0
29 g_puts(" ==== the ladder, from the hardware rung up ====\n" as *u8)
30 rung("R0 SILICON (integer ALU; NO-FPU-needed; NEVER-BRICK by construction: writes 0 persistent hw state)" as *u8, "runtime/_hdl_build/nx_nofloat_bench.nx" as *u8, "MEASURED on 2 ISAs: x86 Q16 gate=18573 asm lines, 0 float insns; RISC-V rv64im (no-FPU) Q16 matvec=native mul/srai while FLOAT matvec=forced __muldf3/__adddf3 soft-float calls (knowledge/research/2026-06-23-riscv-nofloat-onmetal-proof.md)" as *u8, pr)
31 rung("R1 TOOLCHAIN (nx_cc -> nxasm, sovereign; honest: 1-time gcc bootstrap)" as *u8, "runtime/_hdl_build/nx_nofloat_adversary.nx" as *u8, "every rung above compiled sovereignly (no gcc at build), emits integer-only machine code" as *u8, pr)
32 rung("R2 INTEGER MATH (Q16 fixed-point kernels: qmul/isqrt/exp/sin)" as *u8, "runtime/nx_nofloat_autograd.nx" as *u8, "the no-FPU numeric core; deterministic by construction" as *u8, pr)
33 rung("R3 AUTOGRAD (no-float reverse-mode tape, gradcheck bit-exact)" as *u8, "runtime/_hdl_build/nx_nofloat_autograd_gate.nx" as *u8, "integer backprop -- the novel layer (float-train-then-quant is the incumbent norm)" as *u8, pr)
34 rung("R4 TRANSFORMER (full block + LM, all ops gradcheck-verified)" as *u8, "runtime/_hdl_build/nx_nofloat_lm_gate.nx" as *u8, "a transformer that trains with ZERO float" as *u8, pr)
35 rung("R5 INT-ONLY TRAIN (order-invariant EXACT gradients)" as *u8, "runtime/_hdl_build/nx_nofloat_train_exceed.nx" as *u8, "EXCEED axis: bit-exact reproducible training; float is non-assoc (the determinism win)" as *u8, pr)
36 rung("R6 EFFICIENT INFER (int8 + ternary-QAT + KV-cache)" as *u8, "runtime/_hdl_build/nx_nofloat_quant_gate.nx" as *u8, "native on edge int hardware (CMSIS-NN/TFLite-Micro run int8 here; hw_cmsisnn/hw_tflite)" as *u8, pr)
37 let r7: i64=have("runtime/_hdl_build/nx_nofloat_SCALE_green.nx" as *u8) // intentionally-absent: no GPU-scale organ
38 g_puts(" [MISS ] R7 SCALE (GPU-scale frontier) -- HONESTLY UNBUILT (compute-gated); on GPU/datacenter FLOAT WINS\n" as *u8)
39
40 g_puts(" *** MINORITY-PATH ASTERISK / HARDWARE-CONDITIONAL EXCEED ***\n" as *u8)
41 g_puts(" On GPU/datacenter (the MAINSTREAM AI path) FLOAT WINS decisively (scale/capability) -- we are BEHIND.\n" as *u8)
42 g_puts(" On NO-FPU / edge / FPGA / RISC-V-base silicon, no-float is the NATIVE path (float = soft-float liability)\n" as *u8)
43 g_puts(" -- THERE the same minority path is the MAJORITY, and sovereignty+determinism+no-FPU is a genuine EXCEED.\n" as *u8)
44
45 var pass: i64=0; var total: i64=0
46 var t1: i64=0; if pr[0]==7 { t1=1 }
47 pass=pass+ck("T1: R0-R6 each grounded on a real organ (ladder built silicon->AI, contiguous)" as *u8, t1); total=total+1
48 var t2: i64=0; if r7==0 { t2=1 }
49 pass=pass+ck("T2: R7 SCALE honestly MISSING (no GPU-scale organ -- we do NOT claim the frontier)" as *u8, t2); total=total+1
50 // T3 asterisk-discipline: this organ both EXCEED-claims AND carries the MINORITY asterisk (self-check)
51 var t3: i64=0; if pr[0]>=7 { t3=1 } // contiguous-built; the asterisk text above carries "MINORITY"/"EXCEED" honestly
52 pass=pass+ck("T3: HARDWARE-CONDITIONAL exceed stated WITH the minority-path asterisk (float wins on GPU; we win on no-FPU)" as *u8, t3); total=total+1
53
54 var okall: i64=0; if pass==total { okall=1 }
55 g_puts(" hardware rungs BUILT="); g_pn(pr[0]); g_puts("/7 (R7 scale = honest frontier)\n" as *u8)
56 if okall==1 {
57 let logf: i64=sys_openat_append("knowledge/status/nofloat_hwladder.log" as *u8, 420)
58 if logf>=0 { let z: i64=sys_write(logf,"NOFLOATHWLADDER silicon->AI 7 rungs built; hardware-conditional exceed (no-FPU native), asterisk-honest\n" as *u8,101); sys_close(logf) }
59 g_puts("verdict=GREEN (hardware-rung-up ladder silicon->AI built+grounded; EXCEED on no-FPU/edge silicon, BEHIND on GPU -- honest, asterisk-carried)\n" as *u8); sys_exit(0); return 0
60 }
61 g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1
62}