nemo_automodel.components.speculative.eagle.msd_target
nemo_automodel.components.speculative.eagle.msd_target
Frozen VLM target wrapper for multimodal speculative-decoding training.
Module Contents
Classes
API
Expose image-aware feature supervision from a frozen Hugging Face VLM.
Run a VLM and construct shifted multimodal draft supervision.
input_ids and attention_mask are read from model_inputs rather
than taken separately, so the tensors the target actually runs on are the
same ones the image mask and the returned attention mask are derived from.
A second copy would misalign the draft’s modality routing without raising.
Parameters:
Bool tensor of shape [batch, sequence], already aligned to
next-token logits. VLM collators produce this from labels != -100;
they emit labels[:, 1:] against input_ids[:, :-1], so no
further shift is applied here. Its final position is always
dropped because the shifted supervision tensors zero-fill there.
Mapping of VLM forward inputs. It must include
input_ids of shape [batch, sequence], with image-token
placeholders at positions that receive projected vision features,
and attention_mask of the same shape, where one denotes a real
token and zero denotes padding. It also carries any vision tensors
such as pixel_values and image_grid_thw.
Returns: MSDTargetBatch
MSDTargetBatch with shifted image-aware embeddings, target hidden
Return the frozen VLM language-model head used by the draft loss.
Frozen VLM supervision tensors consumed by :class:MSDTrainerModule.
Capture the input embeddings supplied to a VLM language backbone.
Save the fused VLM embedding tensor passed to the language backbone.
Parameters:
Language backbone receiving the VLM’s fused input embeddings.
Positional arguments accepted by the language backbone.
Keyword arguments accepted by the language backbone. Its
inputs_embeds value is a Tensor of shape [batch, sequence,
hidden] containing text and projected image embeddings.