code wiki / (root) / nx_gen_rope_verify.nx

nx_gen_rope_verify.nx

buildroot/runtime/nx_gen_rope_verify.nx

5744 B132 linesdepth 6pulls 12 transitivereach 0 importersview sourcekind tooltopic gen
docsdependenciesstructsconstsfunctions

about

nx_gen_rope_verify.nx -- SOVEREIGN interleaved RoPE, verified vs the oracle. y[h][l][2j+r] = x[l][h][2j] * pe[l][j][r][0] + x[l][h][2j+1] * pe[l][j][r][1] pe holds a 2x2 rotation per (token l, pair j): [[cos, -sin], [sin, cos]], so r=0 gives x0*cos - x1*sin and r=1 gives x0*sin + x1*cos -- ordinary interleaved rotary embedding. Derived from rope.hpp's apply_rope (permute/reshape/repeat chain), not assumed. Usage: nx_gen_rope_verify <model> <x> <pe> <y> <head_dim> <n_heads> [rows] ⚠THE AXIS PERMUTATION IS THE WHOLE DIFFICULTY, and it is silent when wrong: input x is [head_dim, n_heads, L] -> index (l*n_heads + h)*head_dim + d output y is [head_dim, L, n_heads] -> index (h*L + l)*head_dim + d apply_rope permutes head and token axes. Reading either side in the other's order produces finite, plausible, entirely wrong numbers -- no NaN, no crash, just a silently different tensor. Both strides are therefore written out explicitly here rather than shared. pe memory index: ((l*(head_dim/2) + j)*2 + r)*2 + c -- ne = [2, 2, head_dim/2, L] Hardware __f32_* intrinsics in the hot loop, never the nx_f32_* software twins. license_tier: ORIGINAL

dependencies 8 imports · 0 importers

nx_syscalls.nx nx_le.nx nx_f32.nx nx_f32_div.nx nx_f32_cvt.nx nx_strconv.nx nx_genfix.nx nx_genver.nx nx_gen_rope_verify.nx

imports: nx_syscalls.nxnx_le.nxnx_f32.nxnx_f32_div.nxnx_f32_cvt.nxnx_strconv.nxnx_genfix.nxnx_genver.nx

imported by: nobody (leaf or entry point)

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

main nx_genver_emit sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ nx_strconv_format_i64 sys_write ↻ sys_mmap ↻ nx_strconv_parse_i64 nx_ascii_is_digit zrp_strlen nx_genfix_dims sys_mmap ↻ _gf_read_manifest sys_mmap ↻ _gf_cpyz nx_genfix_root sys_openat_rd sys_read sys_close nx_genfix_load _gf_path sys_mmap ↻ _gf_cpyz ↻ nx_genfix_root ↻ _gf_cpy sys_openat_rd ↻ sys_mmap ↻

structs

none

consts

none

functions

32func zrp_strlen(s: *u8) -> i64
called by 1: main
38func main(argc: i64, argv: *i64) -> i64