> 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.hunyuan_image3.flow_adapter

Flow-matching adapter for HunyuanImage-3.0 text-to-image training.

HunyuanImage-3.0 has no separate text encoder: the prompt is part of the transformer's own token sequence. The
preprocessing step stores, per sample, the token ids before the image (`&lt;bos&gt; prompt &lt;boi&gt; &lt;img_size_*&gt;
&lt;img_ratio_*&gt; &lt;timestep&gt;`), the matching unconditional ids used for classifier-free guidance (the prompt replaced
by `&lt;cfg&gt;` tokens of the same length), and the ids after the image (`&lt;eoi&gt;`). This adapter assembles
`prefix + &lt;img&gt; * (h*w) + suffix` for every sample, right-pads the batch and calls the model.

The pipeline's convention already matches the release: `x_t = (1 - sigma) x_0 + sigma * noise`, target
`noise - x_0` and model timestep `sigma * 1000`.

## Module Contents

### Classes

| Name                                                                                                         | Description                                                                                  |
| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| [`HunyuanImage3Adapter`](#nemo_automodel-components-models-hunyuan_image3-flow_adapter-HunyuanImage3Adapter) | Builds the joint token sequence around the noisy latents and returns the predicted velocity. |

### Data

[`PROMPT_IDS_KEY`](#nemo_automodel-components-models-hunyuan_image3-flow_adapter-PROMPT_IDS_KEY)

[`PROMPT_SUFFIX_IDS_KEY`](#nemo_automodel-components-models-hunyuan_image3-flow_adapter-PROMPT_SUFFIX_IDS_KEY)

[`UNCOND_PROMPT_IDS_KEY`](#nemo_automodel-components-models-hunyuan_image3-flow_adapter-UNCOND_PROMPT_IDS_KEY)

### API

```python
class nemo_automodel.components.models.hunyuan_image3.flow_adapter.HunyuanImage3Adapter(
    image_token_id: int = 128006,
    pad_token_id: int = 128009
)
```

**Bases:** [ModelAdapter](/nemo-automodel/nemo_automodel/components/flow_matching/adapters/base#nemo_automodel-components-flow_matching-adapters-base-ModelAdapter)

Builds the joint token sequence around the noisy latents and returns the predicted velocity.

**Parameters:**

**`image_token_id`** `int` — default: 128006

Id of the `&lt;img&gt;` placeholder token.

---

**`pad_token_id`** `int` — default: 128009

Id used to right-pad sequences of different lengths.

---

```python
nemo_automodel.components.models.hunyuan_image3.flow_adapter.HunyuanImage3Adapter.forward(
    model: torch.nn.Module,
    inputs: dict[str, typing.Any]
) -> torch.Tensor
```

Run the model on `prepare_inputs` output.

**Returns:** `torch.Tensor`

Tensor of shape \[batch, channels, height, width]: the predicted velocity `noise - x0`.

```python
nemo_automodel.components.models.hunyuan_image3.flow_adapter.HunyuanImage3Adapter.prepare_inputs(
    context: nemo_automodel.components.flow_matching.adapters.base.FlowMatchingContext
) -> dict[str, typing.Any]
```

Assemble model inputs.

**Parameters:**

**`context`** `FlowMatchingContext`

`noisy_latents` of shape \[batch, channels, height, width], `timesteps` of shape \[batch]
(`sigma * 1000`) and a batch holding per-sample 1D long tensors under `prompt_input_ids`,
`uncond_prompt_input_ids` and `prompt_suffix_ids`.

---

**Returns:** `dict[str, Any]`

`input_ids` long \[batch, sequence] right-padded with `pad_token_id`, `latents` \[batch, channels,

```python
nemo_automodel.components.models.hunyuan_image3.flow_adapter.PROMPT_IDS_KEY = 'prompt_input_ids'
```

```python
nemo_automodel.components.models.hunyuan_image3.flow_adapter.PROMPT_SUFFIX_IDS_KEY = 'prompt_suffix_ids'
```

```python
nemo_automodel.components.models.hunyuan_image3.flow_adapter.UNCOND_PROMPT_IDS_KEY = 'uncond_prompt_input_ids'
```