> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# nemo_automodel.components.speculative.eagle.msd_target

Frozen VLM target wrapper for multimodal speculative-decoding training.

## Module Contents

### Classes

| Name                                                                                                       | Description                                                            |
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [`HFMSDTargetModel`](#nemo_automodel-components-speculative-eagle-msd_target-HFMSDTargetModel)             | Expose image-aware feature supervision from a frozen Hugging Face VLM. |
| [`MSDTargetBatch`](#nemo_automodel-components-speculative-eagle-msd_target-MSDTargetBatch)                 | Frozen VLM supervision tensors consumed by :class:`MSDTrainerModule`.  |
| [`_InputEmbeddingCapture`](#nemo_automodel-components-speculative-eagle-msd_target-_InputEmbeddingCapture) | Capture the input embeddings supplied to a VLM language backbone.      |

### API

```python
class nemo_automodel.components.speculative.eagle.msd_target.HFMSDTargetModel(
    model: torch.nn.Module
)
```

Expose image-aware feature supervision from a frozen Hugging Face VLM.

```python
nemo_automodel.components.speculative.eagle.msd_target.HFMSDTargetModel.generate_batch(
    loss_mask: torch.Tensor,
    model_inputs: dict[str, torch.Tensor]
) -> nemo_automodel.components.speculative.eagle.msd_target.MSDTargetBatch
```

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

```python
nemo_automodel.components.speculative.eagle.msd_target.HFMSDTargetModel.get_lm_head() -> torch.nn.Module
```

Return the frozen VLM language-model head used by the draft loss.

```python
class nemo_automodel.components.speculative.eagle.msd_target.MSDTargetBatch(
    inputs_embeds: torch.Tensor,
    input_hidden_states: torch.Tensor,
    target_hidden_states: torch.Tensor,
    target_logits: torch.Tensor,
    attention_mask: torch.Tensor,
    loss_mask: torch.Tensor,
    image_mask: torch.Tensor
)
```

Dataclass

Frozen VLM supervision tensors consumed by :class:`MSDTrainerModule`.

```python
class nemo_automodel.components.speculative.eagle.msd_target._InputEmbeddingCapture()
```

Capture the input embeddings supplied to a VLM language backbone.

```python
nemo_automodel.components.speculative.eagle.msd_target._InputEmbeddingCapture.__call__(
    _module: torch.nn.Module,
    _args: tuple[typing.Any, ...],
    kwargs: dict[str, typing.Any]
) -> None
```

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.