nemo_automodel.components.distributed.model_parallelizer
nemo_automodel.components.distributed.model_parallelizer
Resolve and execute model-owned parallelization sidecars.
Module Contents
Classes
Functions
Data
API
Single model-owned parallelization sidecar contract.
Apply the shared dense FSDP2 implementation.
Wrap the model’s submodules into FSDP2 units.
Model-owned sidecar strategies deriving from this class override this
hook to change how parameters are grouped into FSDP units without
reimplementing the surrounding TP/AC/mixed-precision flow. Override
_fully_shard_module when a model needs a different primitive.
Apply the expert-parallel flow selected by mesh_context.ep_size > 1.
The shared flow walks one decoder layers stack. A model whose MoE blocks live
in several towers overrides this hook and shards them itself.
Prepare model for FSDP2 when the mesh has no sharding dimension (one data-parallel rank).
The shared flow skips fully_shard, installs activation checkpointing on one decoder
layers stack and wraps the forward in autocast. A model whose blocks live in several
towers overrides this hook.
Apply the FSDP2 primitive used by this model sidecar.
Give large trainable untied embedding tables independent FSDP buffers.
The generic dense path otherwise leaves both tables in the root FSDP unit.
With fp32 gradient reduction, that unit allocates one contiguous
reduce-scatter input containing both gradients. Keeping the two trainable
leaf modules in separate FSDP units bounds that allocation by the larger
table instead of their sum. This pass skips tied tables to preserve aliasing,
and frozen tables because they have no gradient communication buffer
to split. Tables already wrapped as FSDP units retain their existing
reshard policy. With an explicit reshard_after_forward=True, a
container-hosted head reshards while a newly split top-level head stays
gathered. FusedLinearCrossEntropy handles the sharded weight with correct
gradients, at the cost of an extra all-gather.
Parameters:
Model whose input and output embedding modules may be sharded.
Device mesh that owns the FSDP shards.
Mixed-precision policy used by the surrounding FSDP units.
Optional offload policy used by the surrounding FSDP units.
Whether the input embedding unit reshards its parameters after forward.
Validate model constraints and install runtime mesh state before strategy dispatch.
A sidecar can reject unsupported topologies or set model-owned context-parallel state here, before any executor changes parameter ownership. The default needs no preparation; all sidecars retain the inherited public entry point.
Return whether this model safely opts into whole-layer checkpointing.
Validate the model’s attention topology against its TP mesh.
Apply every requested parallelism and return the parallelized model.
Execute shared strategy dispatch for one model-owned parallelizer.
Compile FSDP2 layers after parallelization when requested.
Return the class-owned sidecar, or the shared default implementation.
Apply all requested parallelisms through the model-owned contract.