code wiki / (root) / nx_q4k_real_gemm.nx

nx_q4k_real_gemm.nx

buildroot/runtime/nx_q4k_real_gemm.nx

6043 B131 linesdepth 8pulls 21 transitivereach 0 importersview sourcekind tooltopic q4k
docsdependenciesstructsconstsfunctions

about

nx_q4k_real_gemm.nx -- the CPU SPEED PATH proven on a REAL Qwen weight: integer fused-dequant-dot vs f32. sd-server -> Nishi migration (CPU perf track, SOTA-grounded: llama.cpp/ggml = quantized-integer GEMM, not emulated f32). Reads the real `Huihui-Qwen3-4B-...-Q4_K_M.gguf`, takes blk.0.attn_q.weight (Q4_K), and computes one output-neuron's projection two ways over row 0: (A) INTEGER path -- `nx_q4k_dot_row_col` (fused dequant+dot, integer Q34 = Q24 weight x Q10 col; the FAST path) -> Q10 -> f32. Q24 super-scales are EXACT (Q10/Q14 underflow/flip-sign on real weights). (B) F32 path -- `nx_q4k_to_f32` (dequant to f32) + our emulated-f32 dot (the CORRECTNESS path). Gates: (1) fused Q34 == manual sum of `nx_gguf_dequant_q4_k` (Q24) x activation (Q10), BIT-EXACT (the fused kernel is correct on real weights); (2) integer(Q24)-path f32 ~ f32-path f32 within ~2%, both ~ +0.21576 (the true ggml row-0 dot). Bounded prefix read; only the one row is dequantized. license_tier: ORIGINAL

dependencies 16 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_strconv.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_placement.nx nx_gguf_load_lazy.nx nx_q4k_real_gemm.nx

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

imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_strconv.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_placement.nxnx_gguf_load_lazy.nxnx_q4k_matmul.nxnx_dequant_iter.nxnx_q4k_to_f32.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nx

imported by: nobody (leaf or entry point)

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

main sys_openat_rd 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_find_tensor nx_gguf_tensor_at nx_gguf_name_equals nx_gguf_tensor_at ↻ sys_openat_wr rg_emit sys_mmap ↻ nx_strconv_format_i64 sys_write nx_q4k_iter_alloc sys_mmap ↻ nx_q4k_dot_row_col nx_q4k_iter_init nx_le_read_u16 _gguf_f16_to_q24 nx_le_read_u8 nx_q4k_iter_scale _q4k_iter_scale_at nx_q4k_iter_min _q4k_iter_min_at nx_le_read_u8 ↻ nx_q4km_q20_to_q10 nx_q10_to_f32 nx_i32_to_f32 nx_gguf_dequant_q4_k nx_le_read_u16 ↻

structs

none

consts

none

functions

30func rg_emit(fd: i64, key: *u8, key_len: i64, value: i64) -> i64
44func main() -> i64