Add MiniMax-M3 (text backbone)#1401
Open
davidrhodus wants to merge 1 commit into
Open
Conversation
Adds support for MiniMax-M3 as a text-only LLM (model_type "minimax_m3"), the text backbone of MiniMaxAI/MiniMax-M3 (~427B MoE). M3 extends MiniMax-M2 with Gemma-style RMSNorm (scale by 1+w), per-head QK-norm, partial RoPE, the SwiGLU-OAI activation, a shared expert plus a routed-scaling factor in the MoE, and the first few layers being dense MLPs. MiniMax Sparse Attention is realized as full causal attention (exact up to topk_blocks*block_size tokens; dense beyond), reusing the existing per-expert w1/w2/w3 sanitize layout and SwitchGLU with a custom activation. Includes a model test config exercising both dense and sparse layers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for MiniMax-M3 as a text-only LLM (
model_type: "minimax_m3") — the text backbone of MiniMaxAI/MiniMax-M3 (~427B-parameter MoE).M3 builds on the existing
minimax(M2) implementation, with these architectural differences handled here:1 + weight)rotary_dim < head_dim)(up + 1)term), reused for the dense MLPs, the shared expert, and the experts (viaSwitchGLUwith a custom activation)mlp_layer_types)index_topk_blocks * index_block_sizetokens (where MSA selects every key block) and the dense, un-approximated attention beyond, so quality is preserved at the cost of MSA's long-context speed/memory savings. The lightning-indexer tensors are dropped insanitize.The checkpoint's per-expert
w1/w2/w3weights are stacked intoSwitchGLUexactly as inminimax.py.Notes
minimax_m3_vl; the vision tower, projector, and MTP heads are not part of this LLM build). Quantized MLX builds produced with this code are published here.Testing
minimax_m3entry totests/test_models.pyexercising both dense and sparse layers.model_test_runnerlogic: forward pass in fp32 and fp16, KV-cache decode, batch size > 1, and deepcopy all pass.🤖 Generated with Claude Code