nemo_automodel.components.models.beam.parallelization
nemo_automodel.components.models.beam.parallelization
Model-owned FSDP2 parallelization for Beam: isolate the fp32 router and preserve fp32 RoPE inputs.
Every FSDP unit goes through BeamModelParallelizer._fully_shard_module: Beam blocks disable FSDP’s automatic
forward-input cast and cast hidden states themselves, so the fp32 RoPE tables reach attention unchanged. Decoder
blocks are sharded into dtype-uniform units, so the fp32 router (_keep_in_fp32_modules_strict) gets its own
unit: the MoE/EP path does this through the shared fully_shard_by_dtype block sharding, the dense FSDP2 path
through BeamModelParallelizer._apply_fsdp_sharding.
Module Contents
Classes
Functions
Data
API
Bases: ModelParallelizer
Shard Beam with an fp32 router unit and fp32 RoPE tables kept across block boundaries.
Run the shared dense FSDP2 walk with Beam blocks sharded into dtype-uniform units.
Apply beam_fully_shard_unit to every FSDP unit.
Bases: ModelParallelizer
Dense FSDP2 walk helper: Beam blocks go through fully_shard_by_dtype, other units unchanged.
The MoE path already shards each block with fully_shard_by_dtype; the dense walk wraps each layer with a
single _fully_shard_module call, which this helper turns into the same dtype-aware block sharding.
Shard a Beam block into dtype-uniform units; shard any other module as one Beam unit.
Shard one FSDP unit without casting a Beam block’s FP32 rotary inputs.
For Beam blocks, clone the policy with cast_forward_inputs=False and record param_dtype on the unwrapped block, whose forward casts hidden states itself. Other modules use the policy unchanged.
Parameters:
Module to wrap; a Beam block may be wrapped for activation checkpointing.
Mixed-precision policy for this unit.
Remaining fully_shard arguments (mesh, reshard_after_forward, offload_policy, …).
Returns: nn.Module
The sharded module.
True for a Beam decoder Block, also when wrapped for activation checkpointing.