> This page is for version Latest.
> 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.

# nemo_automodel.components.models.hy_v4_flash.vision

Hy4-flash vision tower: patch embedding, ViT blocks and the spatial-merge projector.

Semantics follow `HYV4VLVisionModel` of the transformers reference (PR 50903): a learned position grid
interpolated with an explicit `scale_factor` of `(size + 0.1) / grid` (this shifts the sampling grid relative to
`size=`), full bidirectional attention inside each image, an RMSNorm + 2x2 conv merge + 1x1 conv projector, and one
`image_newline` embedding appended to every merged row. Module names follow the released `vit.*` keys, which
the state-dict adapter therefore leaves unchanged.

## Module Contents

### Classes

| Name                                                                                                          | Description                                                                                          |
| ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [`HYV4FlashPerceive`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashPerceive)                 | Spatial-merge projector: RMSNorm, 2x2 conv, GELU, 1x1 conv, plus a newline embedding per merged row. |
| [`HYV4FlashVisionAttention`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashVisionAttention)   | Bidirectional multi-head attention with biases.                                                      |
| [`HYV4FlashVisionBlock`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashVisionBlock)           | Pre-norm ViT block.                                                                                  |
| [`HYV4FlashVisionEmbeddings`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashVisionEmbeddings) | Conv patch embedding plus an interpolated learned position grid.                                     |
| [`HYV4FlashVisionMLP`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashVisionMLP)               | GELU MLP named like the release (`dense_h_to_4h` / `dense_4h_to_h`).                                 |
| [`HYV4FlashVisionTower`](#nemo_automodel-components-models-hy_v4_flash-vision-HYV4FlashVisionTower)           | `vit`: embeddings, blocks and the perceive projector.                                                |

### API

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashPerceive(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

Spatial-merge projector: RMSNorm, 2x2 conv, GELU, 1x1 conv, plus a newline embedding per merged row.

**`image_newline`** `= nn.Parameter(torch.empty(config.out_hidden_size))`

---

**`norm`**

---

**`proj`**

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashPerceive.forward(
    hidden_states: torch.Tensor,
    grid_thw: torch.Tensor
) -> torch.Tensor
```

Merge and project `hidden_states` \[patches, hidden] per image (frames are merged independently).

Returns \[tokens, out_hidden]; each frame of `grid_thw` \[images, 3] gives `(h/m) * (w/m + 1)` tokens.

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionAttention(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

Bidirectional multi-head attention with biases.

**`head_dim`** `= config.hidden_size // config.num_attention_heads`

---

**`k_proj`** `= nn.Linear(config.hidden_size, config.hidden_size)`

---

**`num_heads`** `= config.num_attention_heads`

---

**`o_proj`** `= nn.Linear(config.hidden_size, config.hidden_size)`

---

**`q_proj`** `= nn.Linear(config.hidden_size, config.hidden_size)`

---

**`v_proj`** `= nn.Linear(config.hidden_size, config.hidden_size)`

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionAttention.forward(
    hidden_states: torch.Tensor,
    lengths: list[int]
) -> torch.Tensor
```

Attend inside each image: `hidden_states` \[patches, hidden], `lengths` the patch count of each image.

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionBlock(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

Pre-norm ViT block.

**`input_layernorm`**

---

**`mlp`** `= HYV4FlashVisionMLP(config)`

---

**`post_attention_layernorm`**

---

**`self_attn`** `= HYV4FlashVisionAttention(config)`

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionBlock.forward(
    hidden_states: torch.Tensor,
    lengths: list[int]
) -> torch.Tensor
```

Run the block on a tensor of shape \[patches, hidden].

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionEmbeddings(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

Conv patch embedding plus an interpolated learned position grid.

**`edge`** `= config.max_image_size // config.patch_size`

---

**`patch_embedding`**

---

**`patch_size`** `= config.patch_size`

---

**`position_embedding`**

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionEmbeddings.forward(
    pixel_values: torch.Tensor,
    grid_thw: torch.Tensor
) -> torch.Tensor
```

Embed flat patches into \[patches, hidden].

`pixel_values` has shape \[patches, channels \* patch_size \* patch_size], row-major per image, and `grid_thw`
\[images, 3] holds the (time, height, width) patch counts.

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionEmbeddings.interpolate_positions(
    height: int,
    width: int,
    dtype: torch.dtype
) -> torch.Tensor
```

Learned grid resampled to `height x width` patches.

**Returns:** `torch.Tensor`

Tensor of shape \[height \* width, hidden].

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionMLP(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

GELU MLP named like the release (`dense_h_to_4h` / `dense_4h_to_h`).

**`dense_4h_to_h`**

---

**`dense_h_to_4h`**

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionMLP.forward(
    hidden_states: torch.Tensor
) -> torch.Tensor
```

Apply the MLP to a tensor of shape \[..., hidden].

```python
class nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionTower(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig
)
```

**Bases:** `Module`

`vit`: embeddings, blocks and the perceive projector.

**`embeddings`** `= HYV4FlashVisionEmbeddings(config)`

---

**`layers`**

---

**`perceive`** `= HYV4FlashPerceive(config)`

---

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionTower.forward(
    pixel_values: torch.Tensor,
    grid_thw: torch.Tensor
) -> torch.Tensor
```

Encode images into language-width tokens \[tokens, out_hidden], the images' tokens concatenated.

`pixel_values` has shape \[patches, channels \* patch_size \* patch_size] and `grid_thw` \[images, 3].

```python
nemo_automodel.components.models.hy_v4_flash.vision.HYV4FlashVisionTower.reset_parameters(
    std: float
) -> None
```

Initialize as the reference does: zero biases, unit norm weights, normal everything else.