code wiki / (root) / nx_q4k_dot_simd.nx

nx_q4k_dot_simd.nx

buildroot/runtime/nx_q4k_dot_simd.nx

11119 B275 linesdepth 8pulls 16 transitivereach 0 importersview sourcekind tooltopic q4k
docsdependenciesstructsconstsfunctions

about

nx_q4k_dot_simd.nx -- SIMD-accelerated Q4_K fused dot (vpmaddwd), bit-exact vs nx_q4k_dot_row_col. Perf-exceed applied to the Qwen GEMM. Reformulation (exact integer algebra): per sub-block, dot += Σ (d1*q - m0)*col = d1*(Σ q*col) - m0*(Σ col) = d1*sq - m0*sc sq = Σ q*col via one vpmaddwd accumulate (q i16 0..15, col i16 Q10). Optimizations vs v1: read qs bytes ONCE (extract lo+hi together), and take sc = Σ col from a PRECOMPUTED sub-block table (activation-only, constant across the dot -- free in a GEMM). col: both Q10 i64 (unused now except pack) + i16-packed. license_tier: ORIGINAL

dependencies 13 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_dot_simd.nx

diagram shows first 10 each side; +3 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_clock.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 ↻ ds_synth ds_pack4 nx_q4k_sc_precompute 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_q4k_dot_simd _gguf_f16_to_q24 ↻ nx_le_read_u16 ↻ nx_le_read_u8 ↻ ds_pack4 ↻ ds_hsum nx_clock_monotonic_ns

structs

none

consts

none

functions

23func ds_pack4(a: i64, b: i64, c: i64, d: i64) -> i64
called by 2: nx_q4k_dot_simdmain
27func ds_hsum(acc: *i64) -> i64
called by 1: nx_q4k_dot_simd
43func nx_q4k_sc_precompute(col_q10: *i64, n_blocks: i64, sc_pre: *i64) -> i64
called by 1: main
60func nx_q4k_dot_simd(buf: *u8, base_off: i64, n_blocks: i64, col_i16: *i64,
135func ds_emit(fd: i64, key: *u8, kl: i64, v: i64) -> i64
153func ds_synth(buf: *u8, nb: i64) -> i64
called by 1: main
175func main(argc: i64, argv: *i64) -> i64