nemo_automodel.components.models.deepseek_v41.dfly2_target
nemo_automodel.components.models.deepseek_v41.dfly2_target
DFly2 target features of DeepSeek V4.1: the paired layers’ keys and key lists.
A ratio-1 CSA2 layer attends over [its FP8 sliding-window KV | the shared 1:1 compressed KV]: row r reads the window keys r - 127 .. r and the compressed rows its indexer
selected, offset past the window keys. The draft layer paired with it reads exactly those
keys, so this capture returns, per paired layer, that concatenated key tensor and every
row’s key list in the same layout.
The keys are taken during the frozen forward by a hook on each paired attention module, while its parameters are still gathered under FSDP: the window keys are recomputed from the layer’s input with the layer’s own projections (bitwise the values the layer used), and the compressed KV and selection are read from the attention state it publishes.
Module Contents
Functions
API
List each row’s sliding-window keys: the last window tokens up to and including the row.
Parameters:
Boolean tensor of shape [batch, sequence], false at right padding.
Window width.
Returns: torch.Tensor
Long tensor of shape [batch, sequence, min(window, sequence)] of token rows, -1
Run the frozen V4.1 target and capture the DFly2 features of the paired layers.
Parameters:
DeepseekV41ForCausalLM target, text only, without context parallelism.
Integer tensor of shape [batch, sequence].
Binary right-padding tensor of shape [batch, sequence].
Paired ratio-1 layers, in draft-layer order.
Returns: DFly2TargetFeatures
Features whose context_keys[i] has shape [batch, 2 * sequence, head_dim] (the
Raises:
ValueError: A paired layer is not a ratio-1 layer.