code wiki / (root) / nx_qwen_hybrid_attn.nx

nx_qwen_hybrid_attn.nx

buildroot/runtime/nx_qwen_hybrid_attn.nx

9027 B210 linesdepth 9pulls 28 transitivereach 0 importersview sourcekind tooltopic qwen
docsdependenciesstructsconstsfunctions

about

nx_qwen_hybrid_attn.nx -- the hybrid attention SUB-LAYER on real Qwen weights, gated vs the f32 path. sd-server -> Nishi migration (task#19). Wires the proven bricks into a real attention sub-layer: x -> RMSNorm(attn_norm F32) -> [Q,K integer Q4_K via nx_q4k_linear ; V f32 Q5_K] -> GQA attention (f32) -> O (attn_output Q5_K f32) -> residual. Gate: the hybrid output (integer Q/K) vs a pure-f32 reference (f32 Q/K), 2 tokens so attention actually mixes -> they must agree within 2% (the only difference is the Q/K quantization). Real blk.0, ggml-correct dequant throughout. Confirms the ASSEMBLY (conversions + flow), the pieces being individually verified. 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_attn.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_gqa_attention.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_to_f32 nx_q4k_block_to_f32

structs

none

consts

none

functions

32func ha_f32linear(w: *i64, od: i64, id: i64, act: *i64, nt: i64, out: *i64) -> i64
called by 1: main calls 2: nx_f32_addnx_f32_mul
48func ha_emit(fd: i64, key: *u8, kl: i64, v: i64) -> i64
62func main() -> i64