code wiki / (root) / nx_nofloat_weightconv_gate.nx

nx_nofloat_weightconv_gate.nx

buildroot/runtime/nx_nofloat_weightconv_gate.nx

6331 B102 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_weightconv_gate.nx -- the BRIDGE: load REAL BF16 model weights -> no-float Q16 integer. To run a frontier open model (GLM-5 etc.) on the sovereign no-float stack we must convert its BF16/FP8 weights to our integer Q format -- and to keep the WEIGHTS themselves bit-exact reproducible, the conversion is PURE INTEGER (no float touches them). BF16 = top 16 bits of an f32: sign(1) exp(8) mant(7). value = (-1)^s * 2^(exp-127) * (1 + mant/128); Q16 = value*2^16 = (-1)^s * (128+mant) << (exp-118). Decoded with bit-shifts only -> DETERMINISTIC. Verified: synthetic BF16 (1.0/2.0/0.5/1.5/-1.0) convert EXACTLY, then a REAL BF16 tensor is read from a safetensors on disk (bounded read) + converted + sane. No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_stage_path.nx nx_nofloat_weightconv_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_stage_path.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main wc_puts sys_write bf16_to_q16 wc_num sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_write ↻ sp_models_path sp_models_root sp_resolve_root sp_env sys_openat_rd sys_mmap ↻ sys_read sys_close sp_match sp_take_value sp_slen sp_conf ep_open_rd sys_openat_rd ↻ sys_mmap ↻ ep_join sys_mmap ↻ sys_read ↻ sys_close ↻

structs

none

consts

none

functions

13func wc_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
14func wc_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 }
called by 1: main calls 2: sys_mmapsys_write
17func bf16_to_q16(bf: i64) -> i64
called by 1: main
31func main() -> i64