nemo_automodel.components.models.gemma4_moe.parallelization
nemo_automodel.components.models.gemma4_moe.parallelization
Gemma4-owned tensor-parallel plan and FSDP2 strategy registration.
Module Contents
Classes
Functions
API
Bases: ParallelStyle
Shard a Gemma4 linear on input features with a synchronous reduction.
Partition [output, input] weight as Shard(1) and install the local linear.
Bases: ParallelStyle
Shard a Gemma4 embedding by vocabulary without DTensor MaskPartial.
The input ids are replicated [batch, sequence]. The weight changes from
[vocab, embedding] to a DTensor with Shard(0); the forward returns a
local, replicated [batch, sequence, embedding] Tensor.
Partition one Gemma4 embedding weight and install its local lookup.
Bases: Function
Sum local TP values in forward and leave replicated gradients local.
Pass replicated gradients unchanged to each owning TP shard.
Reduce a local contribution Tensor into one replicated Tensor.
Apply one Gemma4 row-parallel linear and synchronously reduce its output.
Parameters:
Linear whose weight is a DTensor sharded on input features.
Local Tensor shaped [..., input_features / tp_size].
Returns: torch.Tensor
Local Tensor shaped [..., output_features], replicated across the
Return the TP plan for the concrete Gemma4 checkpoint variant.
E2B/E4B add a packed per-layer embedding table that is absent from 31B. Row-sharding that table by vocabulary is important: at E4B dimensions it is roughly 2.8 billion parameters, so leaving it replicated defeats much of the memory benefit of TP.
Parameters:
Gemma4 conditional-generation model whose text config selects the dense variant.
Whether sequence parallelism was requested. Gemma4 does not currently support it, so the request is ignored.
Returns: dict[str, ParallelStyle]
Mapping from Gemma4 module paths to PyTorch parallel styles.
Look up replicated token ids in one Gemma4 vocabulary shard.
Parameters:
Gemma4 embedding whose weight is a DTensor sharded on vocabulary.
Replicated integer Tensor shaped [batch, sequence].
Returns: torch.Tensor
Local Tensor shaped [batch, sequence, embedding], replicated across
Register Gemma4’s model-owned FSDP2 strategy once.