code wiki / (root) / nx_crosshw_census.nx

nx_crosshw_census.nx source

↩ module page · 94 lines · 5405 B

1// nx_crosshw_census.nx -- measured HAVE/PARTIAL/GAP census for the cross-hardware perf-exceed program. 2// 3// Per [[feedback-no-wave-measured-exceed]]: gaps-first, no fake green. Each axis records (a) whether the 4// primitive FILE exists (verified live), and (b) the honest PURPOSE-status for the cross-hw-perf goal 5// (HAVE=2 / PARTIAL=1 / GAP=0) -- because a file can exist for a DIFFERENT purpose (nx_shard = data-shard, 6// nx_caption_emit = caption text-render) and must NOT count as purpose-ready. permil uses purpose-status. 7// -> /tmp/crosshw_census.txt 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10import "nx_tier.nx" 11import "nx_strconv.nx" 12 13// emit "name S=<status> F=<file-exists> :: <note>" and return purpose-status weight (0/1/2). 14// status: 2=HAVE, 1=PARTIAL, 0=GAP. Checks the evidence file exists (0/1). 15func cw_axis(fd: i64, name: *u8, nlen: i64, path: *u8, status: i64, note: *u8, nolen: i64) -> i64 { 16 var fexists: i64 = 0 17 if path != (0 as *u8) { 18 let f: i64 = sys_openat_rd(path) 19 if f >= 0 { fexists = 1; sys_close(f) } 20 } 21 let line: *u8 = sys_mmap(160) 22 var lo: i64 = 0 23 var i: i64 = 0 24 while i < nlen { line[lo] = name[i]; lo = lo + 1; i = i + 1 } 25 let s1: *u8 = " S=" as *u8 26 i = 0 27 while s1[i] != (0 as u8) { line[lo] = s1[i]; lo = lo + 1; i = i + 1 } 28 if status == 2 { line[lo] = 72 } else { if status == 1 { line[lo] = 80 } else { line[lo] = 71 } } // H/P/G 29 lo = lo + 1 30 let s2: *u8 = " F=" as *u8 31 i = 0 32 while s2[i] != (0 as u8) { line[lo] = s2[i]; lo = lo + 1; i = i + 1 } 33 line[lo] = 48 + fexists; lo = lo + 1 34 let s3: *u8 = " :: " as *u8 35 i = 0 36 while s3[i] != (0 as u8) { line[lo] = s3[i]; lo = lo + 1; i = i + 1 } 37 i = 0 38 while note[i] != (0 as u8) { line[lo] = note[i]; lo = lo + 1; i = i + 1 } // null-terminated (nolen ignored) 39 line[lo] = 0x0A; lo = lo + 1 40 sys_write(fd, line, lo) 41 return status 42} 43 44func cw_num(fd: i64, key: *u8, kl: i64, v: i64) -> i64 { 45 let line: *u8 = sys_mmap(64) 46 var lo: i64 = 0 47 var i: i64 = 0 48 while i < kl { line[lo] = key[i]; lo = lo + 1; i = i + 1 } 49 line[lo] = 0x3D; lo = lo + 1 50 let dec: *u8 = sys_mmap(32) 51 let nd: i64 = nx_strconv_format_i64(v, dec) 52 var k: i64 = 0 53 while k < nd { line[lo] = dec[k]; lo = lo + 1; k = k + 1 } 54 line[lo] = 0x0A; lo = lo + 1 55 return sys_write(fd, line, lo) 56} 57 58func main() -> i64 { 59 let fd: i64 = sys_openat_wr("/tmp/crosshw_census.txt" as *u8, 0x1a4) 60 if fd < 0 { return 30 } 61 var score: i64 = 0 62 let R: *u8 = "runtime/" as *u8 // (unused marker; paths below are full) 63 64 // ---- HAVE (proven this session / full stack) ---- 65 score = score + cw_axis(fd, "int-gemm-cpu-q4k-q5k" as *u8, 20, "runtime/nx_q4k_matmul.nx" as *u8, 2, "26x fused dequant+dot (nx_q4k/q5k_dot), ggml-correct" as *u8, 35) 66 score = score + cw_axis(fd, "precision-knob-q14q24" as *u8, 21, "runtime/nx_q4k_linear_hp.nx" as *u8, 2, "near-f32 at same speed (200x tighter)" as *u8, 37) 67 score = score + cw_axis(fd, "full-qwen-layer" as *u8, 15, "runtime/nx_qwen_hybrid_attn.nx" as *u8, 2, "attn+FFN verified on real weights" as *u8, 33) 68 score = score + cw_axis(fd, "gpu-simt-kernel-bodies" as *u8, 22, "runtime/nx_simt_sum_kernel.nx" as *u8, 2, "SIMT codegen + real kernel (sum/vec_add)" as *u8, 40) 69 score = score + cw_axis(fd, "network-egress-tls13" as *u8, 20, "runtime/nx_tls13.nx" as *u8, 2, "full TLS1.3 = the distributed transport" as *u8, 39) 70 71 // ---- PARTIAL (primitive exists but NOT wired/adapted for this goal) ---- 72 score = score + cw_axis(fd, "int8-simd-cpu" as *u8, 13, "runtime/nx_simd.nx" as *u8, 1, "i8x32/vdot exist; not wired into the GEMM yet" as *u8, 44) 73 score = score + cw_axis(fd, "threading-pool" as *u8, 14, "runtime/nx_thread_pool.nx" as *u8, 1, "exists; not wired into the GEMM yet" as *u8, 35) 74 score = score + cw_axis(fd, "spirv-vulkan-target" as *u8, 19, "runtime/_hdl_build/nx_spirv_validate.nx" as *u8, 1, "validator exists; full codegen target = gap" as *u8, 42) 75 score = score + cw_axis(fd, "gpu-launch-dispatch" as *u8, 19, "runtime/_hdl_build/nx_gpu_driver.nx" as *u8, 1, "driver research; OP_SIMT_LAUNCH_1D not shipped" as *u8, 46) 76 score = score + cw_axis(fd, "lora-dora-trainer" as *u8, 17, "runtime/nx_lora_pool.nx" as *u8, 1, "lora_pool+galx_export exist; DoRA/few-image = gap" as *u8, 48) 77 78 // ---- GAP (missing, or file exists for a DIFFERENT purpose) ---- 79 score = score + cw_axis(fd, "gpu-int8-int4-gemm-kernel" as *u8, 25, (0 as *u8), 0, "no quantized GPU GEMM kernel yet" as *u8, 31) 80 score = score + cw_axis(fd, "cross-vendor-amd-intel-apple" as *u8, 28, (0 as *u8), 0, "needs the Vulkan/SPIR-V path" as *u8, 27) 81 score = score + cw_axis(fd, "vlm-captioner-qwen-vl" as *u8, 21, "runtime/nx_caption_emit.nx" as *u8, 0, "caption_emit=text-render NOT VLM inference" as *u8, 42) 82 score = score + cw_axis(fd, "distributed-layer-shard-infer" as *u8, 29, "runtime/nx_shard.nx" as *u8, 0, "nx_shard=DATA-shard NOT layer-shard inference" as *u8, 45) 83 84 // ---- tally ---- 85 let n_axes: i64 = 14 86 let maxscore: i64 = n_axes * 2 87 let permil: i64 = score * 1000 / maxscore 88 cw_num(fd, "axes" as *u8, 4, n_axes) 89 cw_num(fd, "score_of_max" as *u8, 12, score) 90 cw_num(fd, "maxscore" as *u8, 8, maxscore) 91 cw_num(fd, "permil_HAVE" as *u8, 11, permil) 92 sys_close(fd) 93 return 0 94}