code wiki / (root) / nx_gguf_load.nx

nx_gguf_load.nx

buildroot/runtime/nx_gguf_load.nx

28336 B747 linesdepth 5pulls 7 transitivereach 251 importersview sourcekind librarytopic gguf
docsdependenciesstructsconstsfunctions

about

nx_gguf_load.nx -- GGUF tensor lookup + dequantize composer. L4 brick that bridges nx_gguf_parse (header + tensor_info walker, SHIPPED) into NxTensor (L1 container, SHIPPED) by: 1. Finding a tensor by name in a parsed header 2. Computing the data byte-size of any GGML-format tensor 3. Dequantizing F32 / F16 / Q8_0 tensor data into Q10 i64 NxTensor This is the brick that lets nx_llm_run.nx leave its v1 "API- composition proof" scaffold behind and become a real runner sourcing weights from a real Llama / Mistral / Qwen / Z-Image GGUF file. Bits-up composition (every primitive cited already SHIPPED canonical): nx_le.nx -- IEEE-LE binary readers nx_gguf.nx -- header + tensor_info parser nx_tensor.nx -- NxTensor + nx_t_alloc nx_loop.nx -- bounded-loop discipline Format spec sources (public-domain documentation; no copied code): GGUF v3 format -- gguf.md in ggml repo (Gerganov 2024) ggml block_q8_0 layout -- ggml docs IEEE 754 binary32 / binary16 -- IEEE standard genealogy_id: gguf_format_gerganov_2024 + ieee754_binary32_binary16 lineage_id: substrate_gguf_loader_v1_f32_f16_q8

dependencies 6 imports · 136 importers

nx_syscalls.nx nx_tier.nx nx_loop.nx nx_le.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_actor_role_llm_v2_real_test.nx nx_batched_gate.nx nx_batched_tput.nx nx_chat_warmcache.nx nx_coder_gen_f32.nx nx_coder_swap_gate.nx nx_companion_chat.nx nx_companion_voice.nx nx_dequant_bench.nx nx_dequant_bench_test.nx

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

imports: nx_syscalls.nxnx_tier.nxnx_loop.nxnx_le.nxnx_tensor.nxnx_gguf.nx

imported by: nx_actor_role_llm_v2_real_test.nxnx_batched_gate.nxnx_batched_tput.nxnx_chat_warmcache.nxnx_coder_gen_f32.nxnx_coder_swap_gate.nxnx_companion_chat.nxnx_companion_voice.nxnx_dequant_bench.nxnx_dequant_bench_test.nxnx_dequant_iter.nxnx_dequant_iter_bench_test.nxnx_dequant_iter_test.nxnx_embed_bench.nxnx_f32_bpe_load.nxnx_f32_bpe_load_test.nxnx_f32_embed_gate.nxnx_f32_lazy_weight_test.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm_bench_test.nxnx_f32_llm_chat_test.nxnx_f32_llm_cohere_test.nxnx_f32_llm_diag_test.nxnx_f32_llm_dim_dump_test.nxnx_f32_llm_embed_diag_test.nxnx_f32_llm_live_dims_test.nxnx_f32_llm_live_gen_test.nxnx_f32_llm_live_load_only_test.nxnx_f32_llm_live_load_test.nxnx_f32_llm_probe.nxnx_f32_llm_read_dims.nxnx_f32_llm_read_dims_test.nxnx_f32_llm_serve.nxnx_f32_llm_special_tokens_test.nxnx_f32_q4k_matmul.nxnx_f32_q4k_matmul_test.nxnx_f32_qwen_capital_gate.nxnx_gguf_dequant_kat_gate.nxnx_gguf_fixture_tiny.nxnx_gguf_load_block.nxnx_gguf_load_block_test.nxnx_gguf_load_f32.nxnx_gguf_load_f32_test.nxnx_gguf_load_lazy.nxnx_gguf_load_lazy_test.nxnx_gguf_load_model.nxnx_gguf_load_model_test.nxnx_gguf_load_q4k_test.nxnx_gguf_load_test.nxnx_gguf_meta.nxnx_gguf_typecensus.nxnx_gpu_export.nxnx_gpu_serve_gate.nxnx_live_fire_gguf.nxnx_live_fire_gguf_test.nxnx_llm_argmax_probe.nxnx_llm_batch_serve.nxnx_llm_capcheck.nxnx_llm_diff_probe.nxnx_llm_forward_profile.nxnx_llm_france_probe.nxnx_llm_layerlens_probe.nxnx_llm_loopb_gate.nxnx_llm_ppl_bench_gate.nxnx_llm_run_v2.nxnx_llm_run_v2_test.nxnx_llm_sched_gate.nxnx_lowrank_kv_real.nxnx_lowrank_weight_spectrum.nxnx_nofloat_arch_config_gate.nxnx_nofloat_arch_moe_gate.nxnx_nofloat_llm.nxnx_nofloat_moe_real_gate.nxnx_nofloat_olmoe_forward_gate.nxnx_nofloat_olmoe_gate.nxnx_nofloat_q6k_gate.nxnx_nofloat_qwen_bias_probe.nxnx_nofloat_qwen_diag_gate.nxnx_nofloat_qwen_dqprobe_gate.nxnx_nofloat_qwen_fastgen_gate.nxnx_nofloat_qwen_fastgen_i32_gate.nxnx_nofloat_qwen_fastgen_i8_gate.nxnx_nofloat_qwen_fidelity_gate.nxnx_nofloat_qwen_forward_gate.nxnx_nofloat_qwen_gen_gate.nxnx_nofloat_qwen_kvgen_gate.nxnx_nofloat_qwen_rope_h2h_gate.nxnx_nofloat_qwen_stack_gate.nxnx_nofloat_qwen_text_gate.nxnx_nofloat_qwen_tok_gate.nxnx_nofloat_qwen_wload_gate.nxnx_nofloat_serve_core.nxnx_olmoe_recon2_gate.nxnx_paged_fwd_gate.nxnx_placement.nxnx_q4k_dot_simd.nxnx_q4k_fused_fidelity_gate.nxnx_q4k_gemm_mt.nxnx_q4k_ggml_kat.nxnx_q4k_linear.nx +36 more (shown cap 100 declared)

structs

none

consts

51const NX_MAGIC_8388607: i64 = 8388607
52const NX_MAGIC_8192: i64 = 8192
53const NX_MAGIC_1024: i64 = 1024
54const NX_MAGIC_2047: i64 = 2047
55const NX_MAGIC_16384: i64 = 16384
56const NX_MAGIC_32767: i64 = 32767
57const NX_MAGIC_32752: i64 = 32752
61const NX_GL_OK: nx_int = 0
62const NX_GL_ERR_NOT_FOUND: nx_int = 1
63const NX_GL_ERR_BAD_TYPE: nx_int = 2
64const NX_GL_ERR_BAD_SHAPE: nx_int = 3
65const NX_GL_ERR_OOB: nx_int = 4
66const NX_GL_ERR_OOM: nx_int = 5
67const NX_GL_ERR_OVERFLOW: nx_int = 6
68const NX_GL_N_VERDICTS: nx_int = 7
90const NX_GL_Q8_0_VPB: nx_int = 32
91const NX_GL_Q8_0_BPB: nx_int = 34
92const NX_GL_Q4_0_VPB: nx_int = 32
93const NX_GL_Q4_0_BPB: nx_int = 18
94const NX_GL_Q4_K_VPB: nx_int = 256
95const NX_GL_Q4_K_BPB: nx_int = 144
98const NX_GL_Q10: nx_int = 1024
109const NX_GL_Q14: nx_int = 16384
114const NX_GL_Q10_INF_SAT: i64 = 0x1000000000000000
412const NX_GL_Q24: i64 = 16777216 // 2^24

functions

70func nx_gl_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
122func nx_gguf_name_equals(ti: *NxGgufTensorInfo,
called by 1: nx_gguf_find_tensor
144func nx_gguf_find_tensor(hdr: *NxGgufHeader,
161func nx_gguf_ggml_values_per_block(ggml_type: i64) -> nx_int
170func nx_gguf_ggml_bytes_per_block(ggml_type: i64) -> nx_int
183func nx_gguf_tensor_n_values(ti: *NxGgufTensorInfo) -> i64
194func nx_gguf_tensor_data_bytes(ti: *NxGgufTensorInfo) -> i64
230func _gguf_f32_to_q10(raw: i64) -> i64
277func _gguf_f32_to_q14(raw: i64) -> i64
called by 1: main
317func _gguf_f16_to_q10(raw: i64) -> i64
366func _gguf_f16_to_q14(raw: i64) -> i64
414func _gguf_f16_to_q24(raw: i64) -> i64
439func nx_gguf_dequant_f32(buf: *u8, base_off: i64, n_values: i64,
456func nx_gguf_dequant_f16(buf: *u8, base_off: i64, n_values: i64,
483func nx_gguf_dequant_q8_0(buf: *u8, base_off: i64, n_values: i64,
566func nx_gguf_dequant_q4_k(buf: *u8, base_off: i64, n_values: i64,
668func nx_gguf_dequant_q4_k_q14(buf: *u8, base_off: i64, n_values: i64,
688func nx_gguf_load_tensor(buf: *u8, hdr: *NxGgufHeader,