nemo_automodel.components.models.minimax_m2.model
nemo_automodel.components.models.minimax_m2.model
Module Contents
Classes
Data
API
Bases: Module
MiniMax-M2 transformer block with attention + MoE.
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Run the decoder and project the kept positions to vocabulary logits.
Parameters:
Token IDs of shape [batch, sequence], or packed (THD) IDs of shape [1, tokens], which the decoder squeezes to [tokens]. Later pipeline stages pass hidden states of shape [batch, sequence, hidden] or [1, tokens, hidden].
Optional positions of shape [batch, sequence], or [1, tokens] for packed input, which requires them.
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding, or, with SDPA and an explicit padding_mask, a dense mask of shape [batch, 1, sequence, sequence]; packed input ignores it.
Optional bool Tensor of shape [batch, sequence], or [1, tokens] when packed, true at padding; when None, the MoE layers derive it from attention_mask.
0 keeps every position, a positive int keeps the last N positions, and an integer
Tensor of shape [kept] keeps those positions.
Whether the output carries the final hidden states; None reads
config.output_hidden_states.
Backend metadata for the decoder. Packed input sets qkv_format="thd" and passes
int32 cu_seqlens and cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and
max_seqlen.
Returns: CausalLMOutputWithPast
CausalLMOutputWithPast whose logits have shape [batch, kept, vocab], or [1, kept, vocab] for packed
Bases: Module
Run the decoder layers on padded or packed (THD) input.
Packed input arrives batched and is squeezed to [tokens, …] for the layers, which TE’s packed kernels take; the hidden states come back batched.
Parameters:
Token IDs of shape [batch, sequence], or packed token IDs of shape [1, tokens]. Later pipeline stages pass hidden states of shape [batch, sequence, hidden] or [1, tokens, hidden].
Optional positions of shape [batch, sequence]; packed input requires them, as [1, tokens].
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding, or, with SDPA and an explicit padding_mask, a dense mask of shape [batch, 1, sequence, sequence]; packed input ignores it.
Optional bool mask of shape [batch, sequence] or [1, tokens], true at padding.
Backend metadata. Packed input sets qkv_format="thd" and passes int32
cu_seqlens and cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and
max_seqlen.
Returns: torch.Tensor
Hidden states of shape [batch, sequence, hidden], or [1, tokens, hidden] for packed input.