nemo_automodel.components.speculative.eagle.msd
nemo_automodel.components.speculative.eagle.msd
Multimodal speculative decoding draft model and training objective.
MSD extends EAGLE-1/2 feature drafting to VLM targets. Text positions use the usual concatenation of target features and next-token embeddings. Image positions instead pass the target VLM’s already-computed image embeddings directly into the draft transformer, preserving the non-causal relationship between visual patches.
Module Contents
Classes
API
Aggregated metrics from one multimodal speculative-decoding training step.
Bases: Module
Draft-side training module for multimodal speculative decoding.
Project predicted hidden states through the frozen target language head.
Parameters:
Tensor of shape […, hidden], with arbitrary leading dimensions.
Returns: torch.Tensor
Tensor of shape […, vocab], containing target-vocabulary logits.
Run one multimodal speculative-decoding training step.
Parameters:
Tensor of shape [batch, sequence, hidden], the target VLM input embeddings shifted left by one position.
Tensor of shape [batch, sequence], where one denotes a real token and zero denotes padding.
Bool tensor of shape [batch, sequence], true where the shifted next-token target is supervised.
Tensor of shape [batch, sequence, hidden], the target’s unshifted final hidden states used as draft features.
Tensor of shape [batch, sequence, hidden], the target’s final hidden states shifted left by one position.
Tensor of shape [batch, sequence, vocab], the frozen target logits shifted left by one position.
Bool tensor of shape [batch, sequence], true where
inputs_embeds contains a projected image token.
Returns: MSDStepMetrics
MSDStepMetrics containing scalar loss terms, first-token accuracy, and
Bases: LlamaEagleDraftModel
EAGLE-1/2 draft model with modality-aware input feature construction.
Raise: MSD drafts consume target embeddings instead of holding their own.
Predict next-position target hidden states from multimodal features.
Parameters:
Tensor of shape [batch, sequence, hidden], containing the target VLM input embeddings shifted one position to the left. Image positions already contain projected vision features.
Tensor of shape [batch, sequence, hidden], the frozen target language model’s unshifted final hidden states.
Tensor of shape [batch, sequence], where one denotes a real token and zero denotes padding.
Bool tensor of shape [batch, sequence], aligned with
inputs_embeds and true for projected image-token positions.
Returns: torch.Tensor
Tensor of shape [batch, sequence, hidden], the draft predictions for
Raise: MSD drafts have no token embedding table to freeze.