code wiki / (root) / nx_blockfloat_stack_gate.nx

nx_blockfloat_stack_gate.nx

buildroot/runtime/nx_blockfloat_stack_gate.nx

11207 B188 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic blockfloat
docsdependenciesstructsconstsfunctions

about

nx_blockfloat_stack_gate.nx -- BLOCK-FLOAT weights through a STACKED (multi-block) transformer -- the step toward a full model. Chains the existing gradcheck-verified block forward (blk_fwd) N_LAYERS times (each block's output feeds the next), with the weights block-float quantized. Proves block-float COMPOSES through depth, and the key depth property: per-tensor INT8 degradation COMPOUNDS with depth, while block-float stays stable. 1 the stacked transformer RUNS with block-float weights (non-trivial output) 2 EXCEED: block-float stack error vs full-precision < per-tensor over N_LAYERS blocks 3 DETERMINISTIC: the block-float stack run twice == bit-identical 4 DEPTH: per-tensor error at depth N > per-tensor error at depth 1 (degradation compounds; block-float stable) expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_gate_verdict.nx nx_blockfloat_stack_gate.nx

imports: nx_nofloat_autograd.nxnx_syscalls.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bb_puts sys_write sys_mmap bf_quant_mat bf_scale_abs bb_abs bf_bitlen bf_quant_pt bf_scale_abs ↻ stack_fwd sys_mmap ↻ blk_out sys_mmap ↻ blk_fwd nfa_leaf nfa_new nfa_rmsnorm_rows nfa_new ↻ nfa_qmul nfa_isqrt nfa_matmul nfa_new ↻ nfa_rope nfa_new ↻ nfa_fxexp nfa_cosf nfa_reduce2pi nfa_cosq nfa_sinf nfa_reduce2pi ↻ nfa_sinq nfa_qmul ↻ nfa_matmul_nt nfa_new ↻ nfa_cmul nfa_new ↻ nfa_qmul ↻ nfa_softmax_rows nfa_new ↻

structs

none

consts

none

functions

14func bb_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: bb_chkmain calls 1: sys_write
15func bb_pn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
25func bb_chk(name: *u8, ok: i64) -> i64
called by 1: main calls 1: bb_puts
29func bb_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 2: bf_scale_absl1err
30func bf_bitlen(x: i64) -> i64 { var b: i64 = 0; var m: i64 = x; while m > 0 { m = m >> 1; b = b + 1 } return b }
called by 1: bf_scale_abs
31func bf_scale_abs(W: *i64, off: i64, B: i64, MB: i64) -> i64
38func bf_quant_mat(W: *i64, rows: i64, cols: i64, B: i64, MB: i64, out: *i64) -> i64
called by 1: main calls 1: bf_scale_abs
53func bf_quant_pt(W: *i64, n: i64, MB: i64, out: *i64) -> i64
called by 1: main calls 1: bf_scale_abs
60func blk_fwd(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, T: i64, dm: i64, ffn: i64, scale: i64, leaves: *i64) -> i64
92func blk_out(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, T: i64, dm: i64, ffn: i64, scale: i64, outY: *i64) -> i64
called by 1: stack_fwd calls 3: sys_mmapblk_fwdnfa_val
100func stack_fwd(tape: *i64, vals: *i64, st: *i64, X: *i64, Wq: *i64, Wk: *i64, Wv: *i64, Wo: *i64, Wg: *i64, Wu: *i64, Wd: *i64, T: i64, dm: i64, ffn: i64, scale: i64, N_LAYERS: i64, outY: *i64) -> i64
called by 1: main calls 2: sys_mmapblk_out
116func l1err(a: *i64, b: *i64, n: i64) -> i64 { var e: i64 = 0; var i: i64 = 0; while i < n { e = e + bb_abs(a[i] - b[i]); i = i + 1 } return e }
called by 1: main calls 1: bb_abs
118func main() -> i64