nemo_automodel.components.models.mimo_v2_flash.state_dict_adapter
nemo_automodel.components.models.mimo_v2_flash.state_dict_adapter
Module Contents
Classes
Functions
Data
API
Bases: MoESplitExpertsStateDictMixin, StateDictAdapter
Convert MiMo-V2-Flash HF checkpoints to Automodel’s grouped MoE layout.
HF stores routed experts as split per-expert projections:
mlp.experts.{E}.{gate,up,down}_proj.weight. Automodel groups those
into gate_and_up_projs and down_projs so EP can shard experts
without materializing every expert on every rank.
Whether checkpoint tensors use MiMo-V2.6 fused QKV and MXFP4 experts.
TP degree interleaving fused QKV rows in the source checkpoint, resolved once.
Rename matching state-dict leaves in place without touching prefixes.
Replace checkpoint fused QKV tensors with native split projections.
Parameters:
Checkpoint tensor mapping. Fused QKV weights have shape [checkpoint_tp_size * local_qkv_rows, hidden], and optional scale tensors have shape [checkpoint_tp_size * local_scale_rows, hidden_blocks].
Returns: dict[str, Any]
The mutated mapping with split query, key, and value weights.
Copy a full checkpoint-layout conversion into local model storage.
Parameters:
Native Tensor or DTensor with the global projection shape.
Rank-local model storage for native_tensor.
Full deinterleaved projection in checkpoint dtype conversion output.
Expand packed expert weights into the native floating-point layout.
Parameters:
Checkpoint tensor mapping. MXFP4 expert weights have
shape [output, input / 2], and their weight_scale tensors
have shape [output, input / 32].
Returns: dict[str, Any]
The mutated mapping with floating-point expert matrices.
Return the rank-local storage view for a Tensor or DTensor.
Create V2.6 fused-QKV checkpoint buffers for three native weights.
Parameters:
Projection prefix ending in self_attn.
Decoder layer index selecting full or sliding shapes.
Native query weight of shape [query_rows, hidden].
Native key weight of shape [key_rows, hidden].
Native value weight of shape [value_rows, hidden].
Returns: dict[str, torch.Tensor]
Fused FP8 weight and FP32 inverse-scale destinations using the exact
Create packed MXFP4 destinations for one logical expert matrix.
Parameters:
Checkpoint expert weight key.
Logical expert view of shape [output, input].
Returns: list[tuple[str, torch.Tensor]]
Packed E2M1 weight [output, input / 2] and E8M0 scales
Map one native MiMo tensor name back to its Hugging Face leaf name.
Convert native tensors to MiMo checkpoint keys and load destinations.
Dequantize one OCP MXFP4 matrix from the MiMo-V2.6 checkpoint.
Parameters:
Packed E2M1 tensor of shape [output, input / 2], with the earlier input element in the low nibble of each byte.
Unsigned E8M0 block scales of shape [output, input / 32].
Floating-point dtype for the returned training weight.
Returns: torch.Tensor
Dequantized tensor of shape [output, input].
Return per-checkpoint-shard Q, K, and V row counts for one layer.
Read the fused-QKV storage TP degree recorded in a checkpoint’s safetensors index.
MiMo-V2.6 checkpoints record it as metadata.tp_size in model.safetensors.index.json; an index without
the field describes a checkpoint saved without TP interleaving. Local directories are read directly; Hugging Face
repository IDs are resolved from the local cache only.
Parameters:
Local checkpoint directory or Hugging Face repository ID.
Optional Hub revision or commit hash for the cache lookup.
Returns: int
metadata.tp_size, or 1 when the index records none.
Raises:
ValueError: If the index cannot be found or records an invalid TP degree.
Return the fused-QKV checkpoint TP degree from the index of the checkpoint config was loaded from.
Convert MiMo’s checkpoint-TP-interleaved fused QKV matrix to split projections.
Parameters:
Fused tensor of shape [checkpoint_tp_size * (q_rows + k_rows + v_rows), hidden].
Optional FP8 inverse scales of shape [checkpoint_tp_size * ceil((q_rows + k_rows + v_rows) / 128), ceil(hidden / 128)].
MiMo model configuration.
Decoder layer index used to select full or sliding dimensions.
TP degree whose shards are interleaved in weight.
Floating-point dtype for dequantized weights.
Checkpoint key used in diagnostics.
Returns: torch.Tensor
Query, key, and value weights with shapes [q_total, hidden],