code wiki / (root) / nx_nofloat_q6k_gate.nx

nx_nofloat_q6k_gate.nx

buildroot/runtime/nx_nofloat_q6k_gate.nx

8668 B155 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind gate/prooftopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_q6k_gate.nx -- sovereign Q6_K -> Q16 integer dequant (unlocks Qwen embeddings + LM head). Q4_K_M stores token_embd.weight and output.weight as Q6_K, which the substrate didn't ship -- so a faithful no-float forward needs this dequant. GGML Q6_K super-block = 256 values in 210 bytes: ql[128] (low 4 bits), qh[64] (high 2 bits), scales[16] (int8 per-16 sub-scale), d (f16 super-scale). value = d * scale * (q-32), q the assembled 6-bit quant -- done PURE INTEGER (f16->Q16 by bit-decode, then integer mults) so no float touches the weights (deterministic). Proven: (a) KAT scale path (scales=0 -> 0; scales=1 -> uniform -32); (b) KAT 6-bit unpack (ql=0x0F,qh=0x03 -> q=31 at y[0]); (c) the REAL Qwen Q6_K tensor dequants to sane integer weights; (d) deterministic. No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_gate_verdict.nx nx_nofloat_q6k_gate.nx

imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main q6_puts sys_write sys_mmap nx_le_write_u16 q6k_block_to_q16 q6_f16_to_q16 nx_le_read_u16 nx_le_read_u8 q6_i8 nx_le_read_u8 ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_gguf_parse nx_le_read_u32 nx_le_read_u64 nx_le_read_u32 ↻ _gguf_skip_value nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gguf_skip_value ↻ sys_mmap ↻ nx_gguf_tensor_at q6_num sys_mmap ↻ sys_write ↻ gv_ctr sys_mmap ↻ gv_verdict gv_puts sys_write ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal

structs

none

consts

none

functions

17func q6_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
18func q6_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
21func q6_f16_to_q16(h: i64) -> i64
called by 1: q6k_block_to_q16
31func q6_i8(buf: *u8, off: i64) -> i64 { let v: i64 = nx_le_read_u8(buf, off); if v>=128 { return v-256 } return v }
called by 1: q6k_block_to_q16 calls 1: nx_le_read_u8
34func q6k_block_to_q16(buf: *u8, super_off: i64, n_values: i64, out: *i64) -> i64
67func main() -> i64