nemo_automodel.components.models.mimo_v2_flash.cp
nemo_automodel.components.models.mimo_v2_flash.cp
MiMo adapters for the framework Transformer Engine THD sharder.
Module Contents
Functions
Data
API
Reproduce TE’s data-dependent THD token partition for every chunk.
Parameters:
Unsharded packed batch. input_ids has shape [batch,
sequence] and seq_lens_padded has shape [batch, documents].
Optional one-dimensional context-parallel mesh.
Number of equal pipeline chunks along the batch axis.
Sentinel used in ragged length rows.
Returns: torch.Tensor
Global token indices with shape [local_tokens] for one chunk or
Flatten batch rows into one token stream per pipeline chunk.
Parameters:
Token-aligned tensor of shape [batch, sequence].
Number of equal groups along the batch axis.
Returns: torch.Tensor
Tensor of shape [num_chunks, batch * sequence / num_chunks], or a
Build a global placeholder mask before Transformer Engine shards tokens.
Parameters:
Unsharded token IDs of shape [batch, sequence].
Image or video placeholder ID, or None when absent.
Number of pipeline token streams.
Returns: torch.Tensor | None
Boolean mask in global THD stream order, with shape [tokens] for one
Create MiMo’s thin adapter around the framework TE THD sharder.
Parameters:
MiMo model or pipeline-local part to configure from the runtime CP mesh.
Number of pipeline microbatch streams.
Optional image placeholder token ID.
Optional video placeholder token ID.
Returns: ContextParallelSharder
An unresolved :class:ContextParallelSharder configured by the caller’s
Delegate MiMo packed CP to the framework TE THD sharder.
The wrapper records global VLM placeholder masks and TE’s local-token index map before the framework mutates the packed batch. Those tensors let MiMo select exactly the image/video features owned by each DualChunkSwap shard. It also preserves the PP media side channel, which is intentionally not a token-aligned tensor and therefore must not be split by the THD helper.
Parameters:
Optional one-dimensional context-parallel mesh.
Unused tensor-parallel mesh required by the sharder protocol.
Packed batch whose token tensors have shape [batch, sequence].
MiMo model or pipeline-local part whose TE attention is configured from the runtime CP mesh before the first forward.
Optional loss mask passed by the sharder protocol. Labels already carry the loss ignore value, so this is unsupported here.
Token ID used for physical THD padding.
Number of pipeline microbatch streams.
Optional image placeholder token ID.
Optional video placeholder token ID.
Returns:
A null transport context, the TE-prepared batch, and its