nemo_automodel.components.speculative.dspark.draft_deepseek_v4
nemo_automodel.components.speculative.dspark.draft_deepseek_v4
DSpark speculative-decoding draft model with a DeepSeek V4 attention backbone.
This mirrors the Qwen3 DSpark draft (draft_qwen3.py) structurally; only the
attention internals, MLP, and rotary plumbing are swapped for DeepSeek V4. The
draft runs dense, non-causal attention over a [context | noise-block] layout,
with visibility supplied entirely by the DFlash additive attention mask. There is
no compressor / indexer / sparse-attention path (the draft is always dense; V4’s
sparse machinery belongs to the target model, not this draft).
Module Contents
Classes
Data
API
Bases: Module
Dense, non-causal V4 attention over a [context | noise-block] layout.
Reuses DeepSeek V4’s Q-LoRA, single shared K=V latent, grouped O-LoRA, and the
per-head attention sink. Queries come from the noise block only, while the
shared latent spans context plus noise. Visibility is set entirely by the
DFlash additive attention_mask (there is no causal flag, and no compressor
or indexer, since the draft is always dense).
Bases: Module
Pre-norm residual block: V4 DSpark attention followed by a dense SwiGLU MLP.
Bases: Module
Dense SwiGLU MLP for the DSpark draft.
This intentionally avoids V4’s MoE and Hyper-Connection paths; the draft keeps a plain 3D hidden state and a single dense feed-forward block.
Bases: Module
DSpark draft model with a DeepSeek V4 attention backbone (dense, non-causal).
Keep the rotary inv_freq buffer in fp32 across dtype casts.
model.to(bfloat16) (the training build path) would otherwise round
inv_freq to bf16 and dephase RoPE with absolute position, eroding draft
acceptance (the mismatch grows with position, and a bf16 round-trip cannot
be undone by upcasting). Snapshot the fp32 frequencies before the cast and
restore them after (the Fp32Safe rotary idiom used elsewhere in the repo),
so the buffer never makes a bf16 round-trip.