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