code wiki / (root) / nx_genweights.nx

nx_genweights.nx

buildroot/runtime/nx_genweights.nx

11217 B290 linesdepth 6pulls 13 transitivereach 15 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_genweights.nx -- read model weights straight from a GGUF. The engine's weight source. Until now this lane read weights from fixtures the oracle tap had dumped. That was right for building a RULER -- the tap's f32 conversion is ggml's own dequantization, which is exactly what a differential test needs. It is wrong for an ENGINE: it means the sovereign path cannot run without first booting a third-party binary to export its weights, and it does not scale (one Z-Image layer is ~190MB of raw blocks; 36 layers is ~7GB of fixtures nobody should be dumping). ★ A RULER MAY DEPEND ON THE INCUMBENT. A RUNTIME MAY NOT. The GGUF's tensor names turn out to be EXACTLY the names sd.cpp uses internally ("model.diffusion_model.layers.0.attention.qkv.weight"), so this is a drop-in swap for the fixture loader -- verified by running the same block both ways and comparing. The file is mmapped whole (sys_map_file), not read: a 6.2GB model is paged in on demand and only the tensors actually touched ever reach RAM. HANDLE LAYOUT (i64 slots): [0]=mapped base, [1]=file length, [2]=*NxGgufHeader license_tier: ORIGINAL

dependencies 8 imports · 15 importers

nx_syscalls.nx nx_le.nx nx_f32.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_q8_0_to_f32.nx nx_safetensors_load.nx nx_genweights.nx nx_gen_archprobe.nx nx_gen_blockrun.nx nx_gen_ditchain.nx nx_gen_ditfull.nx nx_gen_embed_verify.nx nx_gen_lora_repr.nx nx_gen_lora_verify.nx nx_gen_modelid.nx nx_gen_pipecheck.nx nx_gen_zoo.nx

diagram shows first 10 each side; +0 more imports, +5 more importers in the complete lists below.

imports: nx_syscalls.nxnx_le.nxnx_f32.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nxnx_q8_0_to_f32.nxnx_safetensors_load.nx

imported by: nx_gen_archprobe.nxnx_gen_blockrun.nxnx_gen_ditchain.nxnx_gen_ditfull.nxnx_gen_embed_verify.nxnx_gen_lora_repr.nxnx_gen_lora_verify.nxnx_gen_modelid.nxnx_gen_pipecheck.nxnx_gen_zoo.nxnx_genarch.nxnx_genblock.nxnx_genlora.nxnx_genpipe.nxnx_genrole.nx

structs

none

consts

30const NX_GW_TYPE_F32: i64 = 0
31const NX_GW_TYPE_F16: i64 = 1
32const NX_GW_TYPE_Q8_0: i64 = 8
37const NX_GW_FMT_GGUF: i64 = 0
38const NX_GW_FMT_ST: i64 = 1
41const NX_GW_ST_F32: i64 = 100
42const NX_GW_ST_F16: i64 = 101
43const NX_GW_ST_BF16: i64 = 102
44const NX_GW_ST_F8E4M3: i64 = 103

functions

49func nx_gw_f8e4m3_to_f32(b: i64) -> i64
called by 1: nx_gw_to_f32_packed
67func nx_gw_open(path: *u8) -> *i64
112func _gw_st_find(gw: *i64, name: *u8, nl: i64, out: *i64) -> i64
160func nx_gw_ntensors(gw: *i64) -> i64
called by 4: mainmainmainmain
168func nx_gw_find(gw: *i64, name: *u8, nl: i64) -> i64
181func _gw_st_last(gw: *i64, out: *i64) -> i64
185func _gw_info(gw: *i64, idx: i64) -> *NxGgufTensorInfo
191func nx_gw_data(gw: *i64, idx: i64) -> *u8
202func nx_gw_type(gw: *i64, idx: i64) -> i64
211func nx_gw_dim0(gw: *i64, idx: i64) -> i64
220func nx_gw_dim1(gw: *i64, idx: i64) -> i64
237func nx_gw_to_f32_packed(gw: *i64, idx: i64, out: *u8, n_values: i64) -> i64