> 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.ergo.parallelization

Ergo precision policy over the shared FSDP sharding implementation.

## Module Contents

### Classes

| Name                                                                                          | Description                                                           |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [`ErgoParallelizer`](#nemo_automodel-components-models-ergo-parallelization-ErgoParallelizer) | Isolate FP32 scale/router/embedding owners under BF16 branch compute. |

### API

```python
class nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer()
```

**Bases:** `ModelParallelizer`

Isolate FP32 scale/router/embedding owners under BF16 branch compute.

```python
nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._apply_unsharded(
    model: torch.nn.Module,
    mesh_context: nemo_automodel.components.distributed.mesh.MeshContext
) -> torch.nn.Module
```

Keep explicit compute views on singleton FSDP groups, including PP stages.

Generic unsharded autocast does not round the FP32-logit head's master
weight to branch compute dtype. Size-one FSDP uses the same model-owned
precision policy as larger groups and preserves FP32 optimizer leaves.

```python
nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._fully_shard_module(
    module: torch.nn.Module,
    mesh: torch.distributed.device_mesh.DeviceMesh,
    mp_policy: torch.distributed.fsdp.MixedPrecisionPolicy | None = None,
    offload_policy: torch.distributed.fsdp.OffloadPolicy | None = None,
    reshard_after_forward: bool | int | None = None,
    ignored_params: set[torch.nn.Parameter] | None = None
) -> torch.nn.Module
```

Preserve model-owned FP32 computation through shared dtype grouping.

**Parameters:**

**`module`** `nn.Module`

Owner of matrices \[output, input], expert projections
\[experts, input, output], expert scales \[experts, hidden], and
normalization/residual vectors \[hidden]. Modified in place.

---

**`mesh`** `DeviceMesh`

FSDP data-shard mesh, preserving existing expert placements.

---

**`mp_policy`** `MixedPrecisionPolicy | None` — default: None

Branch compute policy; explicit model casts own inputs
and outputs, including the FP32 residual stream.

---

**`offload_policy`** `OffloadPolicy | None` — default: None

Shared parameter offload policy.

---

**`reshard_after_forward`** `bool | int | None` — default: None

Shared FSDP resharding setting.

---

**`ignored_params`** `set[nn.Parameter] | None` — default: None

Arbitrary-shaped parameters already owned by other
sharding units; their placements remain unchanged.

---

**Returns:** `nn.Module`

The same module with global-shaped DTensor parameters and dtype

```python
nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._prepare_model(
    model: torch.nn.Module,
    mesh_context: nemo_automodel.components.distributed.mesh.MeshContext
) -> None
```

Bind attention and MoE to the stage's CP group before FSDP owns weights.

```python
nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._use_full_layer_activation_checkpointing(
    model: torch.nn.Module
) -> bool
```

Checkpoint stateless residual blocks without wrapping the read-only MLP alias.

The shared submodule fallback discovers `mlp` first. Ergo exposes that
name only for MoE discovery; execution and checkpoint keys belong to
`feed_forward`. Whole-block replay preserves that single owner and
also recomputes the FP32 normalization/residual operations.