Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
325230d
server: MiniMax-M3's think block, thinking off and its tool calls (Mi…
BobClawblaw Oct 24, 2026
ba1f072
minimax_m3: serve MiniMax-M3.1-Flash natively on Metal
BobClawblaw Oct 24, 2026
0bb3c80
server: tool_choice required or named on MiniMax-M3 in its own markup…
BobClawblaw Oct 24, 2026
cde0e47
minimax_m3: prompt attention a key head's query heads a tile, and 4,0…
BobClawblaw Oct 24, 2026
5abcfc1
minimax_m3: a prompt scratch's buffers that are never live at once sh…
BobClawblaw Oct 24, 2026
51503bf
minimax_m3: a prompt chunk's expert sort over all 1,024 threads (thre…
BobClawblaw Oct 24, 2026
5f29202
minimax_m3: the router 8 rows and 8 experts a threadgroup (each x loa…
BobClawblaw Oct 24, 2026
394b03f
minimax_m3: a prompt scratch's shared-expert output and sublayer outp…
BobClawblaw Oct 24, 2026
5f981f1
minimax_m3: kernel fixes from the contract (NaN and Inf kept, a stabl…
BobClawblaw Oct 27, 2026
815f27f
core: attention_range forms for Metal's rounding (score rounding, div…
BobClawblaw Oct 27, 2026
1124538
native: qwen27's engine choice moves out of metal.zig into qwen27_eng…
BobClawblaw Oct 27, 2026
7bc76c3
kernel contract: MiniMax-M3's Metal kernels registered (glue, route, …
BobClawblaw Oct 27, 2026
a24bbcc
minimax_m3: config.json as the release publishes it (model_type minim…
BobClawblaw Oct 28, 2026
d3be292
docs: MiniMax-M3.1-Flash on Metal (its recipe page, the README row an…
BobClawblaw Oct 24, 2026
82b07bf
changelog: MiniMax-M3.1-Flash on Metal (#1235)
ashhart Oct 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- The native server takes `--decode-share X` (0 to under 1) instead of refusing it: while a long prompt fills beside running replies, the replies get X of each fill step's time, the same time share `TENSORFOLD_PREFILL_SHARE` sets from the prompt's side (#1327, for #840). It works on the CUDA, Metal and HIP lane servers; DeepSeek, Spark-X on Metal, Qwen4 and the XPU servers ignore it. No model's prompt chunks change size: the flag can also cap a filling prompt's chunks at 512 rows, but that stays off for every model until it is shown to give the same tokens at any cut. Without the flag nothing changes. Thanks to @javierbits and @simon-lin88.

- MiniMax-M3.1-Flash on Metal: the new `minimax_m3` family serves MiniMax's 428B-A23B model (`minimax_m3_vl`, its own `config.json`) on one 256 GB M5 Ultra, with tools, structured output, thinking on or off, images, the prompt cache, two streams and DFlash2 or DSpark drafts that keep replies equal to plain decoding. It reads two community checkpoints, lossy conversions of MiniMax's NVFP4 release, labelled with their cost against it (mean KL 0.244 on mix34, 0.295 on mix256k); everything from those weights on is exact, with a bf16 key/value cache (147,456 tokens on mix256k, 32,768 on mix34). Measured on the M5 Ultra with DFlash2, one stream decodes 44-58 tokens a second on mix256k. `MINIMAX_LOAD_LIMIT_GB` sets the memory budget and `MINIMAX_DRAFTER` picks the drafter (#1235, for #1519). Thanks to @BobClawblaw.

- [The runbook](RUNBOOK.md#prompt-prefill-share-and-budget) documents `TENSORFOLD_PREFILL_SHARE` and `TENSORFOLD_PREFILL_BUDGET`: what each accepts, its default, and how it trades a long prompt's finish against decoding streams' next rounds.

- Flash Next on CUDA drafts a shared round's sampled streams in the batched MTP head pass too, each lane's draft drawn on the host under its own keyed rule from its own row of the pass, the draw its lone pick makes, so drafts and replies are unchanged. On a GB10 at 5 x 131,072, sampled code and chat requests decode 24% and 19% faster in aggregate at 5 streams (15% and 19% at 4), greedy cells and time to first token unchanged, every concurrent reply equal to its lone run. `TF_FLASHNEXT_SAMPLED_HEADS=0` restores drafting those streams one at a time. The parity checker covers sampled and mixed shapes. Receipt: `docs/receipts/flashnext-cuda-sampled-heads/`.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Conversions are explicitly marked: their upstream weights need the linked conver
| Gemma 4 31B, MLX 4-bit | `tensorfold pull mlx-community/gemma-4-31B-it-4bit@696d436c404745a59f30e4939a658162b0a9e57f`<br>`tensorfold pull z-lab/gemma-4-31B-it-DFlash@eabd648301ce28583cc14757912e5e0f84e152e1` | One M5 Mac; M5 Ultra checked. M1-M4 refused. | [Native 31B](docs/recipes/gemma-4-native.md). Name the drafter with `--drafter`; images with `--vision`. |
| Gemma 4 12B, converted MLX 4-bit | `hf download google/gemma-4-12B-it --revision 707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7 --local-dir ~/models/gemma-4-12b-hf`<br>`hf download google/gemma-4-12B-it-assistant --revision 46d4c6f13f0ac0ad827b915669b8df9b81c64c51 --local-dir ~/models/gemma-4-12b-assistant` | One M5 Mac; converted text weights 6.3 GB, image weights 100 MB, plus assistant/caches. M1-M4 refused. | [Convert and serve](docs/recipes/gemma-4-12b-native.md). Upstream download needs `hf`; conversion needs Python, mlx and mlx-lm. Serving is native. |
| Step-5-Preview, converted affine | `hf download stepfun-ai/Step-5-Preview --local-dir ~/models/step5-preview-fp8` | One 256 GB Mac; text 166.9 GiB, MTP adds 2.5 GiB and vision 3.7 GiB. | [Convert and serve](docs/recipes/step-5-preview.md). The documented 256 GB setup serves converted affine weights; converting the upstream FP8 download needs Python and mlx. |
| MiniMax-M3.1-Flash, community affine 3/4-bit | `hf download BobClawblaw/MiniMax-M3.1-Flash-MLX-mix34 --revision 9524999057e0d277d26438606e033e2191fb465c --local-dir ~/models/MiniMax-M3.1-Flash-MLX-mix34`<br>`hf download BobClawblaw/MiniMax-M3.1-Flash-MLX-mix256k --revision 916e7ca1044f1c3e7566163096243c940327224d --local-dir ~/models/MiniMax-M3.1-Flash-MLX-mix256k` | One 256 GB M5 Ultra; 203.7 GiB (32,768-token window) or 189.2 GiB (147,456), plus caches. | [MiniMax-M3.1-Flash](docs/recipes/minimax-m3.1-flash.md). Set `MINIMAX_LOAD_LIMIT_GB`; images with `--vision`. Community checkpoints: lossy conversions of MiniMax's NVFP4 release (KL 0.244 / 0.295). MiniMax Community License. |
| Kolibri-1, block FP8 (research) | `tensorfold pull Aleph-Alpha/Kolibri-1@e52eb4627d11516b0c01de49210ab5a4e4061444` | One NVIDIA GPU; GB10 measured; 74 GB checkpoint. | [Kolibri](docs/recipes/kolibri-1.md). Text only; copy drafts, no EAGLE-3/neural drafter. |
| Liquid AI d1-3B, decisions | Not documented yet. | Native CUDA; RAM minimum not published. | [API section below](#serve-flags). `/v1/systemone` and `/v1/decisions`. |
| Fish Audio Drama 3, speech | Not documented yet. | Native Metal or CUDA; GB10 measured. | [Release audio instructions](CHANGELOG.md#110), [reference voices and dialogue speakers](docs/drama-http-voices.md). `/v1/audio/speech` with [sampling controls](docs/speech-sampling.md); checkpoint and `codec.pth` required. |
Expand Down
1 change: 1 addition & 0 deletions docs/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For agent-assisted contributions, read the [TensorFold contributor skill](SKILL.
| DeepSeek-V4-Flash | [MLX on a 256 GB Mac, DSpark and MTP drafts](deepseek-v4-flash.md) |
| Qwen3.6-35B-A3B | [MLX with MTP drafts, one-GPU CUDA](qwen3.6-moe.md) |
| Step-5-Preview | [Native Metal on one 256 GB Mac: 2-bit experts, MTP drafts, images](step-5-preview.md) |
| MiniMax-M3.1-Flash | [Native Metal on one 256 GB Mac: affine 3/4-bit experts, exact bf16 cache, DFlash2 drafts, images](minimax-m3.1-flash.md) |
| Kolibri-1 | [Native CUDA, block FP8, research checkpoint](kolibri-1.md) |
| LFM2.5-24B-A2B | [Native Metal, MLX 4-bit, shared rounds](lfm2.5-24b-a2b.md) |
| Spark-X2.6-4B | [Native CUDA](spark-x2.6-4b-cuda.md), [native Metal, the bf16 release, contexts to 1M](spark-x2.6-4b-metal.md) |
Expand Down
71 changes: 71 additions & 0 deletions docs/recipes/minimax-m3.1-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# MiniMax-M3.1-Flash on Metal (one 256 GB M5 Ultra)

The `minimax_m3` family serves [MiniMax-M3.1-Flash](https://huggingface.co/MiniMaxAI/MiniMax-M3.1-Flash), a
428B-A23B mixture of experts with block-sparse attention (a lightning indexer picks each row's key blocks) and a
CLIP vision tower, on the lane host: tools, structured output, thinking on or off, images, the prompt cache, two
streams, and drafts from the release's DSpark head or incoai's DFlash2.

MiniMax's release stores its experts in NVFP4 and the rest in MXFP8; as published it takes about 248 GB, more than a
256 GB Mac can give a model. The family reads MLX-style affine groups instead, from two community checkpoints:
lossy conversions of the release, published with its own `config.json` (`minimax_m3_vl`, the language model under
`text_config`), the MLX `quantization` block in place of the release's, and the drafters' weights:

| checkpoint | experts | on disk | window on 256 GB |
| --- | --- | ---: | ---: |
| [`BobClawblaw/MiniMax-M3.1-Flash-MLX-mix34`](https://huggingface.co/BobClawblaw/MiniMax-M3.1-Flash-MLX-mix34) | 4-bit (g128) on 26 of 60 layers, 3-bit (g64) on the rest | 203.7 GiB | 32,768 |
| [`BobClawblaw/MiniMax-M3.1-Flash-MLX-mix256k`](https://huggingface.co/BobClawblaw/MiniMax-M3.1-Flash-MLX-mix256k) | 4-bit on 3 layers, 3-bit on the rest | 189.2 GiB | 147,456 |

Attention, the shared expert, the dense layers and the head are 8-bit in both; both carry the DSpark and DFlash2
weights. Against the release's own weights (1,024 positions teacher-forced, bf16 cache) the conversion costs a mean KL
of 0.244 (80.7% top-1) on mix34 and 0.295 (78.4%) on mix256k. Everything the engine does from the converted weights on
is exact. The key/value cache is bf16: under the 226 GB limit below its caches fit 150,400 tokens on mix256k and 37,376
on mix34. The
[serving recipe](https://github.com/BobClawblaw/minimax-m31-flash-mlx-m5-ultra) has the conversion's studies.

TensorFold's code is Apache-2.0. MiniMax-M3.1-Flash's weights, and these checkpoints made from them, have the MiniMax
Community License: free for non-commercial use; commercial use must show "Built with MiniMax M3.1-Flash" and notify
MiniMax, with its written authorization above US$20 million yearly revenue; its appendix lists prohibited uses.
incoai's DFlash2 drafter, carried in both checkpoints, is Apache-2.0, as its
[model card](https://huggingface.co/incoai/MiniMax-M3.1-Flash-DFlash2/blob/ac07a7c1ecaae26a7ace595756124dca974b432d/README.md)
states at the revision converted (`ac07a7c1`); the release's DSpark head is under MiniMax's licence with the rest.

## Run

```sh
hf download BobClawblaw/MiniMax-M3.1-Flash-MLX-mix34 --revision 9524999057e0d277d26438606e033e2191fb465c \
--local-dir ~/models/MiniMax-M3.1-Flash-MLX-mix34
MINIMAX_LOAD_LIMIT_GB=226 tensorfold serve ~/models/MiniMax-M3.1-Flash-MLX-mix34 \
--context 32768 --parallel 2 --prompt-cache-gib 4 --vision
```

For mix256k (revision `916e7ca1044f1c3e7566163096243c940327224d`), `--context 147456`.

- `MINIMAX_LOAD_LIMIT_GB` bounds weights, scratch and caches together. The default (75% of RAM) holds the weights
but no caches, so set it; at 226 a 145,203-token prompt on mix256k peaked at 210 GiB wired.
- The cache takes 135 KiB a token across the 60 layers; `--parallel 2` streams share it.
- `MINIMAX_DRAFTER`: `dflash2` (the default) or `dspark`; any other value is refused. `--no-drafts` decodes plainly.
- Thinking off ends the prompt with `</mm:think>`, as the model does when it chooses not to think. Tool calls use
MiniMax's `]<]minimax[>[` markup, parsed into OpenAI `tool_calls`; `tool_choice: required` or a named tool is
constrained in that markup (xgrammar's `minimax_m3_xml`).
- Images: at most 576 tokens an image (672 x 672, the release processor's `max_pixels`); larger images are scaled
down. Each image is its own tower pass. No video.

## Checks (Apple M5 Ultra, 256 GB, macOS 27)

- Four layers against transformers' own model: KL at most 0.005. The full model against an MLX reference at the same
weights: KL 0.015.
- 1,024 rows teacher-forced against the release's NVFP4 weights: mix34 KL 0.244 (80.7% top-1), mix256k 0.295 (78.4%).
- Drafted replies equal plain ones (DFlash2 and DSpark); windows equal one-row steps bit for bit; two streams'
replies equal their runs alone; replies are equal with the prompt cache on and off.
- A needle at 145,203 tokens on mix256k (115 s cold; 210 GiB wired at the peak). The tower against transformers':
relative error 0.030 to fp32 (torch bf16: 0.039).
- Decode with DFlash2, one stream (prose / code / structured / list): mix256k 44.0 / 55.8 / 47.8 / 50.9 tokens a
second, mix34 41.2 / 61.3 / 49.3 / 55.3. Cold prompts on mix256k: 1,478 tokens a second at 8,403 tokens, 1,486 at
16,598 and 1,484 at 30,929 (4,096-row chunks); 1,379 at 128k before the kernel fixes.
- The family's 50 Metal kernels are registered with the kernel contract: 50 pass gates 1-4.

## Not covered

- Only the M5's tensor units were checked; nothing smaller than 256 GB holds the weights.
- The release itself: serving it exactly needs native NVFP4/MXFP8 kernels on Metal and a Mac that holds about 248 GB.
- Video input.
2 changes: 2 additions & 0 deletions zig/build/metal_targets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ pub fn metalTargets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s
.{ .name = "tf-gemma4-bench", .path = "zig/tests/gemma4/bench.zig", .about = "Gemma 4 dense step costs: projections alone by rows against whole forwards" },
.{ .name = "tf-gemma4-no-tensor", .path = "zig/tests/gemma4/no_tensor.zig", .about = "Gemma 4's Metal kernels on a Mac without tensor units: what builds, and the row path's bits" },
.{ .name = "tf-spark-run", .path = "zig/tests/spark25/run.zig", .about = "Spark2.5 on Metal: greedy tokens, every position's logits or a prompt's last logits, for the reference's check" },
.{ .name = "tf-minimax-run", .path = "zig/tests/minimax_m3/run.zig", .about = "MiniMax-M3.1-Flash greedy tokens, every position's logits or a prompt's last logits, for the reference's check" },
.{ .name = "tf-minimax-vision", .path = "zig/tests/minimax_m3/vision.zig", .about = "MiniMax-M3.1-Flash's image tower alone: an image's patches and text rows, for tools/vision_ref.py's check" },
.{ .name = "tf-qwen36-row-seam", .path = "zig/tests/qwen36_row_seam.zig", .about = "Model-free fixture: the row projection's bias sums stay fp32 at every width" },
};
for (engine_programs) |p| {
Expand Down
Loading
Loading