nemo_automodel.components.models.praxis.parallelize
nemo_automodel.components.models.praxis.parallelize
Parallelization of PraxisPolicy for training.
FSDP2 shards every block of the two backbone towers and the action expert over the data-parallel
mesh. With distributed.ep_size > 1 the MoE feed-forwards are expert parallel through the shared
MoE machinery (expert sharding, the backend’s token dispatcher, dispatch replay under activation
checkpointing), as in the language-model MoE path; the walk lives here because the Praxis blocks sit
in two stacks under backbone and one under action_expert rather than in a single layers
list.
Module Contents
Classes
Functions
API
Bases: ModelParallelizer
Model-owned parallelization of PraxisPolicy, the parallelizer of the model class.
The shared flows walk one layers stack; these hooks walk the Praxis towers with
shard_policy instead, with (_apply_moe) and without (_apply) expert parallelism,
and on one rank (_apply_unsharded).
Shard model for FSDP2 without expert parallelism; the experts stay inside their blocks.
Shard model for the FSDP2 strategy, and the expert parallelism, of mesh_context.
One data-parallel rank: the per-block FSDP2 wrapping and activation checkpointing over the one-rank mesh.
The block stacks of the model: encoder tower, decoder tower, action expert.
The expert-parallel mesh and the mesh the experts are FSDP-sharded over; None when unused.
The MoE feed-forward of a backbone block, or None for dense and action-expert blocks.
Turn every router’s selection bias into a DTensor replicated over mesh.
FSDP2 leaves buffers as plain tensors, and the shared gate steps a plain bias from this rank’s
expert load alone. Replicated, its update sums the load over all ranks of mesh and applies the
same step on every rank, as the reference trainer does.
Parameters:
The model; its MoE gates hold e_score_correction_bias.
Data-parallel device mesh.
Shard the two backbone towers and the action expert block by block, then the root.
Every transformer block is one FSDP2 unit. With activation_checkpointing each block recomputes
its activations in the backward pass; for an MoE block the router projection and its top-k
selection are saved instead of recomputed when ignore_router_for_ac is set, which keeps the
recompute’s routing and expert dispatch identical to the forward’s. With a moe_mesh whose
ep axis has more than one rank the routed experts are expert parallel: every expert lives
whole on one rank of that axis, the backend’s token dispatcher exchanges the tokens, and the
experts are FSDP-sharded over the ep_shard axis when that axis has more than one rank. The
routers’ selection biases become DTensors replicated over mesh
(replicate_router_biases), so that their load-balancing steps use the expert load of all
ranks.
With LoRA on the action expert the decoder tower never runs, so its units have no unsharded state while the root accumulates gradients across micro-steps; the FSDP guard patch skips them.
Parameters:
The model, built on the meta device.
Data-parallel device mesh of the FSDP shards.
Parameter and reduction dtypes of the shards.
MoE mesh with the ep and, optionally, ep_shard axes; None without expert
parallelism.
Recompute the blocks’ activations in the backward pass.
Save the MoE routing across the recompute instead of recomputing it.
Free each unit’s gathered parameters after its forward.
FSDP2 offload policy of the units, or None for none.