code wiki / (root) / nx_q6_k_to_f32.nx

nx_q6_k_to_f32.nx

buildroot/runtime/nx_q6_k_to_f32.nx

4888 B116 linesdepth 4pulls 6 transitivereach 61 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_q6_k_to_f32.nx -- bits-up Q6_K dequantization to IEEE 754 binary32. Q6_K super-block layout (per ggml v3 spec; clean-room). 210 bytes per super-block of 256 values: bytes [0..128] ql 128 bytes, 4-bit packed (low/high nibble) bytes [128..192] qh 64 bytes, 2-bit packed (4 pairs per byte) bytes [192..208] scales 16 i8 sub-block scales bytes [208..210] d f16 super-scale Dequant (per ggml dequantize_row_q6_K): Process super-block in 2 chunks of 128 values each (c in 0..1). Each chunk consumes 64 bytes of ql, 32 bytes of qh, 8 scales. Inside a chunk, l loops 0..31, producing 4 output positions per l: y[c*128 + l ] = d * sc[c*8 + (l/16) + 0] * q1 y[c*128 + l + 32] = d * sc[c*8 + (l/16) + 2] * q2 y[c*128 + l + 64] = d * sc[c*8 + (l/16) + 4] * q3 y[c*128 + l + 96] = d * sc[c*8 + (l/16) + 6] * q4 where: q1 = (ql[c*64 + l ] & 0x0F) | ((qh[c*32 + l] >> 0) & 3) << 4 - 32 q2 = (ql[c*64 + l + 32] & 0x0F) | ((qh[c*32 + l] >> 2) & 3) << 4 - 32 q3 = (ql[c*64 + l ] >> 4 ) | ((qh[c*32 + l] >> 4) & 3) << 4 - 32 q4 = (ql[c*64 + l + 32] >> 4 ) | ((qh[c*32 + l] >> 6) & 3) << 4 - 32 (Rewrite 2026-05-21 after live-fire on real Qwen2.5 showed the naive per-position algorithm doesn't match ggml's interleaving.) genealogy_id: ggml_q6_k_canon lineage_id: substrate_q6_k_to_f32_v1

dependencies 5 imports · 7 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_f32.nx nx_f32_cvt.nx nx_q6_k_to_f32.nx nx_f32_llama_layer_lazy_load.nx nx_gguf_load_f32.nx nx_q6_k_to_f32_test.nx nx_zimage_dequant_block.nx nx_zimage_real_op.nx nx_zimage_real_proj.nx nx_zimage_real_qkv.nx

imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_f32.nxnx_f32_cvt.nx

imported by: nx_f32_llama_layer_lazy_load.nxnx_gguf_load_f32.nxnx_q6_k_to_f32_test.nxnx_zimage_dequant_block.nxnx_zimage_real_op.nxnx_zimage_real_proj.nxnx_zimage_real_qkv.nx

structs

none

consts

36const NX_Q6_K_OK: nx_int = 0
37const NX_Q6_K_VPB: i64 = 256 // values per super-block
38const NX_Q6_K_BPB: i64 = 210 // bytes per super-block

functions

40func _q6k_emit(d_f32: i64, scale_u8: i64,
54func _nx_q6_k_block_to_f32(buf: *u8, base_off: i64, take: i64,
102func nx_q6_k_to_f32(buf: *u8, base_off: i64, n_values: i64,