> 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.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.qwen3_next.model

## Module Contents

### Classes

| Name                                                                                              | Description |
| ------------------------------------------------------------------------------------------------- | ----------- |
| [`Block`](#nemo_automodel-components-models-qwen3_next-model-Block)                               | -           |
| [`Qwen3NextForCausalLM`](#nemo_automodel-components-models-qwen3_next-model-Qwen3NextForCausalLM) | -           |
| [`Qwen3NextModel`](#nemo_automodel-components-models-qwen3_next-model-Qwen3NextModel)             | -           |

### Data

[`ModelClass`](#nemo_automodel-components-models-qwen3_next-model-ModelClass)

### API

```python
class nemo_automodel.components.models.qwen3_next.model.Block(
    layer_idx: int,
    config: transformers.models.qwen3_next.configuration_qwen3_next.Qwen3NextConfig,
    moe_config: nemo_automodel.components.moe.config.MoEConfig,
    backend: nemo_automodel.components.models.common.BackendConfig
)
```

**Bases:** `Module`

**`input_layernorm`**

---

**`layer_type`** `= config.layer_types[layer_idx]`

---

**`linear_attn`** `= Qwen3NextFp32GatedDeltaNet(config, layer_idx)`

---

**`mlp`** `= MoE(moe_config, backend)`

---

**`post_attention_layernorm`**

---

**`self_attn`** `= Qwen3NextAttention(config, layer_idx, backend)`

---

```python
nemo_automodel.components.models.qwen3_next.model.Block._mlp(
    x: torch.Tensor,
    padding_mask: torch.Tensor | None
) -> torch.Tensor
```

```python
nemo_automodel.components.models.qwen3_next.model.Block.forward(
    x: torch.Tensor,
    freqs_cis: torch.Tensor,
    attention_mask: torch.Tensor | None = None,
    padding_mask: torch.Tensor | None = None,
    position_ids: torch.Tensor | None = None,
    attn_kwargs: typing.Any = {}
) -> torch.Tensor
```

```python
nemo_automodel.components.models.qwen3_next.model.Block.init_weights(
    buffer_device: torch.device
)
```

```python
class nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM(
    config: transformers.models.qwen3_next.configuration_qwen3_next.Qwen3NextConfig,
    moe_config: nemo_automodel.components.moe.config.MoEConfig | None = None,
    backend: nemo_automodel.components.models.common.BackendConfig | None = None,
    kwargs = {}
)
```

**Bases:** [HFCheckpointingMixin](/nemo-automodel/nemo_automodel/components/models/common/hf_checkpointing_mixin#nemo_automodel-components-models-common-hf_checkpointing_mixin-HFCheckpointingMixin), `Module`, [MoEFSDPSyncMixin](/nemo-automodel/nemo_automodel/components/moe/fsdp_mixin#nemo_automodel-components-moe-fsdp_mixin-MoEFSDPSyncMixin)

**`_keep_in_fp32_modules_strict`** `= ['_fp32_params']`

---

**`backend`** `= backend or BackendConfig()`

---

**`lm_head`**

---

**`model`**

---

**`state_dict_adapter`**

---

**`tie_word_embeddings_support`** `TieSupport = TieSupport.UNTIED_ONLY`

---

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.forward(
    input_ids: torch.Tensor,
    position_ids: torch.Tensor | None = None,
    attention_mask: torch.Tensor | None = None,
    padding_mask: torch.Tensor | None = None,
    logits_to_keep: typing.Union[int, torch.Tensor] = 0,
    output_hidden_states: bool | None = None,
    attn_kwargs: typing.Any = {}
) -> transformers.modeling_outputs.CausalLMOutputWithPast
```

Run Qwen3Next without unsupported packed FA4 recurrent attention.

**Parameters:**

**`input_ids`** `torch.Tensor`

Token IDs of shape \[batch, sequence].

---

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

Optional positions of shape \[batch, sequence].

---

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

Padding/document IDs of shape \[batch, sequence] or
an explicit mask of shape \[batch, 1, sequence, sequence].

---

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

Optional padding mask of shape \[batch, sequence].

---

**`logits_to_keep`** `Union[int, torch.Tensor]` — default: 0

Number of trailing logits, or indices of shape \[kept\_tokens].

---

**`output_hidden_states`** `bool | None` — default: None

Whether to return the final hidden states.

---

**`**attn_kwargs`** `Any` — default: \{}

Attention metadata, including cumulative document
lengths of shape \[documents + 1] and packed indices of shape \[tokens].

---

**Returns:** `CausalLMOutputWithPast`

Model output with logits of shape \[batch, kept\_sequence, vocab] and

**Raises:**

* `ValueError`: If packed FA4 is requested, since recurrent layers do not
  reset state at document boundaries.

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.from_config(
    config: transformers.models.qwen3_next.configuration_qwen3_next.Qwen3NextConfig,
    moe_config: nemo_automodel.components.moe.config.MoEConfig | None = None,
    backend: nemo_automodel.components.models.common.BackendConfig | None = None,
    kwargs = {}
)
```

classmethod

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.from_pretrained(
    pretrained_model_name_or_path: str,
    model_args = (),
    kwargs = {}
)
```

classmethod

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.get_input_embeddings()
```

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.get_output_embeddings()
```

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.initialize_weights(
    buffer_device: torch.device | None = None,
    dtype: torch.dtype = torch.bfloat16
) -> None
```

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.set_input_embeddings(
    value
)
```

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextForCausalLM.set_output_embeddings(
    new_embeddings
)
```

```python
class nemo_automodel.components.models.qwen3_next.model.Qwen3NextModel(
    config: transformers.models.qwen3_next.configuration_qwen3_next.Qwen3NextConfig,
    backend: nemo_automodel.components.models.common.BackendConfig,
    moe_config: nemo_automodel.components.moe.config.MoEConfig | None = None,
    moe_overrides: dict | None = None
)
```

**Bases:** `Module`

**`embed_tokens`**

---

**`head_dim`**

---

**`layers`** `= torch.nn.ModuleDict()`

---

**`max_seq_len`** `= config.max_position_embeddings`

---

**`moe_config`** `= moe_config or MoEConfig(**moe_defaults)`

---

**`norm`**

---

**`rotary_emb`**

---

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextModel.forward(
    input_ids: torch.Tensor,
    position_ids: torch.Tensor | None = None,
    attention_mask: torch.Tensor | None = None,
    padding_mask: torch.Tensor | None = None,
    attn_kwargs: typing.Any = {}
) -> torch.Tensor
```

```python
nemo_automodel.components.models.qwen3_next.model.Qwen3NextModel.init_weights(
    buffer_device: torch.device | None = None
) -> None
```

```python
nemo_automodel.components.models.qwen3_next.model.ModelClass = Qwen3NextForCausalLM
```