nx_gguf_load_q4k_test.nx
buildroot/runtime/nx_gguf_load_q4k_test.nx
about
nx_gguf_load_q4k_test.nx -- focused smoke for Q4_K dequant.
Builds a synthetic GGUF with one Q4_K tensor (1 super-block, 256
values) and verifies the dequant:
d = 1.0 (f16 0x3C00) -> d_q10 = 1024
dmin = 0.0 -> dmin_q10 = 0
scales[0..7] = {1, 1, 1, 1, 2, 0, 0, 0} (only sc[4]=2 in high half)
mins[0..7] = {0, 0, 0, 0, 0, 0, 0, 0}
nibble byte 0: 0x32 -> low nibble 2, high nibble 3
nibble byte 64: 0x32 -> low nibble 2, high nibble 3
all other nibbles = 0
ggml layout (32-byte groups; group g -> sub-block 2g low / 2g+1 high)
+ Q24 super-scale (d=1.0 -> d_q24 = 2^24 = 16777216). byte 0 is
group 0 l=0 (low -> sub-block 0 out[0]; high -> sub-block 1 out[32]);
byte 64 is group 2 l=0 (low -> sub-block 4 out[128]; high -> sub-block
5, sc[5]=0, out[160]=0).
Expected Q24 outputs:
out[0] = 16777216 * sc[0]=1 * 2 - 0 = 33554432
out[32] = 16777216 * sc[1]=1 * 3 - 0 = 50331648
out[128] = 16777216 * sc[4]=2 * 2 - 0 = 67108864
everywhere else: 0
Tests both the low-half (is<4) and high-half (is>=4) scale unpacking
paths in nx_gguf_dequant_q4_k.
dependencies 6 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 36 | func main() -> i64 |