code wiki / (root) / nx_qwen_hybrid_ffn.nx

nx_qwen_hybrid_ffn.nx

buildroot/runtime/nx_qwen_hybrid_ffn.nx

8195 B202 linesdepth 9pulls 26 transitivereach 0 importersview sourcekind tooltopic qwen
docsdependenciesstructsconstsfunctions

about

nx_qwen_hybrid_ffn.nx -- the hybrid FFN (SwiGLU) sub-layer on real Qwen weights, gated vs the f32 path. sd-server -> Nishi migration (task#19, FFN half). Mirrors the verified attention sub-layer: x -> RMSNorm(ffn_norm F32) -> [gate,up integer Q4_K via nx_q4k_linear] -> SwiGLU (SiLU(gate)*up, f32) -> down (ffn_down Q5_K f32) -> residual. Gate: hybrid (integer gate/up) vs pure-f32 ref (f32 gate/up), 2 tokens, first 256 down outputs -> agree within 2%. Weights dequantized on-the-fly (12288-wide) to bound memory. Real blk.0, ggml-correct dequant. license_tier: ORIGINAL

dependencies 20 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_qwen_hybrid_ffn.nx

diagram shows first 10 each side; +10 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_linear.nxnx_q4k_to_f32.nxnx_q5_k_to_f32.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nxnx_f32_rmsnorm.nxnx_f32_activations.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 ↻ nx_le_read_u32 ↻ nx_q10_to_f32 nx_i32_to_f32 nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 ↻ nx_f32_rmsnorm nx_i32_to_f32 ↻ nx_f32_sqrt nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_exp_field ↻ nx_f32_mant_field ↻ _f32_isqrt _gguf_f32_to_q10 nx_q4k_iter_alloc sys_mmap ↻

structs

none

consts

none

functions

31func fn_q4kf32(buf: *u8, w_off: i64, od: i64, id: i64, act: *i64, nt: i64, out: *i64, rowbuf: *i64) -> i64
49func fn_emit(fd: i64, key: *u8, kl: i64, v: i64) -> i64
63func main() -> i64