For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python module
max.pipelines.architectures.mimo_v2
MiMo-V2.6-Flash (MiMoV2ForCausalLM).
MiMoV2Config
class max.pipelines.architectures.mimo_v2.MiMoV2Config(*, vocab_size, hidden_size, num_hidden_layers, rms_norm_eps, layer_types, num_attention_heads, head_dim, v_head_dim, qkv_layouts, rotary_dim, rope_thetas, sliding_window, attention_value_scale, sinks, intermediate_size, moe_layers, n_routed_experts, num_experts_per_tok, moe_intermediate_size, norm_topk_prob, quant, dtype, devices, kv_params, max_seq_len, use_subgraphs=True, return_logits=ReturnLogits.LAST_TOKEN, return_hidden_states=ReturnHiddenStates.NONE, target_layer_ids=None)
Bases: ArchConfigWithStoredKVParams, ArchConfigWithKVCache
Model configuration for MiMo-V2.6-Flash.
attention_chunk_size in the checkpoint config is a leftover key and is
deliberately not read: the model has no chunked local attention.
-
Parameters:
-
- vocab_size (int)
- hidden_size (int)
- num_hidden_layers (int)
- rms_norm_eps (float)
- layer_types (list[str])
- num_attention_heads (int)
- head_dim (int)
- v_head_dim (int)
- qkv_layouts (dict[str, QkvChunkLayout])
- rotary_dim (int)
- rope_thetas (dict[str, float])
- sliding_window (int)
- attention_value_scale (float)
- sinks (dict[str, bool])
- intermediate_size (int)
- moe_layers (set[int])
- n_routed_experts (int)
- num_experts_per_tok (int)
- moe_intermediate_size (int)
- norm_topk_prob (bool)
- quant (MiMoV2QuantScheme)
- dtype (DType)
- devices (list[DeviceRef])
- kv_params (KVCacheParamInterface)
- max_seq_len (int)
- use_subgraphs (bool)
- return_logits (ReturnLogits)
- return_hidden_states (ReturnHiddenStates)
- target_layer_ids (list[int] | None)
DEFAULT_ENCODING
DEFAULT_ENCODING: ClassVar[max.pipelines.lib.config.SupportedEncoding] = 'float4_e2m1fnx2'
SUPPORTED_ENCODINGS
SUPPORTED_ENCODINGS: ClassVar[set[max.pipelines.lib.config.SupportedEncoding]] = {'float4_e2m1fnx2'}
attention_scale
property attention_scale: float
The softmax scale, from the unpadded Q/K head dim.
attention_value_scale
attention_value_scale: float
construct_kv_params()
classmethod construct_kv_params(huggingface_config, pipeline_config, devices, kv_cache_config, cache_dtype, *, allow_kv_head_replication=False)
Builds the {sliding_attention, full_attention} KV tree.
-
Parameters:
-
- huggingface_config (AutoConfig)
- pipeline_config (PipelineConfig)
- devices (list[DeviceRef])
- kv_cache_config (KVCacheConfig)
- cache_dtype (DType)
- allow_kv_head_replication (bool)
-
Return type:
devices
dtype
dtype: DType
from_huggingface_config()
classmethod from_huggingface_config(huggingface_config, *, devices, kv_params, max_seq_len)
Builds the config from the checkpoint’s HuggingFace config.
-
Parameters:
-
- huggingface_config (AutoConfig) – The checkpoint’s top-level config.
- devices (list[DeviceRef]) – The devices to build for.
- kv_params (KVCacheParamInterface) – The KV cache tree, from
construct_kv_params(). - max_seq_len (int) – The maximum sequence length to build for.
-
Returns:
-
The config.
-
Raises:
-
ValueError – If the config describes a variant this implementation does not handle, or a quantization other than Xiaomi’s.
-
Return type:
head_dim
head_dim: int
Q and K head dim.
hidden_size
hidden_size: int
initialize()
classmethod initialize(pipeline_config, model_config=None, *, max_seq_len)
Initializes the config from the pipeline config.
-
Parameters:
-
- pipeline_config (PipelineConfig) – The pipeline configuration.
- model_config (MAXModelConfig | None) – The model configuration to read. Defaults to
pipeline_config.model. - max_seq_len (int) – The maximum sequence length to build for.
-
Returns:
-
The initialized config.
-
Raises:
-
ValueError – If a device is not an SM100 GPU, or the checkpoint is not one this implementation handles.
-
Return type:
intermediate_size
intermediate_size: int
Dense MLP width.
kv_params
kv_params: KVCacheParamInterface
layer_types
Each decoder layer’s KV group, sliding_attention or
full_attention.
max_seq_len
max_seq_len: int
moe_intermediate_size
moe_intermediate_size: int
moe_layers
n_routed_experts
n_routed_experts: int
norm_topk_prob
norm_topk_prob: bool
num_attention_heads
num_attention_heads: int
num_experts_per_tok
num_experts_per_tok: int
num_hidden_layers
num_hidden_layers: int
qkv_layouts
The fused qkv_proj chunk layout of each KV group.
quant
quant: MiMoV2QuantScheme
return_hidden_states
return_hidden_states: ReturnHiddenStates = 'none'
return_logits
return_logits: ReturnLogits = 'last_token'
rms_norm_eps
rms_norm_eps: float
rope_thetas
rotary_dim
rotary_dim: int
Leading Q/K dims that RoPE rotates, NeoX style.
sinks
Whether each KV group has a learned per-head attention sink.
sliding_window
sliding_window: int
Keys a sliding layer attends to, the query’s own included.
target_layer_ids
For ReturnHiddenStates.SELECTED_LAYERS, the layers whose outputs
(post-residual, before the final norm) are returned.
use_subgraphs
use_subgraphs: bool = True
Whether the MoE layers of each attention type share one compiled subgraph.
v_head_dim
v_head_dim: int
vocab_size
vocab_size: int
MiMoV2Model
class max.pipelines.architectures.mimo_v2.MiMoV2Model(pipeline_config, session, devices, kv_cache_config, weights, *, memory_plan, adapter=None, return_logits=ReturnLogits.LAST_TOKEN, max_batch_size=1)
Bases: AlwaysSignalBuffersMixin, GraphPipelineModelWithKVCache[TextContext, Any]
Pipeline model for MiMo-V2.6-Flash.
The graph takes GPT OSS’s inputs (tokens, per-device row offsets, signal
buffers and a {sliding_attention, full_attention} KV tree), so GPT
OSS’s inputs and batching are reused.
-
Parameters:
-
- pipeline_config (PipelineConfig)
- session (InferenceSession)
- devices (list[Device])
- kv_cache_config (KVCacheConfig)
- weights (Weights)
- memory_plan (MemoryPlan)
- adapter (WeightsAdapter | None)
- return_logits (ReturnLogits)
- max_batch_size (int)
batch_processor_cls
batch_processor_cls
alias of GptOssBatchProcessor
execute()
execute(model_inputs)
Runs the model on inputs from GptOssBatchProcessor.
-
Parameters:
-
model_inputs (ModelInputs)
-
Return type:
graph_specs()
graph_specs(model_config)
Returns the decoder graph.
-
Parameters:
-
model_config (MiMoV2Config)
-
Return type:
model
property model: Model
The compiled and initialized model.
model_config_cls
model_config_cls
alias of MiMoV2Config