> This page is for version 0.4.0 · 26.04.
> 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.glm5_next.mtp

GLM-5.3-Flash multi-token prediction (MTP) head.

The released checkpoint stores one MTP layer after the decoder stack, as
`model.language_model.layers.&#123;num_hidden_layers&#125;`. It is a plain pre-norm
residual block (no mHC) with the same NoPE MLA + KPool indexer attention and
routed MoE as the sparse decoder layers:

fused = eh_proj(cat(enorm(next_token_embedding), hnorm(h_prev)))
hidden = fused + self_attn(input_layernorm(fused))
output = final_layernorm(hidden + mlp(post_attention_layernorm(hidden)))

`h_prev` is the backbone output after its final norm, and the shared
`lm_head` projects `output` for the auxiliary loss. `final_layernorm`
is stored as `shared_head.norm` in the checkpoint.

## Module Contents

### Classes

| Name                                                                                         | Description                                                                    |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [`Glm5NextMTP`](#nemo_automodel-components-models-glm5_next-mtp-Glm5NextMTP)                 | GLM-5.3-Flash MTP stack: one `Glm5NextMTPSublayer` per depth.                  |
| [`Glm5NextMTPSublayer`](#nemo_automodel-components-models-glm5_next-mtp-Glm5NextMTPSublayer) | One GLM-5.3-Flash MTP depth: embedding fusion, sparse MLA, MoE and final norm. |

### API

```python
class nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTP(
    config: nemo_automodel.components.models.glm5_next.config.Glm5NextTextConfig,
    mtp_config: nemo_automodel.components.models.common.mtp.MTPConfig,
    moe_config: nemo_automodel.components.moe.config.MoEConfig,
    backend: nemo_automodel.components.models.common.BackendConfig,
    dtype: torch.dtype
)
```

**Bases:** [MTPModule](/nemo/automodel/v0.4/nemo-automodel/nemo_automodel/components/models/common/mtp/mtp#nemo_automodel-components-models-common-mtp-mtp-MTPModule)

GLM-5.3-Flash MTP stack: one `Glm5NextMTPSublayer` per depth.

**Parameters:**

**`config`** `Glm5NextTextConfig`

GLM-5.3 text config.

---

**`mtp_config`** `MTPConfig`

Enabled MTP config with the single-sublayer pattern `"*"`.

---

**`moe_config`** `MoEConfig`

MoE config shared with the decoder's sparse layers.

---

**`backend`** `BackendConfig`

Kernel backend selection.

---

**`dtype`** `torch.dtype`

Parameter dtype of the fusion projection and norms.

---

```python
nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTP.init_weights(
    buffer_device: torch.device,
    init_std: float
) -> None
```

Initialize every depth on `buffer_device`.

```python
nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTP.update_moe_gate_bias() -> None
```

Update every depth's routing correction bias.

```python
class nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTPSublayer(
    config: nemo_automodel.components.models.glm5_next.config.Glm5NextTextConfig,
    layer_idx: int,
    moe_config: nemo_automodel.components.moe.config.MoEConfig,
    backend: nemo_automodel.components.models.common.BackendConfig,
    dtype: torch.dtype
)
```

**Bases:** `Module`

One GLM-5.3-Flash MTP depth: embedding fusion, sparse MLA, MoE and final norm.

**Parameters:**

**`config`** `Glm5NextTextConfig`

GLM-5.3 text config.

---

**`layer_idx`** `int`

Checkpoint layer index of this depth (`num_hidden_layers + depth`).

---

**`moe_config`** `MoEConfig`

MoE config shared with the decoder's sparse layers.

---

**`backend`** `BackendConfig`

Kernel backend selection.

---

**`dtype`** `torch.dtype`

Parameter dtype of the fusion projection and norms.

---

**`eh_proj`**

---

**`enorm`** `= Glm5NextRMSNorm(hidden_size, eps, dtype)`

---

**`final_layernorm`** `= Glm5NextRMSNorm(hidden_size, eps, dtype)`

---

**`hnorm`** `= Glm5NextRMSNorm(hidden_size, eps, dtype)`

---

**`input_layernorm`** `= Glm5NextRMSNorm(hidden_size, eps, dtype)`

---

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

---

**`post_attention_layernorm`** `= Glm5NextRMSNorm(hidden_size, eps, dtype)`

---

**`self_attn`**

---

```python
nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTPSublayer.forward(
    hidden_states: torch.Tensor,
    embed_input: torch.Tensor,
    packed_context: nemo_automodel.components.models.glm5_next.cp.Glm5NextPackedContext,
    padding_mask: torch.Tensor | None = None
) -> torch.Tensor
```

Predict one token further ahead.

**Parameters:**

**`hidden_states`** `torch.Tensor`

Previous depth's output (the backbone's final-norm
output for depth 1) with shape `[batch, local_sequence, hidden]`.

---

**`embed_input`** `torch.Tensor`

Embedding of the token `depth` positions ahead, in the
same local layout, zero where that token leaves the document.

---

**`packed_context`** `Glm5NextPackedContext`

Document map shared with the backbone attention.

---

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

Optional `[batch, local_sequence]` mask, `True` on padding.

---

**Returns:** `torch.Tensor`

Normalized hidden states `[batch, local_sequence, hidden]` for the

```python
nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTPSublayer.init_weights(
    buffer_device: torch.device,
    init_std: float
) -> None
```

Initialize a checkpoint-free MTP depth on `buffer_device`.

```python
nemo_automodel.components.models.glm5_next.mtp.Glm5NextMTPSublayer.update_moe_gate_bias() -> None
```

Update this depth's no-aux-loss routing correction bias.