Repository navigation
Add MiniMax M3 and M3.1-Flash - #2536
Conversation
|
The runner crash in the 8-concurrent GSM8K runs ( Each sparse-attention layer keeps its index keys in a second cache beside the attention cache. Nothing reads that index cache's offsets. In a batch, those offsets are an array that moves on lazily at every step, so each step's update chained onto the last and kept a small Metal buffer alive. That is 60 more live buffers per decode step, until the batch empties. When it doesn't empty for about 8,000 steps, the runner crashes. Fixed in 1073bbc, now part of this PR: exo's decode step evaluates every cache's offsets, as it already did for Qwen3.5's linear attention lengths. Two regression tests (a stand-in model and a tiny MiniMax M3 through the batch generator) fail without it.
🤖 Generated with Claude Code |
d5eb3a5 to
66ea418
Compare
Landing commit: this PR's change on top of main, with conflicts with the PRs landed before it resolved as in the tested integration build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1073bbc to
612d081
Compare
… the right layers on pipeline ranks Port upstream commit e4db325 from exo-explore/exo PR exo-explore#2543. Every rank of a multi-node decode instance fetches the remote prefill on its own, and the prefill server sends layers by their global index. A pipeline rank holds only layers [start_layer, end_layer), but ingest_into_mlx_cache matched the global index against the rank's local index, so ranks after the first silently loaded layers 0..k. There was no error; attention was simply wrong. Pass the shard's start_layer from MlxBuilder through BatchGenerator to ExoBatchGenerator, and on to ingest_into_mlx_cache as layer_offset. Nothing made the ranks agree on the outcome either: one rank could fall back to local prefill (which runs collectives) while another did not, which hangs. After the fetch, multi-node instances now check with mx_any; if any rank failed, every rank discards its result and prefills the full prompt locally from a fresh cache. Tests: test_pipeline_layer_offset.py (3 tests) passes, verifying that a rank holding layers 3..5 gets exactly those layers with the offset, and layers 0..2 without it. Note: test_sequential_remote_prefill_layer_offset.py cannot be collected due to a pre-existing fork inconsistency — the fork's Architecture class at base 09f75ad is missing fields (exact_think_tags, batched_generation, pipeline_parallel, post_load) that upstream added between PR exo-explore#2536 and exo-explore#2543. The fork's laguna/family.py already uses exact_think_tags=True, creating an import-time TypeError. This is a fork-level issue unrelated to PR exo-explore#2543's changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… PR exo-explore#2557) Port of upstream exo PR exo-explore#2557 (3a8b1b2) onto the fork, based on 09f75ad (the fork's port of upstream exo-explore#2536). A fake Hub (src/exo/download/tests/fake_hub.py) that serves the tree, revision, resolve and CDN endpoints over real TCP, with ETags, Range, redirects and pagination, and injects faults per request: resets, stalls, short bodies, throttling, slow first byte, 5xx, 429 with the RateLimit header, 401/403/404, ignored Range, 416, corrupt bodies, and the endpoint going down (refused or blackholed) and coming back. Repos have a commit history so tests can change files upstream mid-download. A harness (harness.py) runs the real DownloadCoordinator and shard downloader against it, applies the events with the real apply_node_download_progress, and can play the worker's part (re-requesting a wanted model). Timeouts and backoffs are shrunk through a Timing parameter rather than slept through. test_download_failure_modes.py covers network faults, restarts, cancel/delete, duplicate and per-shard starts, disk full, read-only and multiple model dirs, offline mode, upstream changes, hash mismatches and broken repos. The 22 scenarios that fail today are xfail(strict=True) with the reason. Cherry-pick of upstream 3a8b1b2, no conflicts.
Stacked on #2509 (upstream mlx-lm), which is stacked on #2508 (MLX 0.32.4) and #2507 (per-family model folders). It carries #2512's
ReasoningEffortHookcommit unchanged; drop that commit if #2512 lands first.Summary
MiniMax M3 (June) and M3.1-Flash (October 23) are the successors of the MiniMax M2.x models exo already serves. Both are open weights under MiniMax's community licence.
minimax_m3_vl, Add MiniMax M3 model support (text-only) ml-explore/mlx-lm#1398, Ignore HF remote repo changes (temporary fix) #1958, feat(app): open Share Bug Report in a dedicated window #2003), including loading M3.1-Flash's official checkpoint, so it is in deps: move mlx-lm to upstream ml-explore/mlx-lm #2509's pin. The vision tower is not loaded; these cards are text only.What exo adds, in the
minimaxfamily:MiniMaxM3ShardingStrategy, as mlx-lm's ownModel.shard):auto_parallel.py). An nvfp4 switch layer holds one tensor scale per expert (global_scale, shape[experts]). exo's in-place sharding split every parameter of a projection along the same axis, so each rank kept the scales of only half the experts, and the first forward pass failed ([gather_qmm] Global scale must have one entry per expert with shape (128) but got (64)). The scale doesn't depend on which rows or columns a rank keeps: every rank now keeps them all. The new unit test fails that way without it. This affects any nvfp4 checkpoint with per-expert scales under tensor parallelism, not only MiniMax.minimax/parser.py):<mm:think>…</mm:think>. A turn without reasoning starts with a bare</mm:think>: the template renders such turns that way, and the model writes them so. Both tags are dropped from the content.]<]minimax[>[token, so code or markup inside a value can't be taken for a tag. Objects nest as child elements, arrays as<item>children, and scalars are untyped text (booleans astrue/false).<think>in MiniMax's vocabulary (a token the model doesn't use) and picks its JSON tool-call parser because the template contains<tool_call>andtool_call.name.ToolCallResponses without the request's tools. AnOutputParsercan now ask exo to coerce the arguments to the tool schemas, with the coercion the generic tool parser already uses ("3"→3for an integer,"true"→true, nested objects and arrays). The coercion also reads an empty value as[]or{}when the schema says array or object: XML writes both as nothing.ReasoningEffortHookof Add GLM-5.3, and fix GLM-5.2/5.3 output past 2048 tokens #2512, plus a smallTemplateKwargsHookin its own commit):reasoning_effortas<effort>…</effort>and documentslow,medium,high,xhighandmax. exo'sminimalbecomeslow;noneand unset give no effort tag (the template's default). M3's template has no effort.thinking_modeswitch. Forenable_thinking: falseexo now setsthinking_mode=disabled: the system prompt says so and the generation prompt ends with</mm:think>, token for token as the official template renders it.enable_thinking: falseexo ends the generation prompt with</mm:think>, the prefix its system prompt names for thinking disabled.enable_thinking: truestays adaptive on both. M3'sthinking_mode=enabledwould open the reasoning block in the prompt itself, which the output parser can't see.MiniMaxAI/MiniMax-M3.1-Flashmlx-community/MiniMax-M3.1-Flash-Text-4bitmlx-community/MiniMax-M3.1-Flash-Text-3bitMiniMaxAI/MiniMax-M3-MXFP8mlx-community/MiniMax-M3-4bitload_model(strict=True)on lazy placeholders built from the safetensors headers sets every parameter with the right shape. Under exo's non-strict loading, a conversion with the wrong tensor names would otherwise run on random weights.MiniMax-M3.1-Flash-oQ*-mtpmixed conversions (they load, but weren't measured).Test plan
uv run basedpyright(0 errors),uv run ruff check,nix fmt(no changes), and pytest as CI runs it (pytest src -m "not slow" --import-mode=importlib): 1964 passed, 3 skipped, on a Mac Studio with MLX.models/minimax/tests/):</mm:think>, a tag next to a held-back space, the official template's rendering of two tool calls (code with<and quotes, a nested object, a list, an empty list, a float) parsed back with typed arguments, values without a schema, a JSON-looking string argument, and malformed blocks returned as text.apply_chat_template, with the effort and generation-prompt lines of the M3.1 template and the thinking-mode lines of the M3 template.Correctness report
Verdict: PASS. exo's bf16 is closer to the float32 reference than the reference's own bf16 run, and 2x tensor and 2x pipeline parallelism across two Mac Studios pass at full depth.
Setup
MiniMaxAI/MiniMax-M3.1-Flashat2f33a8b9ae49ce7b51c994df97166a7fd059bc2e, every file checked (LFS sha256, git blob ids).mlx-community/MiniMax-M3-4bitat29909f4575501289881466f3b3bd910fdc95bc7c,mlx-community/MiniMax-M3.1-Flash-Text-3bitat71463b23769721057082e06fc14c1a54be981012(their first layers, fetched by tensor)from_pretrained(dtype=...)woulduv.lockbuilds the same tag from source), mlx-lmml-explore/mlx-lmat6b572abas lockedMiniMaxM3VLForCausalLM(SDPA attention,grouped_mmexperts). Float32 for teacher forcing (gold); bfloat16 as the noise baseline and, on truncated checkpoints, for greedy decodingKL is KL(reference ‖ candidate) per scored position, over the reference's top 64 tokens plus a tail bucket (a lower bound of the full-vocabulary KL).
Summary
/v1/chat/completions: one Mac Studio; two, as 2x TP (RDMA) and 2x PP (ring)Tier b at full depth: where the KL is
Mean KL per prompt against the float32 reference:
[truncated] … [tr] [tr]invoke_ur) where every next token is uncertain. Tool-call turns and long contexts are the others.1 + win float32 (as transformers does) or combine the routed experts' outputs in float32 leave these prompts where they are (e.g. raw-json-01 1.45 → 1.33 / 1.47; tools-result-01 0.23 → 0.27 / 0.18). exo in float32 matches the reference on the tool and raw-text prompts (mean KL ≈ 1e-8). So it is bf16 rounding, which the model amplifies at depth, not a difference in the computation. By the precision policy, nothing is changed.Long contexts in float32: the sparse attention's selection is ill-conditioned
Full model across two Mac Studios (tier e)
exo's harness ran the full model in bf16 on the same 25 prompts on a single device, as 2x tensor parallel over RDMA and as 2x pipeline parallel over the ring, and compared the teacher-forced distributions.
distributedthreshold. Chat, knowledge, math, multilingual and reasoning prompts are at 0.006-0.012. Long contexts (1.07), raw text (0.69), code (0.19) and tools (0.17) carry the mean: the prompts where bf16 rounding already moves the model most (tier b above). Tensor parallelism changes the order of the all-reduced sums, and on long contexts that reaches the sparse attention's block selection, as the prefill chunk size does.First 6 layers, in one piece (real weights)
M3 (not M3.1)
mlx-community/MiniMax-M3-4bit, first 4 layers (3 dense full-attention layers, then an MoE layer with sparse attention; RoPE base 5M): against transformers on the checkpoint's exactly decoded 4-bit weights, tier b mean KL 1.5e-5 (transformers bf16 2.5e-5), greedy 25/25 identical, TP mean KL 6.3e-6, PP bit-identical. This conversion folds the shared expert into the routed experts as a 129th; mlx-lm's loader splits it off.MiniMaxAI/MiniMax-M3-MXFP8: its first layers couldn't be fetched in time (the range requests slowed to ~1 MB/s). Instead, the tiny-random M3 was written in exactly its layout: per-expertw1/w2/w3and every other linear as F8_E4M3 values with an E8M0weight_scale_invper 32 inputs, dense MLPs undermlp., and the officialquantization_config. mlx-lm loads it as mxfp8QuantizedSwitchLinearexperts and mxfp8 linears; in float32 it matches transformers at relative L2 ≤ 2.9e-7, logits KL 7e-16, also step by step. The full checkpoint's tensor names and shapes load strictly.Tier f: chat templates
exo's real rendering path (OpenAI request → adapter →
apply_chat_template→encode_prompt) against the official templates rendered by transformers:highnullargument, parallel calls with grouped results</mm:think>)minimal(→low),xhigh, thinking on (exo'smedium)</mm:think>; M3.1's template has no switchthinking_mode=disabled</mm:think>(exo's generic handling)Quantized weights (informational)
mlx-community/MiniMax-M3.1-Flash-Text-4bitholds the official weights repacked for MLX: the sampled tensors (expert values and scales, attention values and scales, a dense MLP) are byte-identical to the official ones.mlx-community/MiniMax-M3.1-Flash-Text-3bitre-quantizes them to 3-bit affine (186.5 GB, the only conversion that fits one 256 GB machine). On the first 6 layers, against the float32 reference of the official weights: mean KL 1.1e-3 (paired excess 9.4e-4), top-1 0.975, top-5 overlap 0.893, greedy 25/25 identical. Six layers understate what the full depth costs.Deviations and caveats
Thresholds
same-precision(tier b): mean KL ≤ 2e-3, or no more than transformers bf16 on the same positions (paired); top-1 limits scaled the same way; greedy departures only at near-ties.distributed(TP): within the reference's own fp32→bf16 noise.distributed-exact(PP): bit-identical.exact(templates): identical token ids, except documented deviations.Reproduce
Performance (official M3.1-Flash weights)
Setup
MiniMaxAI/MiniMax-M3.1-Flash(NVFP4 routed experts, MXFP8 elsewhere), 248 GB in memory.6b572abas pinned inuv.lock.Method: the exo correctness harness perf runner (
exo_harness.perf), batch 1./bench/chat/completions. The prefix cache is off.generation_stats. Peak memory: MLX's peak on the reporting rank / the largest RAM in use on either node during the row (from/state; the whole machine).Observations
Screenshots
MiniMax-M3.1-Flash (the official NVFP4/MXFP8 card) placed by exo as 2x tensor parallel over RDMA on two Mac Studios, answering a chat from the dashboard with thinking on (the reasoning is collapsed): first token after 3.5 s, 26.1 tok/s. Device names are generic.
Dashboard home with MiniMax-M3.1-Flash running tensor parallel on two Mac Studios:
Dashboard chat with MiniMax-M3.1-Flash (2x tensor parallel, RDMA over Thunderbolt):
🤖 Generated with Claude Code