nemo_automodel.components.models.mimo_v2_flash.model
nemo_automodel.components.models.mimo_v2_flash.model
Module Contents
Classes
Functions
Data
API
Bases: Module
MiMo-V2 attention with a Transformer Engine THD context-parallel path.
Apply partial RoPE to BSHD or flattened THD query/key tensors.
Run TE attention with native V dimensions, padding for legacy TE a2a CP.
Parameters:
Tensor of shape [batch, sequence, hidden] for BSHD, or [tokens, hidden] for THD; a singleton batch is also accepted.
Cosine and sine tensors aligned to the input sequence, each ending in the rotary feature dimension.
Optional mask of shape [batch, sequence] for BSHD.
TE attention metadata, including one-dimensional cumulative sequence-length tensors for THD inputs.
Returns: torch.Tensor
Attention output with the same shape as hidden_states.
Validate the head partition required by TE’s a2a CP transport.
Validate and attach TE all-to-all context parallelism.
Bases: Module
Decoder block that alternates dense MLP and routed-MoE layers.
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Causal LM wrapper for MiMo-V2-Flash with Automodel checkpoint adapters.
Encode global media and splice only this TE THD shard’s feature rows.
Map local TE THD placeholders to rows in globally ordered media features.
Retrieve PP media using global masks so every CP rank runs the same vision work.
Keep both rotary embeddings per stage and the vision tower on stage zero.
Run the text or vision-language forward and project the kept positions to vocabulary logits.
Packed (THD) input requires the TE backend and cu_seqlens; each TE shard splices only its own media
feature rows.
Parameters:
Optional token IDs of shape [batch, sequence], or packed (THD) IDs of shape [1, tokens] or [tokens]. Later pipeline stages pass hidden states of shape [batch, sequence, hidden] or [1, tokens, hidden].
Optional embeddings of shape [batch, sequence, hidden], or [1, tokens, hidden] when packed, used instead of input_ids.
Optional positions of shape [batch, sequence], or [1, tokens] when packed; None numbers positions 0 to sequence - 1, across the whole pack for packed input.
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding.
Without TE it may instead be a bool or additive mask of shape [batch, 1, sequence, sequence], or a
dict of such masks keyed full_attention and sliding_attention. Packed input ignores it.
Optional bool Tensor of shape [batch, sequence], or [1, tokens] when packed, true at padding; when None, it is derived from a Tensor attention_mask.
Optional flattened image patches of shape [patches, patch_features].
Optional int grid of shape [images, 3] holding each image’s (t, h, w) patch counts, or [images, 2] holding (h, w).
Optional flattened video patches of shape [patches, patch_features].
Optional int grid of shape [videos, 3] holding each video’s (t, h, w) patch counts.
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: qkv_format, int32 cu_seqlens and
cu_seqlens_padded of shape [1, documents + 1] or [documents + 1], padded with -1000,
max_seqlen, cp_size and cp_rank, plus the private media and local-token maps that
MiMo’s context-parallel sharder adds, which this method consumes.
Returns: CausalLMOutputWithPast | torch.Tensor
With _pp_return_hidden_states set, the hidden states Tensor of shape [batch, sequence, hidden], or
Describe PP tensors using the already TE-sharded local token length.
Install MiMo’s model-local adapter around framework TE THD sharding.
Bases: Module
Backbone model for Xiaomi MiMo-V2-Flash.
Run the text backbone in BSHD or genuine TE THD layout.
THD batches must already have passed through the framework TE sharder. Their cumulative lengths delimit packed documents and are forwarded to every attention layer, including non-first pipeline stages.
Bases: Module
Rotary embedding module matching MiMo-V2-Flash partial-RoPE behavior.
Build the FP32 inverse frequencies on the requested device.
Restore a non-persistent RoPE buffer after meta-model materialization.
Bases: MiMoV2FlashForCausalLM
MiMo-V2.5/V2.6 wrapper using the mimo_v2 checkpoint config.
Resolve a MiMo-V2 config while checkpoint loading remains framework-owned.
Bases: Module
RMSNorm used by MiMo-V2-Flash decoder blocks.
Construct a MiMo RMSNorm from the configured backend.
Apply causal sliding-window bounds to an existing 4D document mask.
Accept the THW grids emitted by Qwen processors and PP’s HW alias.
Replace one kind of multimodal placeholder while preserving gradients.
Reject the known pre-9.26 cuDNN ragged dSink kernel bug.