code wiki / _hdl_build / nx_nofloat_k3block.nx
nx_nofloat_k3block.nx
buildroot/runtime/_hdl_build/nx_nofloat_k3block.nx
about
nx_nofloat_k3block.nx -- LOGICALLY-INTEGRATED K3-style transformer BLOCK in no-float (operator 2026-07-19
"logically integrated"). Proves the scattered K3 primitives COMPOSE into one deterministic block, not just
exist as separate gates. Minimal K3 block = the KDA/linear-attention sublayer + a SwiGLU-ish FFN sublayer,
both with residual connections (the DeepSeek-V3/Moonlight skeleton the real K3 uses):
attn_in = x ; q,k,v = x.Wq, x.Wk, x.Wv ; a = linattn(q,k,v) ; h = x + a.Wo (KDA sublayer + residual)
f = relu(h.W1).W2 ; out = h + f (FFN sublayer + residual)
All PURE INTEGER Q16 (matvec accumulate-then-shift + the proven linear-attn kernel) = bit-exact
deterministic K3-style block. Composes nx_nofloat_linattn (the KDA foundation). Grounded arXiv 2510.26692.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 2 imports · 2 importers
imports: nx_nofloat_linattn.nxnx_syscalls.nx
imported by: nx_nofloat_k3block_gate.nxnx_nofloat_k3stack.nx
structs
| none |
consts
| 13 | const K3_QBITS: i64 = 16 |
| 14 | const K3_DMAX: i64 = 16 |
| 15 | const K3_FFMAX: i64 = 32 |
functions
| 18 | func k3_matmul(x: *i64, w: *i64, y: *i64, t: i64, d: i64, n: i64) -> i64 |
| 34 | func k3_add(a: *i64, b: *i64, out: *i64, t: i64, d: i64) -> i64 |
| 40 | func k3_relu(a: *i64, t: i64, d: i64) -> i64 |
| 46 | func k3_block(x: *i64, wq: *i64, wk: *i64, wv: *i64, wo: *i64, w1: *i64, w2: *i64, out: *i64, t: i64, d: i64, dff: i64) -> i64 |