code wiki / (root) / nx_genblock.nx

nx_genblock.nx

buildroot/runtime/nx_genblock.nx

27273 B665 linesdepth 8pulls 23 transitivereach 6 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_genblock.nx -- shared DiT block primitives for the sovereign gen engine. Extracted from nx_gen_blockrun once a second consumer appeared (nx_gen_ditchain, which loops these over N layers). Copying them would have been the third instance of this lane's most expensive recurring mistake -- two implementations of one op drift, and the drift is silent because both produce finite plausible numbers. Everything here is layer-agnostic and model-agnostic: tensor names, dimensions and worker counts are arguments. Hot loops use the HARDWARE __f32_* intrinsics, never the nx_f32_* software IEEE-754 twins (measured 9-10x slower in this lane). license_tier: ORIGINAL

dependencies 13 imports · 6 importers

nx_syscalls.nx nx_le.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx nx_f16.nx nx_f32_exp.nx nx_f32_activations.nx nx_strconv.nx nx_genfix.nx nx_genblock.nx nx_gen_blockrun.nx nx_gen_ditchain.nx nx_gen_ditfull.nx nx_gen_embed_verify.nx nx_gen_lora_repr.nx nx_gen_lora_verify.nx

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

imports: nx_syscalls.nxnx_le.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.nxnx_f16.nxnx_f32_exp.nxnx_f32_activations.nxnx_strconv.nxnx_genfix.nxnx_genver.nxnx_genweights.nxnx_genarch.nx

imported by: nx_gen_blockrun.nxnx_gen_ditchain.nxnx_gen_ditfull.nxnx_gen_embed_verify.nxnx_gen_lora_repr.nxnx_gen_lora_verify.nx

structs

none

consts

542const BR_SCR_SLOTS: i64 = 24

functions

45func br_arch_bind(gw: *i64) -> i64
called by 3: mainmainmain calls 2: sys_mmapnx_arch_probe
57func br_arch_ready() -> i64
called by 1: br_block
64func br_puts(s: *u8) -> i64
called by 1: main calls 1: sys_write
69func br_strlen(s: *u8) -> i64
called by 10: mainmainmainmainmainmain+4
77func br_load_q8(model: *u8, name: *u8, in_dim: i64, out_dim: i64, scales_out: *i64) -> *u8
96func br_mm_band(w: *u8, scales: *i64, x: *u8, out: *u8,
called by 1: br_matmul calls 1: nx_le_write_u32
121func br_matmul(w: *u8, scales: *i64, x: *u8, out: *u8,
147func br_rmsnorm(x: *u8, w: *u8, mods: *i64, out: *u8, rows: i64, d: i64, eps: i64) -> i64
175func br_gate_resid(inner: *u8, tg: *i64, resid: *u8, out: *u8, rows: i64, d: i64) -> i64
199func br_sdpa_band(qrp: *u8, krp: *u8, qkv: *u8, aop: *u8,
271func br_swiglu_band(a: *u8, b: *u8, out: *u8, i0: i64, i1: i64) -> i64
284func br_fork_range(kind: i64, a: *u8, b: *u8, out: *u8, n: i64, nw: i64) -> i64
309func br_gw_q8(gw: *i64, name: *u8, in_dim: i64, out_dim: i64, scales_out: *i64) -> *u8
331func br_gw_f32(gw: *i64, name: *u8, n: i64) -> *u8
344func br_name_p(out: *u8, prefix: *u8, layer: i64, suffix: *u8) -> *u8
363func br_name(out: *u8, layer: i64, suffix: *u8) -> *u8
called by 1: main calls 2: sys_mmapnx_strconv_format_i64
383func br_adaln(gw: *i64, prefix: *u8, layer: i64, t_emb: *u8, out: *u8, embed_dim: i64, width: i64) -> i64
424func br_mmf32_band(w: *u8, x: *u8, out: *u8,
459func br_matmul_f32(w: *u8, x: *u8, out: *u8, rows: i64, in_dim: i64, out_dim: i64, nw: i64) -> i64
481func br_qk_rope(qkv: *u8, wqn: *u8, wkn: *u8, pe: *u8, qrp: *u8, krp: *u8,
544func br_block(gw: *i64, prefix: *u8, layer: i64, modulation: i64, cur: *u8, outb: *u8, scr: *i64,