> This page is for version Nightly (default).
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> 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.models.deepseek_v41.vision

DeepSeek vision encoder and spatial merger with independent batched images.

## Module Contents

### Classes

| Name                                                                                                                 | Description                                                                |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [`DeepseekV41VisionAligner`](#nemo_automodel-components-models-deepseek_v41-vision-DeepseekV41VisionAligner)         | The released padded spatial merger and GELU projection into text width.    |
| [`DeepseekV41VisionTransformer`](#nemo_automodel-components-models-deepseek_v41-vision-DeepseekV41VisionTransformer) | The released full-attention 2D-RoPE ViT, configured by nested V4.1 fields. |

### Functions

| Name                                                                                     | Description                                                                       |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [`_vision_config`](#nemo_automodel-components-models-deepseek_v41-vision-_vision_config) | Translate the typed V4.1 config into the existing vision implementation's config. |

### API

```python
class nemo_automodel.components.models.deepseek_v41.vision.DeepseekV41VisionAligner(
    config: nemo_automodel.components.models.deepseek_v41.config.DeepseekV41Config
)
```

**Bases:** [DeepseekV4VisionAligner](/nemo/automodel/nemo-automodel/nemo_automodel/components/models/deepseek_v4/vision#nemo_automodel-components-models-deepseek_v4-vision-DeepseekV4VisionAligner)

The released padded spatial merger and GELU projection into text width.

**Parameters:**

**`config`** `DeepseekV41Config`

Top-level V4.1 configuration containing vision and text widths.

---

```python
nemo_automodel.components.models.deepseek_v41.vision.DeepseekV41VisionAligner.forward(
    x: torch.Tensor,
    n_h: int | None = None,
    n_w: int | None = None,
    image_grid_hws: torch.Tensor | None = None
) -> torch.Tensor
```

Merge each image independently, then batch the projection GEMMs.

**Parameters:**

**`x`** `torch.Tensor`

Concatenated unmerged image features \[patches, vision_dim].

---

**`n_h`** `int | None` — default: None

Patch rows for a single-image call.

---

**`n_w`** `int | None` — default: None

Patch columns for a single-image call.

---

**`image_grid_hws`** `torch.Tensor | None` — default: None

Integer patch grids \[images, 2] in feature order.

---

**Returns:** `torch.Tensor`

Features \[sum(ceil(height / ratio) \* ceil(width / ratio)), hidden].

```python
class nemo_automodel.components.models.deepseek_v41.vision.DeepseekV41VisionTransformer(
    config: nemo_automodel.components.models.deepseek_v41.config.DeepseekV41Config
)
```

**Bases:** [DeepseekV4VisionTransformer](/nemo/automodel/nemo-automodel/nemo_automodel/components/models/deepseek_v4/vision#nemo_automodel-components-models-deepseek_v4-vision-DeepseekV4VisionTransformer)

The released full-attention 2D-RoPE ViT, configured by nested V4.1 fields.

**Parameters:**

**`config`** `DeepseekV41Config`

Top-level V4.1 configuration containing the vision dimensions.

---

**`config`** `= config.vision_config`

---

**`spatial_merge_size`** `int = 1`

---

```python
nemo_automodel.components.models.deepseek_v41.vision.DeepseekV41VisionTransformer.forward(
    patches: torch.Tensor,
    n_h: int | None = None,
    n_w: int | None = None,
    grid_thw: torch.Tensor | None = None,
    return_dict: bool = False
) -> torch.Tensor | transformers.modeling_outputs.BaseModelOutputWithPooling
```

Encode independent images with one call per FSDP/checkpointed block.

**Parameters:**

**`patches`** `torch.Tensor`

Normalized RGB patches \[patches, 3, patch_size, patch_size]
or flattened \[patches, 3 \* patch_size\*\*2], in image order.

---

**`n_h`** `int | None` — default: None

Patch rows for the backward-compatible single-image call.

---

**`n_w`** `int | None` — default: None

Patch columns for the backward-compatible single-image call.

---

**`grid_thw`** `torch.Tensor | None` — default: None

Integer grids \[images, 3], each (frames, height, width).
Frames are independent images, including frame-sharder dummies.

---

**`return_dict`** `bool` — default: False

Return the pooler-output contract used by frame sharding.

---

**Returns:** `torch.Tensor | BaseModelOutputWithPooling`

Unmerged features \[patches, vision_dim], or a ModelOutput containing

```python
nemo_automodel.components.models.deepseek_v41.vision._vision_config(
    config: nemo_automodel.components.models.deepseek_v41.config.DeepseekV41Config
) -> nemo_automodel.components.models.deepseek_v4.config.DeepseekV4Config
```

Translate the typed V4.1 config into the existing vision implementation's config.