nemo_automodel.components.models.minimax_m3_vl
nemo_automodel.components.models.minimax_m3_vl
Subpackages
Submodules
nemo_automodel.components.models.minimax_m3_vl.confignemo_automodel.components.models.minimax_m3_vl.cp_sparse_attnnemo_automodel.components.models.minimax_m3_vl.flopsnemo_automodel.components.models.minimax_m3_vl.layersnemo_automodel.components.models.minimax_m3_vl.modelnemo_automodel.components.models.minimax_m3_vl.msanemo_automodel.components.models.minimax_m3_vl.msa_bindingsnemo_automodel.components.models.minimax_m3_vl.mtpnemo_automodel.components.models.minimax_m3_vl.processingnemo_automodel.components.models.minimax_m3_vl.recomputenemo_automodel.components.models.minimax_m3_vl.state_dict_adapternemo_automodel.components.models.minimax_m3_vl.vision_encoder
Package Contents
Classes
Data
API
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Standalone M3 text backbone for causal LM (Stage 1 parity target).
Whether the packed loader should hand this model _packed_seq_ids (the compact document map)
for every pack, single-document ones included, instead of a [batch, 1, sequence, sequence] mask.
Map ids/positions/padding[B,S] and mask[B,S] or [B,1,S,S] to logits[B,S,V] or MTP logits; MSA uses BSHD.
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
MiniMax M3 VL: CLIP-style vision tower + projector/merger + M3 text backbone.
Vision features (vision_tower(pixel_values, grid_thw)) are spliced into
the text embeddings at image_token_index / video_token_index
positions, then run through the (sparse/dense MoE) language model + lm_head.
Whether the packed loader should hand this model _packed_seq_ids (the compact document map)
for every pack, single-document ones included, instead of a [batch, 1, sequence, sequence] mask.
Embed token ids and splice vision/video features into the embeddings.
Shared by forward and prepare_model_inputs_for_cp so the splice logic
lives in one place.
True when this is a partial pipeline stage (some text modules nulled).
Rewrite auto-generated pipeline FQNs to M3’s real module paths.
M3’s text stack lives directly under self.model and the vision tower
is a top-level sibling (vision_tower). The framework, seeing the
language_model property, derives a nested model.language_model.
prefix for the text modules and a model. prefix for the multimodal
encoders. Map both back to M3’s actual paths so per-stage module nulling
keeps/drops the correct submodules.
Run one MiniMax-M3 VL microbatch, consuming staged PP media when present.
Parameters:
Token IDs of shape [batch, sequence] on the first stage, with one placeholder per merged vision token, or float hidden states of shape [batch, sequence, hidden] from the previous pipeline stage. Under CP they stay full-length until the embeddings are sharded here.
Optional image patch rows of shape [patches, patch_features], where patch_features is channels * temporal_patch_size * patch_size**2 and each image’s time * height * width patches are concatenated in image order. When both media inputs are None, the next staged PP media chunk is used.
Optional tensor of shape [images, 3], or a list of [time, height, width] triples, storing each image’s patch grid.
Optional video patch rows of shape [patches, patch_features], laid out like pixel_values.
Optional tensor of shape [videos, 3], or a list of [time, height, width] triples, storing each video’s patch grid.
Optional tensor of shape [batch, sequence]; under CP, sequence is the local shard.
Optional mask of shape [batch, sequence] or [batch, 1, sequence, sequence].
Optional tensor of shape [batch, sequence, hidden].
When set outside pipeline parallelism, skip the LM head and return hidden states for the fused loss.
Attention metadata forwarded to the text model.
Returns: torch.Tensor | MiniMaxM3CausalLMOutput | dict[str, torch.Tensor]
Logits of shape [batch, sequence, vocab], or hidden states of shape
Return modules whose inputs are the DSpark target features of layer_ids.
The feature of layer i is the residual stream entering layer i + 1.
For the last layer that is the stream entering the final norm, so the
draft sees the same unnormalized last-layer state as at serving time
instead of the normalized hidden state that feeds lm_head. Each
decoder block’s input norm and the final norm take that stream as their
first positional argument.
Parameters:
Strictly increasing decoder-layer indices in
[-1, num_hidden_layers); -1 selects the stream entering
layer 0.
Returns: nn.Module
Modules ordered like layer_ids. Each receives a tensor of shape
Raises:
ValueError: If the indices are duplicated, unsorted, or outside the decoder depth, or this rank does not hold the final norm.
Per-stage input/output meta tensors for the PP schedule’s shape inference.
First stage consumes the FULL token ids [mb, seq]; later stages
consume hidden states. The final stage (owning lm_head) emits logits;
earlier stages emit hidden states.
Under context parallelism the first stage embeds the full sequence and
shards it to this rank’s round-robin chunk pair inside forward
(see shard_sequence_for_cp_round_robin), so every stage output and every
later-stage input carries the LOCAL (padded-to-2*cp then //cp)
sequence length while the first stage’s input stays full-length. At
cp_size == 1 the lengths coincide and the layout is symmetric.
Return a sharder-only CP backend; embed + splice + shard happen in forward.
The returned ContextParallelSharder round-robin-shards only the
no-grad aux streams (labels/position_ids/loss_mask/padding_mask) via
shard_batch_aux_only, leaving input_ids and the multimodal inputs
full-length; the forward then embeds + splices and calls
shard_sequence_for_cp_round_robin per microbatch, so embeddings and vision stay
trainable under CP. Nothing is consumed here.
Defining this method is the opt-in signal the recipe checks
(hasattr(model, "prepare_model_inputs_for_cp")).
Parameters:
The full-sequence batch; left intact (nothing consumed).
Accepted for hook-signature parity; unused (round-robin CP).
Bases: PretrainedConfig
Top-level configuration for MiniMax M3 vision-language checkpoints.
Bases: PretrainedConfig
Configuration for the MiniMax M3 (mixed sparse/dense MoE) text backbone.
Bases: PretrainedConfig
Configuration for the MiniMax M3 VL CLIP-style vision tower (Conv3d + 3D RoPE).