code wiki / _hdl_build / nx_cuda_readiness_census.nx
nx_cuda_readiness_census.nx source
↩ module page · 102 lines · 9346 B
1// nx_cuda_readiness_census.nx -- the DRIVING INSTRUMENT for the REAL CUDA goal (operator 2026-07-12: "done when we
2// can MEET cuda's capabilities + a path to SOTA-exceed"). Pointed at the actual CUDA stack, measured against OUR
3// organs, liar-killed. CRITIC = liar-kill (a claimed layer must cite a real organ file). ADVERSARY = the SPEC/CPU
4// TRAP: the ISA + submit path are cracked vs the SPEC MODEL and the compute libs run on the CPU -- neither is executing
5// on real GPU silicon, so we have not yet MET cuda on-GPU (but we already EXCEED on the determinism axis, measured).
6// Strategic split: MEETING cuda FOR OUR workloads = our kernels fast on the GPU (C0-C7, needs silicon); running
7// EXTERNAL cuda binaries additionally needs the API surface + PTX-ingest (a separate track). license_tier: ORIGINAL expect_exit: 0
8import "nx_syscalls.nx"
9const K_MAGIC_65536: i64 = 65536
10
11func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 }
13func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
14func fexists(path: *u8) -> i64 {
15 let szp: *i64 = sys_mmap(16) as *i64
16 let b: *u8 = sys_read_file(path, szp)
17 if (b as i64) == 0 { return 0 }
18 if szp[0] < 64 { return 0 }
19 return 1
20}
21func ocat(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a }
22
23func layer(rep: *u8, ro: *i64, name: *u8, solf: *u8, status: i64, note: *u8, sums: *i64) -> i64 {
24 var af: i64 = 0
25 if slen(solf) > 0 { af = fexists(solf) }
26 var verdict: i64 = 0
27 if status > 0 { if af == 1 { verdict = status } }
28 var liar: i64 = 0
29 if status > 0 { if af == 0 { liar = 1 } }
30 var o: i64 = ro[0]
31 o = ocat(rep, o, "LAYER " as *u8); o = ocat(rep, o, name)
32 if verdict == 2 { o = ocat(rep, o, " HAVE " as *u8) }
33 if verdict == 1 { o = ocat(rep, o, " PARTIAL " as *u8) }
34 if verdict == 0 { if liar == 1 { o = ocat(rep, o, " LIAR-KILL->GAP " as *u8) } }
35 if verdict == 0 { if liar == 0 { o = ocat(rep, o, " GAP " as *u8) } }
36 o = ocat(rep, o, note); o = ocat(rep, o, "\n" as *u8)
37 ro[0] = o
38 sums[0] = sums[0] + 1
39 if verdict == 2 { sums[1] = sums[1] + 1 }
40 if verdict == 1 { sums[2] = sums[2] + 1 }
41 if liar == 1 { sums[3] = sums[3] + 1 }
42 return verdict
43}
44
45func main() -> i64 {
46 hw("=== nx_cuda_readiness_census -- can we MEET cuda's capabilities (+ a path to exceed)? (the REAL goal) ===\n" as *u8)
47 var fails: i64 = 0
48 let rep: *u8 = sys_mmap(K_MAGIC_65536)
49 let ro: *i64 = sys_mmap(16) as *i64
50 let sums: *i64 = sys_mmap(64) as *i64
51 var o: i64 = 0
52 o = ocat(rep, o, "CUDA CAPABILITY CENSUS -- 2026-07-12. The CUDA stack measured against OUR organs (liar-killed). Determinism = our EXCEED axis.\n\n" as *u8)
53 ro[0] = o
54
55 layer(rep, ro, "CUDA driver/runtime API " as *u8, "" as *u8, 0, "GAP: no cuMemAlloc/cuMemcpy/cuLaunchKernel (or cudaMalloc/<<<>>>) surface -- only needed to run EXTERNAL cuda binaries; we drive the low-level submit path directly." as *u8, sums)
56 layer(rep, ro, "PTX ingest (run app PTX) " as *u8, "" as *u8, 0, "GAP: cannot INGEST + run an external app's PTX kernel (the external-compat track)." as *u8, sums)
57 layer(rep, ro, "PTX / kernel emit " as *u8, "runtime/_hdl_build/nx_ptx_emit.nx" as *u8, 1, "PARTIAL: nx_ptx_emit generates PTX; not a full CUDA-C front-end or ingest-and-run." as *u8, sums)
58 layer(rep, ro, "tensor-core SASS ISA " as *u8, "runtime/_hdl_build/nx_mma_asm.nx" as *u8, 2, "HAVE: HMMA/IMMA/QMMA encoder CRACKED bit-exact vs cuobjdump (Blackwell sm_120 + Ampere sm_86), gate 16/16." as *u8, sums)
59 layer(rep, ro, "submit -> execute (GPFIFO) " as *u8, "runtime/_hdl_build/nx_nv.nx" as *u8, 1, "PARTIAL: nx_nv/nx_kfd GPFIFO + doorbell submit CRACKED vs SPEC model (tinygrad-confirmed); NOT executing on real silicon." as *u8, sums)
60 layer(rep, ro, "device memory model " as *u8, "runtime/_hdl_build/nx_kfd.nx" as *u8, 1, "PARTIAL: alloc/H2D/D2H modeled in the submit shims; not exercised on real VRAM." as *u8, sums)
61 layer(rep, ro, "compute libs (GEMM/attn/DDP)" as *u8, "runtime/nx_nofloat_gemm.nx" as *u8, 2, "HAVE: deterministic integer GEMM (9.3 GOP/s, bit-exact) + byte-exact flash-attn + bit-identical distributed-train. CPU today, not GPU." as *u8, sums)
62 layer(rep, ro, "DETERMINISM exceed axis " as *u8, "runtime/nx_nofloat_gemm.nx" as *u8, 2, "HAVE + EXCEED: bit-exact reproducible math. cuBLAS float-accumulate is NON-deterministic BY CONSTRUCTION. Our defensible exceed lever (measured)." as *u8, sums)
63 let vsil: i64 = layer(rep, ro, "real-GPU execution (PERF) " as *u8, "" as *u8, 0, "GAP: THE KEYSTONE -- nothing runs on real silicon (WSL2 dead-end). Native-Linux/cloud flips submit+ISA+libs from spec/CPU to MEASURED GPU." as *u8, sums)
64 layer(rep, ro, "measure vs cuBLAS (accept) " as *u8, "runtime/nx_gpu_bench.nx" as *u8, 1, "PARTIAL: nx_gpu_bench harness + the cuBLAS bar (~70 TFLOP/s BF16) recorded; the OURS-on-GPU column is empty until real silicon." as *u8, sums)
65 // NEG-CONTROL (liar-kill teeth)
66 layer(rep, ro, "NEG-CONTROL phantom cuda " as *u8, "runtime/nx_cuda_phantom_absent.nx" as *u8, 2, "claims HAVE but has NO file -> the census must LIAR-KILL it to GAP (teeth check)." as *u8, sums)
67
68 let total: i64 = sums[0]; let have: i64 = sums[1]; let part: i64 = sums[2]; let liar: i64 = sums[3]
69 let score: i64 = (have*1000 + part*400) / total
70 hw("\n layers="); pn(total); hw(" HAVE="); pn(have); hw(" PARTIAL="); pn(part); hw(" GAP="); pn(total-have-part); hw(" liar-killed="); pn(liar); hw(" CUDA-CAPABILITY="); pn(score); hw("/1000\n" as *u8)
71
72 var t1: i64 = 0
73 if total >= 8 { t1 = 1 }
74 if t1 == 1 { hw("T1 PASS census grounded (>=8 layers)\n" as *u8) } else { fails=fails+1; hw("T1 FAIL\n" as *u8) }
75 var t2: i64 = 0
76 if liar >= 1 { t2 = 1 }
77 if t2 == 1 { hw("T2 PASS liar-kill BITES (phantom cuda -> GAP)\n" as *u8) } else { fails=fails+1; hw("T2 FAIL\n" as *u8) }
78 // T3 ADVERSARY spec/CPU trap: the real-silicon keystone is GAP -> we have NOT met cuda ON-GPU despite the strong spec/CPU stack.
79 var t3: i64 = 0
80 if vsil == 0 { t3 = 1 }
81 if t3 == 1 { hw("T3 PASS adversary SPEC/CPU-TRAP: real-GPU execution is GAP -> the ISA/submit are cracked vs SPEC, libs run on CPU; MEETING cuda on-GPU is unproven until the cloud keystone. (We DO exceed on determinism, measured.)\n" as *u8) } else { fails=fails+1; hw("T3 FAIL keystone not flagged\n" as *u8) }
82
83 o = ro[0]
84 o = ocat(rep, o, "\nCUDA-CAPABILITY " as *u8); let bb: *u8 = sys_mmap(32) as *u8; var bx: i64 = score; var bi: i64 = 31; if bx==0 { bb[bi]=48 as u8; bi=bi-1 } while bx>0 { bb[bi]=(48+bx%10) as u8; bx=bx/10; bi=bi-1 } var bj: i64 = bi+1; while bj<32 { rep[o]=bb[bj]; o=o+1; bj=bj+1 }
85 o = ocat(rep, o, "/1000. HONEST: the compute stack is MORE built than D3D-game (183) -- ISA cracked, compute libs deterministic, PTX emit -- but the real-silicon keystone is GAP, so 'MET cuda on-GPU' is unproven. We already EXCEED on determinism (measured).\n" as *u8)
86 o = ocat(rep, o, "\nSTRATEGIC SPLIT: 'MEET cuda FOR OUR workloads' (accelerate our LLM/image-gen) = OUR kernels running fast on the GPU (C-ladder, needs silicon), NOT the CUDA API surface. Running EXTERNAL cuda binaries additionally needs the API surface + PTX-ingest (separate track). Prioritize the C-ladder.\n" as *u8)
87 o = ocat(rep, o, "\nRACI: the cuda-exceed workstream exists; ensure a gpu-compute-runtime OWNER drives the C-ladder (grow the team, not Claude-per-organ).\n" as *u8)
88 o = ocat(rep, o, "\nC-LADDER to meet + exceed cuda (each rung a gate on real silicon):\n" as *u8)
89 o = ocat(rep, o, " C0 real-silicon bring-up (cloud): nx_nv/nx_kfd complete the RM/KFD tree on a rented GPU -> first sovereign kernel EXECUTES (semaphore writes 0xCAFEBABE).\n" as *u8)
90 o = ocat(rep, o, " C1 memcpy H2D/D2H measured GB/s. C2 FP32 GEMM (honest floor). C3 tensor-core BF16 GEMM (nx_mma_asm on silicon) -> measure vs cuBLAS ~70 TFLOP/s.\n" as *u8)
91 o = ocat(rep, o, " C4 IMMA INTEGER GEMM = deterministic AND fast (the exceed cuBLAS CANNOT match). C5 cuBLAS-competitive (>=90%) then EXCEED on locked Z-Image/LLM shapes + NVFP4/FP8.\n" as *u8)
92 o = ocat(rep, o, " C6 wire compute libs (GEMM/attn/DDP) onto the GPU backend. C7 a real LLM-forward / image-gen GEMM runs faster-or-equal AND deterministic -> SOTA-exceed.\n" as *u8)
93 rep[o] = 0 as u8
94 let fd: i64 = sys_openat_wr("knowledge/cuda_readiness_census.txt\x00" as *u8, 0x1a4)
95 sys_write(fd, rep, o); sys_close(fd)
96 hw("T4 report + C-ladder -> knowledge/cuda_readiness_census.txt ("); pn(o); hw(" bytes)\n" as *u8)
97
98 if fails == 0 { hw("CUDA-READINESS-CENSUS GREEN -- REAL goal measured: cuda-capability "); pn(score); hw("/1000; C0-C7 ladder + determinism-exceed named; keystone = real silicon (cloud)\n" as *u8); sys_exit(0); return 0 }
99 hw("CUDA-READINESS-CENSUS RED fails="); pn(fails); hw("\n" as *u8)
100 sys_exit(1)
101 return 1
102}