code wiki / _hdl_build / nx_nofloat_serialize_gate.nx

nx_nofloat_serialize_gate.nx

buildroot/runtime/_hdl_build/nx_nofloat_serialize_gate.nx

5173 B84 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_serialize_gate.nx -- CAP-NF-SERIALIZE: sovereign model PERSISTENCE (save/load trained weights). You can't deploy a model you can't save -- this is the missing systems piece. Own binary format: [magic][n][WN[0..n-1]][weight arrays raw i64][checksum]. Pure integer, sovereign (sys_openat/read/write only). T1 ROUND-TRIP LOSSLESS: deserialized weights are BIT-IDENTICAL to the originals. T2 INTEGRITY: checksum recomputed from the loaded weights == the stored checksum. T3 TEETH: flipping one loaded value makes the recomputed checksum MISMATCH (corruption is detectable). expect_exit: 0 Sovereign: nx_syscalls only.

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gate_emit_lib.nx nx_nofloat_serialize_gate.nx

imports: nx_syscalls.nxnx_gate_emit_lib.nx

imported by: nobody (leaf or entry point)

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

main g_puts sys_write sys_mmap dini checksum serialize sys_openat_wr wi64 sys_mmap ↻ sys_write ↻ sys_write ↻ checksum ↻ sys_close deserialize sys_openat_rd ri64 sys_mmap ↻ sys_read sys_close ↻ sys_mmap ↻ sys_read ↻ g_pn sys_mmap ↻ sys_write ↻ g_check g_puts ↻ sys_openat_append sys_write ↻ sys_close ↻ sys_exit

structs

none

consts

10const MAGIC: i64 = 6219518 // "NVM1"-ish sovereign model magic

functions

13func dini(a: *i64, n: i64, sd: i64) -> i64 { var i: i64=0; while i<n { a[i]=(((i*7+sd*13+1)%97)-48)*131 + sd*7; i=i+1 } return 0 }
called by 1: main
14func wi64(fd: i64, v: i64) -> i64 { let c: *i64=sys_mmap(8) as *i64; c[0]=v; sys_write(fd, c as *u8, 8); return 0 }
called by 1: serialize calls 2: sys_mmapsys_write
15func ri64(fd: i64) -> i64 { let c: *i64=sys_mmap(8) as *i64; sys_read(fd, c as *u8, 8); return c[0] }
called by 1: deserialize calls 2: sys_mmapsys_read
16func checksum(W: *i64, WN: *i64, n: i64) -> i64 { var s: i64=0; var i: i64=0; while i<n { let a: *i64=W[i] as *i64; let cn: i64=WN[i]; var c: i64=0; while c<cn { s=s+a[c]; c=c+1 } i=i+1 } return s }
called by 2: serializemain
18func serialize(path: *u8, W: *i64, WN: *i64, n: i64) -> i64
29func deserialize(path: *u8, W2: *i64, WN2: *i64, n_expect: i64) -> i64
41func main() -> i64