Skip to navigation
ReferenceFull Library ReferenceNemo AutomodelNemo AutomodelComponentsModelsErgonemo_automodel.components.models.ergo.parallelization

nemo_automodel.components.models.ergo.parallelization

View as MarkdownOpen in Claude

Ergo precision policy over the shared FSDP sharding implementation.

Module Contents

Classes

NameDescription
ErgoParallelizerIsolate FP32 scale/router/embedding owners under BF16 branch compute.

API

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

Bases: ModelParallelizer

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

nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._apply_unsharded(
model: torch.nn.Module,
) -> 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.

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 | NoneDefaults to None

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

offload_policy
OffloadPolicy | NoneDefaults to None

Shared parameter offload policy.

reshard_after_forward
bool | int | NoneDefaults to None

Shared FSDP resharding setting.

ignored_params
set[nn.Parameter] | NoneDefaults to 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

nemo_automodel.components.models.ergo.parallelization.ErgoParallelizer._prepare_model(
model: torch.nn.Module,
) -> None

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

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.