nemo_automodel.components.speculative.eagle.draft_kimi_k3
nemo_automodel.components.speculative.eagle.draft_kimi_k3
Kimi K3 (NoPE MLA backbone) EAGLE-3 draft model.
Kimi K3 interleaves Kimi Delta Attention (KDA) layers with Multi-head Latent
Attention (MLA) layers. The draft mirrors only the MLA layer, which differs from
the DeepSeek MLA the shared MLA draft (draft_deepseek) implements in three
ways:
- NoPE. K3 fixes
mla_use_nope=True: theqk_rope_head_dimslice is concatenated to the query and key heads unrotated, and no rotary embedding is applied anywhere in the MLA layer (positional information reaches the full attention layers through the interleaved KDA recurrence). The draft keeps that contract, so it registers no rotary cache and applies no per-TTT-step rotary phase offset. - Output gate.
mla_use_output_gate=Truemultiplies the attention output by a sigmoid gate projected from the layer input. - SiTU MLP. The feed-forward block is K3’s
SituAndMulgated MLP (KimiK3MLP), not SwiGLU, and every norm is K3’s fp32-varianceKimiRMSNorm.
Everything EAGLE-3 specific is inherited from the DeepSeek MLA draft: the
[embed, hidden] fused first layer, the cache_hidden = [K_list, V_list]
TTT recurrence with diagonal-extension attention, project_hidden_states /
compute_logits / set_vocab_mapping and the d2t / t2d buffers. The
SiTU MLP and the norm are imported from the onboarded K3 target
(components/models/kimi_k3.model) and the MLA projection layout and the gate
follow its KimiMLAAttention (widened to the fused [embed, hidden] input),
so the draft’s math matches the target’s MLA.
Scope: EAGLE-3 single fused draft layer, eager attention, dense draft (KDA,
routed experts and the attention-residual mixer stay in the target only). The
draft itself consumes the shared [B, 1, T, T] block-causal packed mask like
the DeepSeek MLA draft, but the recipe rejects sequence packing for a K3 target:
K3 owns its own packed-attention path, which the EAGLE-3 target wrapper does not
drive (see examples/speculative/eagle3/README_kimi_k3.md).
Module Contents
Classes
Data
API
Bases: Module
Inner backbone: embed_tokens, the fc aux-projection, the fused draft layer, and norm.
Bases: Module
Fused EAGLE-3 first layer: [embed, hidden] -> NoPE MLA -> SiTU MLP.
Fuse the embedding and hidden streams, then run attention and the MLP.
Parameters:
Tensor of shape [batch, sequence, hidden], the draft
token embeddings.
Tensor of shape [batch, sequence, hidden], the
projected target hidden states; also the residual stream.
Additive mask of shape [batch, 1, sequence, sequence].
Tensor of shape [batch, sequence]; unused (NoPE MLA).
TTT cache [K_list, V_list] forwarded to the attention.
Returns: torch.Tensor
Tensor of shape [batch, sequence, hidden].
Bases: DeepseekV3Eagle3DraftModel
Kimi K3 (NoPE MLA) EAGLE-3 draft model.
Same public training API as every other EAGLE-3 draft
(project_hidden_states / embed_input_ids / compute_logits /
set_vocab_mapping / freeze_embeddings / forward) and the same
d2t / t2d vocab-remap buffers, so the EAGLE-3 trainer and
checkpointing are reused unchanged; only the backbone is K3’s.
Bases: Eagle3DeepseekMLAAttention
NoPE MLA self-attention with an output gate for the Kimi K3 EAGLE-3 draft.
Reuses the DeepSeek draft’s TTT recurrence verbatim (_eager_attention_forward:
full T x T causal attention against the step-0 keys plus one diagonal column
per cached later step). Only the projections change: no rotary cache is built,
the rope slice rides along unrotated, and the attention output is gated. The
parent __init__ is bypassed deliberately — it registers a rotary buffer
that a NoPE layer must not carry.
Run one NoPE MLA step over the fused EAGLE-3 input.
Parameters:
Tensor of shape [batch, sequence, 2 * hidden], the
fused [normed embed, normed hidden] EAGLE-3 first-layer input.
Additive mask of shape [batch, 1, sequence, sequence].
Tensor of shape [batch, sequence]; unused (NoPE MLA).
TTT cache [K_list, V_list]; each list holds one entry
per TTT step, shaped [batch, heads, sequence, qk_head_dim] for
keys and [batch, heads, sequence, v_head_dim] for values.
Returns: torch.Tensor
Tensor of shape [batch, sequence, hidden].