code wiki / (root) / nx_nofloat_mla.nx

nx_nofloat_mla.nx

buildroot/runtime/nx_nofloat_mla.nx

5662 B129 linesdepth 8pulls 16 transitivereach 4 importersview sourcekind librarytopic nofloat
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_nofloat_llm.nx nx_nofloat_mla.nx nx_mla_import_probe.nx nx_nofloat_k3interleave.nx nx_nofloat_mla_gate.nx

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

14func nmla_downproj(x: *i64, Wdkv: *i64, c: *i64, T: i64, D: i64, LC: i64) -> i64
19func nmla_upproj(c: *i64, Wuk: *i64, Wuv: *i64, K: *i64, V: *i64, T: i64, LC: i64, kvd: i64) -> i64
25func nmla_mha(Q: *i64, K: *i64, V: *i64, concat: *i64, T: i64, nh: i64, hd: i64, scale: i64, sc: *i64, at: *i64) -> i64
68func nmla_forward_latent(ap: *i64) -> i64
100func nmla_forward_fullkv(ap: *i64) -> i64