code wiki / (root) / nx_kda_gate.nx

nx_kda_gate.nx

buildroot/runtime/nx_kda_gate.nx

7108 B171 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_kda_gate.nx -- two things nx_nofloat_kda_gate does NOT cover: (A) the ALGEBRAIC IDENTITY that licenses the shipped kernel's factored update, and (B) the KDA:MLA interleave schedule, a separate census feature that no organ implemented. (A) WHY IT MATTERS. Kimi Linear (arXiv 2510.26692) states the rule as S_t = (I - beta k k^T) Diag(alpha) S_{t-1} + beta k v^T which literally builds a d_k x d_k matrix: O(d_k^2 * d_v). The shipped kernel (_hdl_build/nx_nofloat_kda.nx) does NOT do that -- it computes pred = k^T S, then S += k (x) beta(v-pred), which is O(d_k * d_v). That is a real optimisation and it is CORRECT only because (I - beta k k^T) is identity-plus-rank-1. nx_nofloat_kda_gate proves the kernel's BEHAVIOUR (overwrite, gating, determinism); nothing proved the factorisation itself. T1 does, over two steps from a NON-ZERO state -- one step from S=0 would agree even for a wrong factorisation. T3 guards against proving the identity on a DEGENERATE case: if k were a basis vector, (I - beta k k^T) would be diagonal and both forms would agree trivially. T3 asserts the off-diagonal term is non-zero, so T1 exercised the genuinely non-diagonal path. Deliberately NOT retested here (owned by nx_nofloat_kda_gate 5/5): delta-overwrite idempotence, per-channel vs scalar gating, bit-exact determinism. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_kda.nx nx_kda_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_kda.nx

imported by: nobody (leaf or entry point)

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

main gv_ctr sys_mmap gv_head gv_puts sys_write sys_mmap ↻ kg_state sys_mmap ↻ kg_step_factored kg_mul kg_step_naive sys_mmap ↻ kg_mul ↻ gv_check gv_puts ↻ kg_mul ↻ kdasched_kind kdasched_full_layers kdasched_kind ↻ kdasched_kv_cut_permille kdasched_full_layers ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat sys_write ↻ sys_close

structs

none

consts

25const KG_FP: i64 = 1024

functions

27func kg_mul(a: i64, b: i64) -> i64 { return (a * b) / KG_FP }
29func kg_state(dk: i64, dv: i64) -> *i64
called by 1: main calls 1: sys_mmap
37func kg_step_factored(S: *i64, dk: i64, dv: i64, alpha: *i64, beta: i64, k: *i64, v: *i64, sc: *i64) -> i64
called by 1: main calls 1: kg_mul
65func kg_step_naive(S: *i64, dk: i64, dv: i64, alpha: *i64, beta: i64, k: *i64, v: *i64) -> i64
called by 1: main calls 2: sys_mmapkg_mul
100func main() -> i64