nx_nofloat_mla.nx
buildroot/runtime/nx_nofloat_mla.nx
about
nx_nofloat_mla.nx -- MLA (Multi-head Latent Attention, DeepSeek's marquee KV-compression) in no-float
integer SERVE convention (2026-07-15). The 2026-frontier attention: instead of caching full K,V (2*kv_dim
per token), x is DOWN-projected to a small latent c (LC-dim, LC << 2*kv_dim) which is the WHOLE KV cache;
K,V are UP-projected from c at attention time. The KEY property (provable by construction): serving from
the LC-dim latent cache produces the BYTE-IDENTICAL output as serving from a full-K,V cache -- LOSSLESS
compression, ratio (2*kv_dim)/LC. This lib gives BOTH paths so a gate can differential them.
NOPE variant (no RoPE) for rung 1 -- decoupled-RoPE (RoPE on a separate dim, since RoPE doesn't commute
with the up-projection) is rung 2. Composes proven primitives (mm_out_in / fx_exp / qmul); Q16 throughout,
deterministic (exact integer sums, positional tie-breaks). license_tier: ORIGINAL (lib: no main)
dependencies 2 imports · 3 importers
imports: nx_syscalls.nxnx_nofloat_llm.nx
imported by: nx_mla_import_probe.nxnx_nofloat_k3interleave.nxnx_nofloat_mla_gate.nx
structs
| none |
consts
| none |
functions
| 14 | func nmla_downproj(x: *i64, Wdkv: *i64, c: *i64, T: i64, D: i64, LC: i64) -> i64 |
| 19 | func nmla_upproj(c: *i64, Wuk: *i64, Wuv: *i64, K: *i64, V: *i64, T: i64, LC: i64, kvd: i64) -> i64 |
| 25 | func nmla_mha(Q: *i64, K: *i64, V: *i64, concat: *i64, T: i64, nh: i64, hd: i64, scale: i64, sc: *i64, at: *i64) -> i64 |
| 68 | func nmla_forward_latent(ap: *i64) -> i64 |
| 100 | func nmla_forward_fullkv(ap: *i64) -> i64 |