Expand description
2026-09-25: Kimi K3 in the engine: the bound decoder layer, its per-sequence state, and the CUDA launches for the KDA and MLA mixers, the packed LatentMoE experts and the dense MLP.
The CPU reference math is re-exported from metrale_model_weights::kimi_k3_host.
Owner: model-arch, Kimi K3. Invariants: none beyond the types.
Re-exports§
pub use device_cache::DeviceHybridCache;pub use device_cache::DeviceLayerCache;pub use kda_cuda::K3KdaDecodeKernels;pub use kda_cuda::KdaDeviceState;pub use kda_cuda::launch_k3_kda_decode_token;pub use kda_cuda::launch_k3_kda_decode_token_on_device;pub use mla_cuda::K3MlaDecodeKernels;pub use mla_cuda::MlaDeviceKv;pub use mla_cuda::launch_k3_mla_decode_token;pub use mla_cuda::launch_k3_mla_decode_token_on_device;pub use moe_cuda::K3MoeGemmKernels;pub use moe_cuda::launch_k3_latent_moe_experts;pub use tp::supports_tp;pub use tp::tensor_plan;pub use state::K3CpuFallbackState;
Modules§
- bound
- 2026-09-25:
K3BoundLayer, the Kimi K3 decoder layer the engine binds, andK3HostShared, the state its layers share. - dense_
cuda - 2026-09-25: CUDA SiTU-GLU MLP for Kimi K3 (a dense layer’s MLP or a LatentMoE layer’s shared expert) on the resident BF16/FP32 weights, with FP32 activations.
- device_
cache - 2026-09-25:
DeviceHybridCache: device copies of every layer’s Kimi K3 mixer state, built from a hostHybridCache. - kda
- 2026-09-25: Re-exports the Kimi K3 KDA CPU reference,
metrale_model_weights::kimi_k3_host::kda. - kda_
cuda - 2026-09-25: Host launch of the Kimi K3 KDA decode kernels (PTX module
MODULE) for one token. - latent_
moe - 2026-09-25: Re-exports the Kimi K3 LatentMoE CPU reference (latent down projection, sigmoid top-k router, SiTU-GLU experts, up projection),
metrale_model_weights::kimi_k3_host::latent_moe. - mla
- 2026-09-25: Re-exports the Kimi K3 gated NoPE MLA CPU reference,
metrale_model_weights::kimi_k3_host::mla. - mla_
cuda - 2026-09-25: Host launch of the Kimi K3 MLA decode kernels (PTX module
MODULE) for one token. - moe_
cuda - 2026-09-25: Host launch of the Kimi K3 packed LatentMoE experts on the MXFP4 E8M0 pointer-table GEMM,
PTRTABLE_E8M0in PTX moduleMODULE. - state
- 2026-09-25:
K3CpuFallbackState, one sequence’s Kimi K3 mixer state: the hostLayerCacheand the device copies the CUDA mixers use. - tp
- 2026-09-25: The Kimi K3 tensor-parallel plan (
metrale_model_weights::kimi_k3_host::tp::tensor_plan) inTpShardKindterms.
Structs§
- Ablation
- Graph mutants. Mix=0 / force-expert-0 are C1; skip-layer is C2;
o_projTP is C7. - Attn
ResHub - Stream map keyed by hidden/residual pointer bits (
DevicePtr.0). Layer 0 inserts; last layerremoves on success. AnyErrdrops the entry (umbrella940bd4eeb). - Hybrid
Cache - Per-sequence hybrid cache. Slot identity is the layer index; a prefix hit that writes KDA state into the wrong slot is the C4 mutant.
- K3Cpu
Model - CPU twin (or tiny stand-in) ready for greedy decode.
- K3Graph
- K3Layer
Spec - KdaConfig
- KDA geometry. Tiny dims are legal for CPU tests; production is 128/4.
- KdaState
- Per-sequence KDA state. Both buffers are FP32, read-modify-write.
- Latent
MoeConfig - MlaConfig
- MlaKv
- One MLA layer’s host KV (unpaged CPU stand-in).
Enums§
Constants§
- KDA_
L2_ EPS - FLA
use_qk_l2norm_in_kerneleps. CUDAk3_kda_recurrent_step_f32uses the same.
Functions§
- attnres_
blend - Test / ablation lever:
mix=0returnsskip;mix=1returnsmixed. - attnres_
mix - Apply AttnRes with an explicit mix lever.
mix=0is identity skip. - attnres_
softmax_ mix - Softmax mixture over residual sources.
sources[0]is conventionally the skip (current partial block).queryis[hidden](*_res_proj). - cuda_
kda_ enabled - LinearAttention BoundLayer uses CUDA
kda_decodeunlessK3_CUDA_KDA=0. Projections, AttnRes, and MLP stay on the host either way. - cuda_
mla_ enabled - FullAttention BoundLayer uses CUDA
mla_decodeunlessK3_CUDA_MLA=0. Same polarity asK3_CUDA_KDA. Projections stay on the host either way. - gated_
mla_ attend - Gated NoPE attend: optionally skip RoPE, SDPA, optional output gate.
- greedy_
decode - Greedy decode. Returns
prompt || new_tokens(lengthprompt.len() + max_new). - kda_
decode_ token - One decode token: conv update then recurrent step.
- kda_
from - Map parsed
ModelConfigonto KDA geometry. - latent_
moe_ forward - Routed latent path + optional shared expert (identity-scale for tests).
- mix_
routed_ experts - Mix selected SiTU-GLU experts into latent. Empty
w1means packed-only (no host dequant) — CUDA grouped GEMM must have run instead. - mla_
decode_ token - One decode token: optional RoPE, append K/V, SDPA, optional output gate.
Projections stay in
mla_mixer. CUDAk3_mla_*matches this order. - mla_
from - moe_
from - sigmoid_
topk - noaux_tc: sigmoid(logits) for mix weights;
scores + biasonly ranks. - situ_
glu - One SiTU-GLU coordinate. Product is bounded by
|β1 * β2|. - situ_
glu_ vec - Elementwise SiTU-GLU over paired gate/up vectors.
- softcap
- Smooth cap.
betamust be finite and non-zero.