Instructions to use devin-lai/MiniMax-H3-Image-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use devin-lai/MiniMax-H3-Image-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download devin-lai/MiniMax-H3-Image-mlx --local-dir MiniMax-H3-Image-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download reports/optimization-r3/RESULTS.md from devin-lai/MiniMax-H3-Image-mlx: direct link, hf CLI and curl.
- Browser
- Download file 10.8 kB
-
https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/main/reports/optimization-r3/RESULTS.md
- Command line
-
hf download hf://devin-lai/MiniMax-H3-Image-mlx/reports/optimization-r3/RESULTS.md
-
curl -L -o RESULTS.md https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/main/reports/optimization-r3/RESULTS.md
Exact M5 optimization, round 3
On the local M5 Pro, 16 GPU cores, 64 GiB, the selected Q/K fusion and FC2 tile reduce warm geometric-mean latency from 65.83 s to 62.49 s (5.07%). Maximum sampled parent physical footprint over the timing population decreases from 40.12 to 39.74 GiB. All four declared cases retain identical RGB pixels, conditioning, six velocities, six Euler states and final latents.
This is an incremental comparison with the existing MLX BF16 recipe. It does not claim CUDA byte identity or identity to the separate FP32 decoder. The image gallery links actual matched grids, vertical stacks, native-resolution crops and amplified differences, plus earlier precision-loss examples.
Paired complete-image results
macOS 27.0.1, MLX/MLX Metal 0.32.4, original CPU Torch RNG, all six heads, native compiled VAE batch four, cached conditioning and resident shared weights. Each timing shape receives a full warmup per variant. Repeats alternate AB, BA, AB; black dots in the chart are individual samples. First-load samples are retained separately. The timing includes trace/PNG save and excludes interpreter startup and external image scoring.
| 2048-square case | Native samples (s) | Native median | Tuned samples (s) | Tuned median |
|---|---|---|---|---|
| product | 67.02, 66.80, 64.56 | 66.80 | 63.90, 64.24, 61.27 | 63.90 |
| portrait | 64.23, 64.86, 65.15 | 64.86 | 60.65, 61.11, 62.01 | 61.11 |
The frozen helper reports measured_improvement: all quality gates pass, both timing-case ranges are separated, and the memory constraint passes. This is a descriptive range screen with three repeats, not a statistical confidence interval. Comparison receipt, reopened pixel/tensor audit, timing and memory chart.
Physical footprint is sampled every 100 ms for the parent process, including Metal and excluding compiler XPC services. Short peaks can be missed. MLX allocator peaks and process lifetime high water are separate overlapping counters; they are not added. Both compiled variants can remain resident. The method and frozen scope explain the boundary, environment and references. The two extra quality cases are a detail prompt fixed before search and a reference-image edit; subsequent configurations reuse these cases rather than introducing fresh blind holdouts.
Lossless packed configuration
The existing packed12 BF16 codec combines successfully with the selected exact tuning. Its own paired campaign reduces warm geometric-mean latency from 66.42 to 64.05 s (3.57%), with timing-population physical peak decreasing from 32.04 to 31.83 GiB. All four image and trajectory cases are exact. The helper returns measured_improvement. Receipt, full audit, chart.
| Case | Packed control median (s) | Packed tuned median (s) | Tuned samples (s) |
|---|---|---|---|
| product | 66.74 | 64.86 | 64.86, 65.30, 63.02 |
| portrait | 66.11 | 63.26 | 63.44, 62.98, 63.26 |
Across all observed candidate outputs, including the edit validation rather than just timed cases, maximum sampled physical footprint is 40.50 GiB dense / 32.56 GiB packed. These are separate campaigns: timings are compared against each profile's own paired control, not pooled into a storage speedup. The packing format was implemented in v2; this round validates the new operator tuning with it. Original BF16 payloads are reconstructed exactly before GEMM. No quantization is introduced.
Add --weight-storage packed12 --wired-gb 32 to the dense command below. The existing 50-block, 27.23 GiB cache was reused; no second model cache was created. Compressed arrays remain explicit dynamic inputs to compiled blocks, preventing retained dense-weight constant folding. The separate frozen compact contract allows up to 5% memory regression before measurement; the measured peak actually decreases. Its validation cases are reused, not fresh blind holdouts.
Implemented changes
- Q/K normalization and RoPE: four adjacent BF16 reads per SIMD lane, the installed MLX reduction order, precise reciprocal square root, FP32 affine and explicit BF16 product/add boundaries. The earlier differing fusion did not preserve this arithmetic. The new producer matches complete deployed trajectories.
- M5 FC2: Metal 4 TensorOps, 64×128×512 tile, four SIMD groups, eight-row tile walk, FP32 accumulation and one BF16 epilogue. Dispatch is restricted to the tested M5 Pro/MLX version and 4,096–8,192 joint tokens. The real 6,213-token edit operator improves about 13%; the 16,478-token 4K operator improves under 1%, so 4K retains native execution. The 8,192-row boundary probe repeats real edit activations and is an operator test, not a full 8K-token image qualification.
- Vocabulary row reads: cold encoding reads only requested safetensors rows with original BF16 payloads, preserving order, duplicates and padding. Three fresh-process pairs on real weights reduce this phase from 107.8 ms to 4.95 ms and its sampled physical peak from 1.52 GiB to about 31 MiB. This is an embedding-read result, not a whole-model speedup or peak reduction.
- Memory accounting: JSON now separates process physical memory from MLX active/peak/cache. The SDK struct layout was checked with a compiled C ABI probe.
The released implementation is in tuning.py, ops.py, dit.py, weights.py and memory.py. Unsupported devices, versions and shapes keep native execution. Default precision, schedule and native fallback remain available.
Rejected and conditional results
The full-width RMSNorm/AdaLN fusion is exact on all four cases. It improves an already tuned first block by 4.34%, but its complete-image campaign has 5.24% lower latency and 1.04094% higher timing-population physical peak. That narrowly exceeds the predeclared 1% allowance, so the helper returns no_qualified_improvement. It remains an optional --kernel metal-exact tradeoff. Those samples are not pooled with the selected campaign, and their closeness does not establish an extra whole-model advantage. Receipt.
Other retained experiments include:
| Mechanism | Observed result | Decision |
|---|---|---|
| Six explicit attention-copy layouts | Exact, no useful gain; copying all Q/K/V is slower | Native SDPA layout retained |
| Twelve vector-unpack settings | Decode alone about 20% faster; gain mostly disappears with GEMM | Existing scalar lossless codec retained |
| Eight FC1/SwiGLU dual-accumulator epilogues | Exact; best is still about 0.7% slower | Rejected |
| FC2 K panel 2048 | Operator improves 4.43% vs panel 512, complete block regresses 0.19% | Panel 512 retained |
| RMSNorm threadgroups 256/512 | Tiny BF16 differences; only 1024 reproduces the native loop | Differing operators rejected |
| Free-allocator cache 512 MiB | Block about 1.65% slower, no sampled physical-peak reduction | No allocator-limit change shipped |
There are 72 distinct matrix settings, six attention layouts and twelve unpack settings, plus reduction/layout, block and shape checks. Compiler/harness failures are archived separately and are not successful trials. Decision ledger, source provenance, observed project-local lesson.
Other backends and precision
The previous backend report contains real Torch CPU/MPS, direct Metal/MPSMatrix, and complete 24-block VAE ML Packages on CPU_ONLY, CPU_AND_GPU, CPU_AND_NE and ALL. These are historical measurements, not current controls. The full 33B denoiser remains MLX; no complete ANE/Core ML denoiser export is claimed. ANE VAE quality failures, FP16 projection overflow, quantization and reduced-head losses have real comparison grids and a same-latent device grid.
The same-latent FP32 decoder comparison isolates the existing BF16 decoder choice. Select --vae-dtype float32 when that separate precision/performance tradeoff is preferred. New exact tuning adds no loss relative to the stated MLX reference; that does not erase preexisting cross-backend differences.
Reproduce
Use the pinned environment in requirements-macos.lock and the original local checkpoints. The recommended dense configuration is:
h3-mlx generate --model /path/to/MiniMax-H3-Image \
--text-encoder /path/to/MiniMax-H3/text_encoder \
--compile-blocks --eval-every 0 --prefetch-blocks 4 --wired-gb 42 \
--compile-vae --vae-batch 4 --kernel metal-qk-exact --tune-matmul \
"A detailed image description" --output outputs/tuned.png
The benchmark entry point is python -m experiments.r3.images --deployment --variants qk-fc2-native-norm, with model/encoder paths and a fresh output/comparison directory. Reopen and audit with experiments.r3.report, then validate and compare its receipts with tmp/mlx-skills/scripts/mlx_skill.py. Raw commands and configurations are retained in receipts and output JSON. The wheel is dist/minimax_h3_image_mlx-0.3.0-py3-none-any.whl; runtime source bytes are verified in wheel.json.
Deployment verification
Version 0.3.0 builds as a 55,953-byte wheel. All 21 runtime modules match the repository source bytes. A complete 2048-square generation ran through the CLI from the actual wheel in /tmp, with an assertion preventing checkout imports. The delivered pixels and every saved trajectory tensor match the immutable reference exactly. Its fresh-process outer wall time was 67.35 s, including imports and loading; it is not pooled with warm timings. Wheel/CLI verification, source-byte verification. All 39 tests pass, project lint passes, and changed-code formatting checks pass.