> 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.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.pixtral.compat

Temporary Pixtral forward backport for Transformers 5.17.0, 5.18.0, and 5.19.0.

Adapted from Hugging Face Transformers (Apache-2.0), with the image-boundary
fix from [https://github.com/huggingface/transformers/pull/49373](https://github.com/huggingface/transformers/pull/49373)
(ff704ffd47d800e31b31f2f81a5a2952fb0fbf71). Remove this module and its binding
when AutoModel pins a release containing that fix.

## Module Contents

### Functions

| Name                                                                                                                | Description                                                                      |
| ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [`_pixtral_vision_forward`](#nemo_automodel-components-models-pixtral-compat-_pixtral_vision_forward)               | Preserve axial positions while passing explicit FlashAttention image boundaries. |
| [`apply_pixtral_forward_backport`](#nemo_automodel-components-models-pixtral-compat-apply_pixtral_forward_backport) | Apply HF #49373 to one vision tower on the affected Transformers releases.       |

### API

```python
nemo_automodel.components.models.pixtral.compat._pixtral_vision_forward(
    self: transformers.models.pixtral.modeling_pixtral.PixtralVisionModel,
    pixel_values: torch.Tensor,
    image_sizes: torch.Tensor | None = None,
    kwargs: transformers.processing_utils.Unpack[transformers.utils.TransformersKwargs] = {}
) -> tuple | transformers.modeling_outputs.BaseModelOutput | transformers.modeling_outputs.BaseModelOutputWithPooling
```

Preserve axial positions while passing explicit FlashAttention image boundaries.

**Parameters:**

**`pixel_values`** `torch.Tensor`

Tensor of shape \[images, channels, height, width], padded
to a common image size.

---

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

Tensor of shape \[images, 2] containing each unpadded height
and width. A list of height/width pairs is also accepted upstream.

---

**`**kwargs`** `Unpack[TransformersKwargs]` — default: \{}

Options following `PixtralVisionModel.forward`'s contract.

---

**Returns:** `tuple | BaseModelOutput | BaseModelOutputWithPooling`

The `PixtralVisionModel.forward` output contract: last hidden state

```python
nemo_automodel.components.models.pixtral.compat.apply_pixtral_forward_backport(
    vision_tower: transformers.models.pixtral.modeling_pixtral.PixtralVisionModel
) -> None
```

Apply HF #49373 to one vision tower on the affected Transformers releases.

Remove this compatibility hook and its callers when the pinned release
contains the upstream fix and passes the Pixtral regression tests.

**Parameters:**

**`vision_tower`** `PixtralVisionModel`

The owning model's Pixtral tower. Its forward method is
replaced in place; independently constructed HF towers are unchanged.

---