> 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.ernie5_5.mtp_state_dict_adapter

Whole-state, unsharded checkpoint layout for one-depth ERNIE 5.5 MTP.

The decoder conversion is delegated to its existing adapter. Shared MTP body
keys are export aliases only; native storage has no duplicate body parameters.
Low-memory/in-place DCP loading and streaming consolidation are not established
by this whole-state adapter. Native state_dict save/restore does not require this adapter.

## Module Contents

### Classes

| Name                                                                                                                           | Description                                                             |
| ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
| [`Ernie5_5MTPStateDictAdapter`](#nemo_automodel-components-models-ernie5_5-mtp_state_dict_adapter-Ernie5_5MTPStateDictAdapter) | Map eight owned parameters, one bias and shared export aliases exactly. |

### Functions

| Name                                                                                                     | Description                                                                 |
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [`_mtp_body_suffix`](#nemo_automodel-components-models-ernie5_5-mtp_state_dict_adapter-_mtp_body_suffix) | Use the released extra nesting for the ten shared hyper-connection tensors. |

### Data

[`_OWNED`](#nemo_automodel-components-models-ernie5_5-mtp_state_dict_adapter-_OWNED)

### API

```python
class nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter.Ernie5_5MTPStateDictAdapter(
    config: nemo_automodel.components.models.ernie5_5.config.Ernie5_5Config
)
```

**Bases:** [StateDictAdapter](/nemo/automodel/v0.5/nemo-automodel/nemo_automodel/components/checkpoint/state_dict_adapter#nemo_automodel-components-checkpoint-state_dict_adapter-StateDictAdapter)

Map eight owned parameters, one bias and shared export aliases exactly.

**`bias_suffix`** `= 'block_sparse_moe.e_score_correction_bias'`

---

**`body_prefix`** `= f'model.layers.{config.num_hidden_layers - 1}.'`

---

**`decoder`**

---

**`mtp_prefix`** `= f'model.layers.{config.num_hidden_layers}.'`

---

```python
nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter.Ernie5_5MTPStateDictAdapter.convert_single_tensor_to_hf(
    fqn: str,
    tensor: torch.Tensor,
    kwargs: str | bool | None = {}
) -> list[tuple[str, torch.Tensor]]
```

Reject streaming export until its full alias/decoder contract is implemented.

**Parameters:**

**`fqn`** `str`

Native tensor name.

---

**`tensor`** `torch.Tensor`

Tensor in the native parameter's semantic layout.

---

**`**kwargs`** `str | bool | None` — default: \{}

Framework compatibility options.

---

**Returns:** `list[tuple[str, torch.Tensor]]`

No result; this adapter supports whole-state conversion only.

**Raises:**

* `NotImplementedError`: Single-tensor conversion cannot construct the complete shared-body HF layout.

```python
nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter.Ernie5_5MTPStateDictAdapter.from_hf(
    hf_state_dict: dict[str, torch.Tensor],
    device_mesh: torch.distributed.device_mesh.DeviceMesh | None = None,
    kwargs: str | bool | None = {}
) -> dict[str, torch.Tensor]
```

Convert a complete HF mapping, refusing conflicting shared copies.

**Parameters:**

**`hf_state_dict`** `dict[str, torch.Tensor]`

Whole unsharded HF tensors; decoder keys and MTP body
keys have matching shapes/dtypes/values. The owned head matrix
has HF shape \[streams \* hidden, streams]. Meta inputs are unsupported.

---

**`device_mesh`** `DeviceMesh | None` — default: None

Must be None for this whole-state conversion.

---

**`**kwargs`** `str | bool | None` — default: \{}

Compatibility options forwarded to the decoder adapter.

---

**Returns:** `dict[str, torch.Tensor]`

Unique native tensors in registered layouts; the owned head matrix

**Raises:**

* `NotImplementedError`: If the HF mapping contains sharded tensors.
* `ValueError`: If required keys are missing, layouts are invalid or shared copies differ from their owners.

```python
nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter.Ernie5_5MTPStateDictAdapter.to_hf(
    state_dict: dict[str, torch.Tensor],
    quantization: bool = False,
    for_checkpoint_load: bool = False,
    v4_compatible: bool = False,
    kwargs: str | bool | torch.distributed.device_mesh.DeviceMesh | None = {}
) -> dict[str, torch.Tensor]
```

Export the whole native state without copying shared body storage.

**Parameters:**

**`state_dict`** `dict[str, torch.Tensor]`

Unsharded native tensors in their registered layouts;
decoder tensors have model.\* names and MTP-owned tensors mtp.\*.
mHC head projection is \[streams, streams \* hidden] natively.

---

**`quantization`** `bool` — default: False

Must be False.

---

**`for_checkpoint_load`** `bool` — default: False

Must be False; in-place load sessions are not supported.

---

**`v4_compatible`** `bool` — default: False

Must be False.

---

**`**kwargs`** `str | bool | DeviceMesh | None` — default: \{}

Checkpointer compatibility arguments passed to the decoder adapter.

---

**Returns:** `dict[str, torch.Tensor]`

HF tensor layouts, including \[streams \* hidden, streams] MTP head

**Raises:**

* `NotImplementedError`: If load destinations, quantization or sharded tensors are requested.
* `ValueError`: If the eight owned parameters and persistent router bias are not present exactly once.

```python
nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter._mtp_body_suffix(
    decoder_suffix: str
) -> str
```

Use the released extra nesting for the ten shared hyper-connection tensors.

```python
nemo_automodel.components.models.ernie5_5.mtp_state_dict_adapter._OWNED = {'enorm.weight': 'enorm.weight', 'hnorm.weight': 'hnorm.weight', 'e_proj.weight'...
```