nx_paradigm_neuromorphic_gate.nx source
↩ module page · 66 lines · 4614 B
1// nx_paradigm_neuromorphic_gate.nx -- honest cycle on the NEUROMORPHIC/spiking paradigm (next surfaced target).
2// Hypothesis (testable): event-driven SPIKING computation does FEWER ops than DENSE clock-driven, via sparsity.
3// Independent reference: a real op-count from a deterministic integrate-and-fire simulation -- dense polls
4// every neuron every timestep (M*T ops); spiking only processes actual spike events (spikes * fan-out).
5// Discipline (find where it LOSES too): spiking wins ONLY below the crossover firing-rate ~1/fanout; above it,
6// per-spike overhead beats dense. Record the REGIME where the paradigm pays, honestly -- not "spiking is
7// better". No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL
8import "nx_syscalls.nx"
9import "nx_gate_verdict.nx"
10
11func nm_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func nm_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); 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; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
13
14func main() -> i64 {
15 nm_puts("HONEST CYCLE on NEUROMORPHIC/spiking: does event-driven beat dense? measure WHERE it pays + where it doesn't\n\n" as *u8)
16 let M: i64=100
17 let T: i64=100
18 let F: i64=8 // fan-out per spike -> crossover firing-rate ~1/F = 12.5%
19 let dense_ops: i64 = M*T // clock-driven polls every neuron every timestep
20
21 // sweep firing rates via spike period (rate ~ 1/period)
22 let per: *i64 = sys_mmap(8*8) as *i64
23 per[0]=50; per[1]=16; per[2]=8; per[3]=4; per[4]=2; let NR: i64=5
24
25 nm_puts(" dense (clock-driven) ops = "); nm_num(dense_ops); nm_puts(" (constant) fan-out F="); nm_num(F); nm_puts("\n");
26 nm_puts(" firing% spikes spiking-ops winner\n");
27 var wins_sparse: i64=0
28 var loses_dense: i64=0
29 var crossover_rate: i64=0
30 var r: i64=0
31 while r<NR {
32 let p: i64=per[r]
33 var spikes: i64=0
34 var t: i64=0
35 while t<T { var i: i64=0
36 while i<M { if ((i*7+t*13)%p)==0 { spikes=spikes+1 } i=i+1 }
37 t=t+1 }
38 let spk_ops: i64 = spikes*F
39 let pct: i64 = 100/p
40 nm_puts(" "); nm_num(pct); nm_puts("% "); nm_num(spikes); nm_puts(" "); nm_num(spk_ops); nm_puts(" ");
41 if spk_ops < dense_ops { nm_puts("SPIKING (sparse pays)\n"); wins_sparse=wins_sparse+1 } else { nm_puts("dense (too active)\n"); loses_dense=loses_dense+1; if crossover_rate==0 { crossover_rate=pct } }
42 r=r+1
43 }
44
45 nm_puts("\n HONEST RECORD: spiking wins ONLY in the SPARSE regime (low firing); above ~"); nm_num(100/F); nm_puts("% firing, per-spike\n");
46 nm_puts(" overhead makes DENSE win. So neuromorphic PAYS for sparse/event-driven workloads, NOT universally.\n");
47 nm_puts(" Verdict for the evidence-map: NICHE-BUT-REAL (sparse-activity regime), measured -- not asserted.\n\n");
48
49 var pass: i64=0
50 var ttl: i64=0
51 ttl=ttl+1; nm_puts(" T1 full cycle ran: spiking vs dense op-counts measured across firing rates: "); if wins_sparse>0 { pass=pass+1; nm_puts("PASS\n") } else { nm_puts("FAIL\n") }
52 ttl=ttl+1; nm_puts(" T2 verifier has TEETH: spiking demonstrably WINS in the sparse regime (real op reduction): "); if wins_sparse>=2 { pass=pass+1; nm_puts("PASS\n") } else { nm_puts("FAIL\n") }
53 ttl=ttl+1; nm_puts(" T3 HONEST: spiking demonstrably LOSES in the dense regime (NOT universal -- the tempering): "); if loses_dense>=1 { pass=pass+1; nm_puts("PASS\n") } else { nm_puts("FAIL\n") }
54 ttl=ttl+1; nm_puts(" T4 crossover identified -> the regime where the paradigm pays is MAPPED (~"); nm_num(crossover_rate); nm_puts("% firing): "); if crossover_rate>0 { pass=pass+1; nm_puts("PASS\n") } else { nm_puts("FAIL\n") }
55
56 nm_puts("NX-PARADIGM-NEUROMORPHIC-GATE passed "); nm_num(pass); nm_puts("/"); nm_num(ttl)
57 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
58 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
59 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
60 let ctr__dry: *i64 = gv_ctr()
61 ctr__dry[0] = pass
62 ctr__dry[1] = ttl
63 let rc__dry: i64 = gv_verdict("PARADIGM-NEUROMORPHIC-GATE" as *u8, ctr__dry, "neuromorphic worked rigorously: NICHE-BUT-REAL for sparse workloads, crossover mapped -- evidence)" as *u8)
64 sys_exit(rc__dry)
65 return rc__dry
66}