> This page is for version 0.5.0 · 26.06.
> 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.qwen3_8_flash_next.vision

Image inputs of Qwen3.8-Flash-Next: the vision tower and multimodal rotary positions.

The reference vision stack of this family (`Qwen4ExpVisionModel` in Transformers)
is the Qwen3.5-MoE tower with different sizes only, so the released
`Qwen3_5MoeVisionModel` is used as is. Video inputs are not implemented.

## Module Contents

### Classes

| Name                                                                                                                       | Description                                                                               |
| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| [`Qwen3_8_FlashNextVisionModel`](#nemo_automodel-components-models-qwen3_8_flash_next-vision-Qwen3_8_FlashNextVisionModel) | Qwen3-VL-style vision tower: 3D patch embedding, 2D rotary blocks and a 2x2 patch merger. |

### Functions

| Name                                                                                                                                         | Description                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`qwen3_8_flash_next_image_position_ids`](#nemo_automodel-components-models-qwen3_8_flash_next-vision-qwen3_8_flash_next_image_position_ids) | Build the three-axis rotary positions of rows that mix text and images. |

### Data

[`_IMAGE_TOKEN_TYPE`](#nemo_automodel-components-models-qwen3_8_flash_next-vision-_IMAGE_TOKEN_TYPE)

[`_TEXT_TOKEN_TYPE`](#nemo_automodel-components-models-qwen3_8_flash_next-vision-_TEXT_TOKEN_TYPE)

### API

```python
class nemo_automodel.components.models.qwen3_8_flash_next.vision.Qwen3_8_FlashNextVisionModel(
    config: nemo_automodel.components.models.qwen3_8_flash_next.config.Qwen3_8_FlashNextVisionConfig
)
```

**Bases:** `Qwen3_5MoeVisionModel`

Qwen3-VL-style vision tower: 3D patch embedding, 2D rotary blocks and a 2x2 patch merger.

**Tensor layout**

`forward(hidden_states, grid_thw)` takes flattened patches
`[patches, in_channels * temporal_patch_size * patch_size * patch_size]`
of every image in order and the per-image unmerged patch grid
`[images, 3]` as (frames, height, width). `pooler_output` holds the
merged features `[patches / spatial_merge_size ** 2, out_hidden_size]`
in the same order; `last_hidden_state` is `[patches, hidden_size]`.

**Parameters:**

**`config`** `Qwen3_8_FlashNextVisionConfig`

Vision architecture configuration. `deepstack_visual_indexes`
must be empty: the tower returns only its final merged features.

---

**`rotary_pos_emb`** `= Fp32SafeQwen3_5MoeVisionRotaryEmbedding(hf_config)`

---

```python
nemo_automodel.components.models.qwen3_8_flash_next.vision.Qwen3_8_FlashNextVisionModel.reset_parameters() -> None
```

Initialize every weight and the rotary frequencies with the reference initializer.

```python
nemo_automodel.components.models.qwen3_8_flash_next.vision.qwen3_8_flash_next_image_position_ids(
    mm_token_type_ids: torch.Tensor,
    image_grid_thw: torch.Tensor,
    attention_mask: torch.Tensor | None,
    spatial_merge_size: int
) -> torch.Tensor
```

Build the three-axis rotary positions of rows that mix text and images.

Each row is read left to right over its valid tokens with a running start
position. A text run of `n` tokens takes the next `n` positions on all
three axes. An image whose merged grid is `(frames, rows, cols)` and that
starts at position `p` gets `p + frame` on the temporal axis,
`p + row` on the height axis and `p + col` on the width axis, in
frame, row, column raster order; the token after it continues at
`p + max(rows, cols)`. Padding keeps position zero on every axis.

**Parameters:**

**`mm_token_type_ids`** `torch.Tensor`

Integer tensor `[batch, sequence]`; 0 marks a text
token and 1 an image placeholder.

---

**`image_grid_thw`** `torch.Tensor`

Integer tensor `[images, 3]` with the unmerged
(frames, height, width) patch counts of every image, in order of
appearance over the rows of the batch.

---

**`attention_mask`** `torch.Tensor | None`

Optional tensor `[batch, sequence]`; nonzero marks a
real token. `None` treats every token as real.

---

**`spatial_merge_size`** `int`

Side of the square of patches merged into one
language token.

---

**Returns:** `torch.Tensor`

Long tensor `[3, batch, sequence]` on the device of

**Raises:**

* `ValueError`: If an image placeholder run does not have the token count of
  its grid, or the number of runs differs from the number of grids.
* `NotImplementedError`: If a token type other than text or image appears.

```python
nemo_automodel.components.models.qwen3_8_flash_next.vision._IMAGE_TOKEN_TYPE = 1
```

```python
nemo_automodel.components.models.qwen3_8_flash_next.vision._TEXT_TOKEN_TYPE = 0
```