Skip to content

About

Faster local MiniMax H3 Image generation and editing on Apple Silicon with MLX, with ultra-low ram

Topics

Resources

Stars

66 stars

Watchers

2 watching

Forks

Repository files navigation

H3 Image MLX in liquid-glass lettering on a blue gradient

This banner was generated end to end with MiniMax H3 Image using H3 Image MLX.

If you find this repository useful, feel free to 🌟 & fork~

H3 Image MLX

English · 简体中文

Follow @anion_ex on X PyPI version Requires Python 3.11 or newer Package license: Apache-2.0 AND MIT

Quick start · Image editing · How it works · Benchmarks · Usage · Performance

Generate and edit images on an Apple Silicon Mac with MiniMax H3 Image. Optimized for fast inference, with 4K generation using around 7 GB of peak inference-process memory. Available through a CLI and Python API, ready to use out of the box.

Recent updates

Release Intended hardware and mode What changed Measured hardware and median time
0.1.0a9 M1–M4 on macOS earlier than 26.4, portable INT8 Tiled Metal projections speed up streamed INT8. M4 Pro, 1024×1024: 250.55 → 101.56 s (59.5% less time).
0.1.0a8 M5 family, resident W8A8 Resident inference overlaps weight loading with GPU work and uses wider W8A8 tiles. M5 Pro, 1024×1024: 26.49 → 18.93 s (28.5% less time).
0.1.0a7 M1–M4, or M5 with --backend portable; macOS 26.4+ and a successful GPU integer TensorOps check The portable backend uses INT8 TensorOps for larger matrix multiplications. M5 Pro, 1024×1024: 141.84 → 41.13 s (71.0% less time).
0.1.0a6 M1–M4 with streamed INT8, or M5 with --backend portable and streamed INT8 Streamed inference prefetches the next block while the GPU processes the current one. M5 Pro, portable backend, 512×512: 124.28 → 56.40 s (54.6% less time).

Each row compares two versions on the same machine with the same six-step sampler. Test conditions and raw data

Highlights

  • Native Apple Silicon inference. Built on MLX to take advantage of your Mac's compute capabilities, H3 Image runs locally with text-to-image generation and multi-image editing.
  • W8A8 quantization and Metal acceleration. Quantized weights reduce memory use. On M1–M4 Macs running macOS earlier than 26.4, a9 automatically uses Metal to accelerate eligible large matrix multiplications. M5 and M6 use W8A8 Metal TensorOps by default.
  • Staged inference with on-demand block loading. Each stage runs in a separate process to release its memory on completion. Denoiser weights can be read one block at a time, greatly reducing peak memory usage and leaving more room for other apps.
  • Overlap weight reads with GPU computation. Prefetch the next block while evaluating the current one, keeping streaming memory low and reducing time spent waiting for weights. Enable prefetch and async

In our 1024×1024 same-machine test, streaming with both switches matched resident-mode speed: 23.61 s vs 23.63 s, with the highest measured process peak falling from 21.18 GB to 3.23 GB — about 85% lower. Outputs matched pixel for pixel. Test conditions and results

Benchmark results

On an M4 Pro running macOS 26.3, a9 cut median 1024×1024 generation time by 59.5% in streamed INT8 mode.

Version Median generation time Median peak process footprint
0.1.0a8 250.55 s 2.44 GB
0.1.0a9 101.56 s 2.30 GB

Three runs per version, interleaved on the same machine. All six PNGs matched byte for byte. Test conditions and raw data

M5 Pro, resident INT8, 1024×1024: v0.1.0a8 reduced median generation time from 26.49 s to 18.93 s (28.5%). Median peak process footprint increased from 21.08 GB to 21.67 GB. Same-machine uncached results.

Streaming at resident speed

M5 Pro 48 GB, version 0.1.0a3, 1024×1024, identical weights, prompt and seed, original six-step sampler, no embedding cache.

Mode Median generation time Highest process peak
Resident 23.63 s 21.18 GB
Streaming 32.33 s 2.53 GB
Streaming + prefetch + async 23.61 s 3.23 GB

Resident and prefetch+async: five measured runs each; plain streaming: three. Warmups excluded. Memory is the highest kernel-recorded process physical footprint across measured runs, in decimal GB. Full results and timing ranges · Source JSON

Same-machine controlled comparison

The same M5 Pro MacBook (48 GB), weight files, teapot prompt, initial noise and six-step sigma grid. Each group has one warmup and three measured generations.

Resolution MLX DiT mode ComfyUI time (s) MLX time (s) Speed ratio ComfyUI peak (GB) MLX peak (GB)
1024×1024 resident 87.15 19.90 4.38× 31.29 21.16
1024×1024 stream 87.15 28.82 3.02× 31.29 2.53
2048×2048 resident 134.17 57.43 2.34× 38.21 22.27
2048×2048 stream 134.17 67.06 2.00× 38.21 3.48
4096×4096 stream 570.59 317.29 1.80× 42.31 7.18

Time is the median complete generation request. Memory is the kernel-recorded single-process physical-footprint peak, including warmup, in decimal GB. Speed ratio = local ComfyUI time ÷ MLX time.

This compares complete pipelines: ComfyUI's default text encoder runs on CPU; MLX uses GPU. The main table reproduces the community configuration. The additional native INT8 DiT path, pinned versions and measurement method are in the full benchmark records, with source JSON in this repository.

Supplementary community measurements

Device / memory Pipeline DiT mode Resolution Time (s) Process peak (GB) Source
M5 MacBook Air / 16 GB H3 Image MLX stream 1024×1024 70.51 2.48 arielfikru
M5 MacBook Air / 16 GB H3 Image MLX stream 2048×2048 240.78 2.78 arielfikru
M5 Pro Mac mini / 64 GB ComfyUI + MPS INT8 — 1024×1024 89.55 31.42 pratikgx
M5 Pro Mac mini / 64 GB ComfyUI + MPS INT8 — 2048×2048 164.90 36.21 pratikgx
M5 Pro Mac mini / 64 GB ComfyUI + MPS INT8 — 4096×4096 547.31 48.78 pratikgx

Independent measurements on different machines, retaining contributors' original results. Run counts and measurement methods are in the full records, alongside the earlier M5 Pro runs.

Generation gallery

Six H3 Image MLX examples: a feast, a fox in flight, a celadon tea set, a woodland chapel, a watercolor illustration and a rainy-night watchmaker.

Generated locally with H3 Image MLX: food, wildlife, product photography, architecture, illustration and a 4K watchmaker portrait. Click the collage to view it at full size.

Generate your first image

Version 0.1.0a4 also supports unquantized BF16 DiT and text-encoder weights, retaining AdaLN pruning and staged streaming. Select --precision bf16; INT8 remains the default. BF16 download and usage

Use Python 3.11 or later on a Mac with Metal. Allow 49.30 GB of disk space for a fresh model download. Check the MiniMax model license for regional and usage restrictions.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install 'h3-image-mlx==0.1.0a9'

h3-image-mlx fetch --models ./models
h3-image-mlx generate --models ./models --output teapot.png \
  --prompt 'A yellow enamel teapot and a white cup on a blue wooden table.'

This writes a 1024×1024 RGB PNG. Set --width and --height to change the size. Each dimension accepts multiples of 32 from 256 through 4096.

Recommended streaming acceleration

Use weight prefetch and asynchronous evaluation together with --dit-mode stream to reduce weight-loading waits. Streamed INT8 on the portable backend enables both by default. The W8A8 TensorOps backend uses the explicit switches below. The six-step sampler stays unchanged. Our 1024×1024 test matched resident-mode speed with about 85% less peak process memory. Same-machine results · Contributor measurements

Available from 0.1.0a2; upgrade and enable both switches for this command:

python -m pip install --upgrade 'h3-image-mlx==0.1.0a9'
H3_ASYNC=1 H3_PREFETCH=1 h3-image-mlx generate \
  --models ./models --dit-mode stream --output teapot.png \
  --prompt 'A yellow enamel teapot and a white cup on a blue wooden table.'

Usage guide: CLI, Python and existing weights · Performance guide: switches, caching and profiling

Experimental: optional two-/three-step LoRA inference and LoRA-merged INT8 checkpoints are available on GitHub main, off by default. Usage and quality trade-offs

Edit with reference images

To replace the cup in teapot.png with a bird from your own photo, save the photo as bird.png. Number the pictures in your prompt in the order you pass them on the command line.

h3-image-mlx generate --models ./models --output edit.png \
  --reference teapot.png --reference bird.png \
  --prompt 'Edit <Picture 1>. Replace the white cup with the bird from <Picture 2>. Keep the teapot and table.'

You can pass up to 16 references. On an M5 Pro, we completed one- and two-reference edits. The 16-reference test reached the third of six denoising steps before cancellation. Validation notes

How it works

The pipeline reduces memory use at three levels: between model stages, within the denoiser, and during image decoding.

H3 Image MLX pipeline: encode the prompt, stream denoiser weights, then decode overlapping image tiles. Each stage releases its model memory before the next starts.

  • Run one stage at a time. Text encoding, denoising and VAE decoding run in separate processes. Each saves its intermediate output and exits before the next loads its weights, so the three models do not need to stay in memory together. Editing adds a reference-image VAE encoding stage before denoising.
  • Keep quantized projections compact. The runtime reads Comfy-Org's INT8 ConvRot weights directly. Activations are rotated and dynamically quantized to INT8 before quantized linear projections. The portable backend uses a Metal SIMD kernel for small aligned projections and probes for direct INT8 TensorOps on macOS 26.4 or later for longer sequences. Other shapes and devices use tiled MLX operations. Other operations retain their appropriate floating-point precision.
  • Load denoiser weights as needed. In stream mode, tensors are read from safetensors as each transformer block runs, rather than cached for all six steps. Denoising still operates on the full image's latent sequence. resident mode caches weights to reduce repeated reads. The runtime also precomputes the steps' AdaLN modulation values from the compressed curves in Comfy-Org's pruned checkpoint, then releases the setup weights.
  • Decode in overlapping tiles. The VAE decodes small groups of latent tiles and blends their overlapping edges into the output image, limiting decoder working memory at high resolutions.

Streaming keeps memory low by reading weights on demand. Prefetch and asynchronous evaluation overlap these reads with GPU work to reduce the time cost. Peak usage still includes activations, attention buffers and image buffers, so resolution and reference-image count matter. See the benchmark results for the measured trade-off.

Hardware and memory

M5/M6 select W8A8 Metal TensorOps by default; M1–M4 use the portable MLX backend. Use --dit-mode stream for lower memory usage or --dit-mode resident to retain denoiser weights between steps. Hardware validation and automatic mode selection

Documentation

Document Contents
Usage guide CLI parameters, reference editing, Python API and existing weights
Performance guide Recommended streaming switches, hardware modes, embedding cache and profiling
Benchmarks Measurements, environments and source JSON
Validation notes Completed checks and remaining hardware coverage

Credits and licenses

MiniMax developed H3 Image and supplies the VAE configuration. Comfy-Org provides the quantized weights. The three W8A8 Metal kernel files come from mlx-serve and retain their MIT license. This project’s runtime code uses Apache-2.0.

About

I'm anionex, an AI-native developer who once ranked No. 3 on GitHub's global developer trending list, with more than 18.7k stars across my projects. If you would like to follow my future work, follow me on X or GitHub.

About

Faster local MiniMax H3 Image generation and editing on Apple Silicon with MLX, with ultra-low ram

Topics

Resources

Stars

66 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages