code wiki / (root) / nx_trig_kat.nx

nx_trig_kat.nx

buildroot/runtime/nx_trig_kat.nx

2806 B55 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_trig_kat.nx -- KAT for nx_f32_cos/nx_f32_sin at rope-realistic arguments. RoPE at position p rotates the i=0 (highest-freq) dim by angle p -> cos(p)/sin(p) for p up to seq_len. If the range reduction is only good near 0, varied multi-token sequences get corrupted rope on the fast dims (masked by repetition = the residual bug after the QKV-bias fix). Self-consistency check: cos^2+sin^2 == 1.0 (0x3F800000) for ALL args; a deviation at larger args localizes a range-reduction bug. Also checks cos(0)=1, sin(0)=0. expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_f32.nx nx_f32_sincos.nx nx_trig_kat.nx

imports: nx_syscalls.nxnx_tier.nxnx_f32.nxnx_f32_sincos.nx

imported by: nobody (leaf or entry point)

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

main pw sys_write nx_f32_cos nx_f32_classify nx_f32_exp_field nx_f32_mant_field _sc_range_reduce_pk nx_f32_mul nx_f32_classify ↻ nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ _sc_f32_to_i32_rne nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_exp_field ↻ nx_f32_mant_field ↻ nx_i32_to_f32 nx_f32_sub nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_neg _sc_cos_poly nx_f32_mul ↻ nx_f32_neg ↻ nx_f32_add ↻ nx_f32_neg ↻ _sc_sin_poly nx_f32_mul ↻ nx_f32_neg ↻ nx_f32_add ↻ nx_f32_sin nx_f32_classify ↻ _sc_range_reduce_pk ↻ _sc_sin_poly ↻ _sc_cos_poly ↻

structs

none

consts

none

functions

11func pw(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: onemain calls 1: sys_write
12func ph(v: i64) -> i64 { let b: *u8=sys_mmap(8); var i: i64=0; while i<8 { let nib: i64=(v>>((7-i)*4))&0xF; if nib<10 {b[i]=(48+nib) as u8} else {b[i]=(87+nib) as u8} i=i+1 } sys_write(1,b,8); return 0 }
called by 2: onemain calls 2: sys_mmapsys_write
15func near_one(sum: i64) -> i64
called by 1: one
22func one(label: *u8, x: i64) -> i64
34func main() -> i64