diff --git a/CHANGELOG.md b/CHANGELOG.md index ac5b0c0b2..e539fbac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,23 @@ adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). images, video and sound on `/v1/systemone` and `gmlx systemone`, and `gmlx pull` has them as `d1-2b` and `d1-omni-2b`. See [Images, video and sound](docs/decisions.md#images-video-and-sound). +- `gmlx pull`, `image generate`, `serve` and the ComfyUI pack run + MiniMax-H3-Image on a Mac with 32 GB or more, at 2048x2048 or up to 20 MP, + with edits of up to 16 pictures. See + [MiniMax-H3-Image](docs/images.md#minimax-h3-image). +- MiniMax-H3-Image rewrites prompts with MiniMax's prompt expander, which sees + an edit's pictures. See [Prompt expander](docs/images.md#prompt-expander). +- `--int8 attention`, `linears` or `all` runs MiniMax-H3-Image in int8 on an M5 + or newer. See + [Faster images with int8](docs/images.md#faster-images-with-int8). +- MiniMax-H3-Image LoRAs run in MiniMax's module names or diffusers', in gmlx + and through the gmlx ComfyUI nodes. See + [LoRA files](docs/images.md#lora-files). +- The ComfyUI pack has MiniMax-H3-Image workflows at 2048x2048 and 4096x4096, + an edit of two pictures, and pDMD-2steps in 2 steps with `gmlx PDD Heads`. +- An image LoRA such as pDMD-2steps runs on the schedule it was trained on, + and `--sigmas` or a request's `sigmas` set one. See + [Adapter schedules](docs/images.md#adapter-schedules). ### Changed @@ -80,6 +97,8 @@ adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- An image or video request served after a chat turn no longer takes tens of + GB more memory than the same request alone, nor wires all of it. - Qwen3.8-Flash-Next requests that decoded together past 2052 tokens of context attended to all of it and answered unlike a request decoding alone. - Two Qwen3.8-Flash-Next requests failed when they decoded together with the diff --git a/docs/benchmarks.json b/docs/benchmarks.json index df5a2ad60..7153a77b2 100644 --- a/docs/benchmarks.json +++ b/docs/benchmarks.json @@ -3984,6 +3984,124 @@ "speedup_image": 1.93 } ] + }, + "base-h3-image-1024": { + "model": "MiniMax-H3-Image pruned", + "steps": 6, + "size": 1024, + "rows": [ + { + "engine": "ComfyUI with ComfyUI-GGUF", + "weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "step_s": 5.06, + "image_s": 31.07, + "gmlx_weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "gmlx_step_s": 1.15, + "gmlx_image_s": 7.29, + "speedup_step": 4.4, + "speedup_image": 4.26 + }, + { + "engine": "stable-diffusion.cpp", + "weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "step_s": 2.12, + "image_s": 13.97, + "gmlx_weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "gmlx_step_s": 1.191, + "gmlx_image_s": 7.54, + "speedup_step": 1.78, + "speedup_image": 1.85 + } + ], + "gmlx_int8": [ + { + "int8": "off", + "step_s": 1.191, + "image_s": 7.54, + "speedup_step": 1.0, + "speedup_image": 1.0 + }, + { + "int8": "attention", + "step_s": 1.189, + "image_s": 7.52, + "speedup_step": 1.0, + "speedup_image": 1.0 + }, + { + "int8": "linears", + "step_s": 0.679, + "image_s": 4.51, + "speedup_step": 1.75, + "speedup_image": 1.67 + }, + { + "int8": "all", + "step_s": 0.684, + "image_s": 4.55, + "speedup_step": 1.74, + "speedup_image": 1.66 + } + ] + }, + "base-h3-image-4096": { + "model": "MiniMax-H3-Image pruned", + "steps": 6, + "size": 4096, + "rows": [ + { + "engine": "ComfyUI with ComfyUI-GGUF", + "weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "step_s": 39.213, + "image_s": 239.16, + "gmlx_weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "gmlx_step_s": 30.557, + "gmlx_image_s": 187.97, + "speedup_step": 1.28, + "speedup_image": 1.27 + }, + { + "engine": "stable-diffusion.cpp", + "weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "step_s": 91.045, + "image_s": 570.67, + "gmlx_weights": "minimax_h3_image_pruned-UD-Q4_K_XL.gguf", + "gmlx_step_s": 30.598, + "gmlx_image_s": 187.97, + "speedup_step": 2.98, + "speedup_image": 3.04 + } + ], + "gmlx_int8": [ + { + "int8": "off", + "step_s": 30.598, + "image_s": 187.97, + "speedup_step": 1.0, + "speedup_image": 1.0 + }, + { + "int8": "attention", + "step_s": 28.393, + "image_s": 174.99, + "speedup_step": 1.08, + "speedup_image": 1.07 + }, + { + "int8": "linears", + "step_s": 24.705, + "image_s": 152.87, + "speedup_step": 1.24, + "speedup_image": 1.23 + }, + { + "int8": "all", + "step_s": 22.51, + "image_s": 139.75, + "speedup_step": 1.36, + "speedup_image": 1.35 + } + ] } } } diff --git a/docs/benchmarks.md b/docs/benchmarks.md index 74426e711..add0f01ca 100644 --- a/docs/benchmarks.md +++ b/docs/benchmarks.md @@ -461,13 +461,13 @@ This comparison has its own settings in place of those under ## Image generation gmlx draws a 1024x1024 image faster than ComfyUI and -stable-diffusion.cpp for Z-Image-Turbo and both Qwen-Image 2.1 models, -faster than ComfyUI for Krea 2 Turbo, and faster than mflux for -Z-Image-Turbo, on the M5 Max listed under -[Methodology](#methodology). Each speedup is the other engine's time -divided by gmlx's, with the same GGUF file on both sides, except for -mflux, which runs its own MLX quants against the gmlx file nearest in -bits. +stable-diffusion.cpp for Z-Image-Turbo, both Qwen-Image 2.1 models and +MiniMax-H3-Image, faster than ComfyUI for Krea 2 Turbo, and faster than +mflux for Z-Image-Turbo, on the M5 Max listed under +[Methodology](#methodology). MiniMax-H3-Image is also measured at +4096x4096. Each speedup is the other engine's time divided by gmlx's, +with the same GGUF file on both sides, except for mflux, which runs its +own MLX quants against the gmlx file nearest in bits. - Each engine ran 1024x1024 images with seed 42, cfg 1, euler and the model's default steps, one engine at a time in its own process, over @@ -513,6 +513,62 @@ bits. |---|---|--:|--:|--:|--:|--:|--:| | ComfyUI with ComfyUI-GGUF | Krea-2-Turbo-Q4_K_M.gguf | 5.55 | 2.89 | 45.1 | 23.4 | 1.92x | 1.93x | +### MiniMax-H3-Image pruned, 6 steps + +MiniMax-H3-Image ran at 1024x1024 and 4096x4096 on newer engine releases +than the models above, by the same rules, with these differences: + +- ComfyUI 0.45.4 ran with ComfyUI-GGUF 373048b and torch 2.14.1 on MPS + in bf16, started with `--use-pytorch-cross-attention`, which took + less time a step than its default attention at both sizes, 17% less + at 4096x4096. It read a copy of the GGUF with one more metadata key, + the six-step schedule that ComfyUI reads from the file, with every + tensor the same. ComfyUI-GGUF loads no Qwen3-VL-32B encoder GGUF, so + ComfyUI took the prompt conditioning from gmlx, and its times cover + the DiT, the sampler and the VAE. +- stable-diffusion.cpp b9d7176b was built with Metal and run with + `--diffusion-fa` and `--vae-tiling`, with the + qwen3vl_32b_minimax_h3 Q4_K_M encoder its guide names. gmlx ran the + Qwen3-VL-32B-Instruct Q4_K_M encoder. The seconds per image of + stable-diffusion.cpp leave out its prompt encode, which it runs once + for a batch. +- At 1024x1024 each round timed two images after one or two untimed + ones. At 4096x4096 it timed one image after one untimed image, + ComfyUI's at 1024x1024. +- gmlx ran beside ComfyUI in one set of rounds and beside + stable-diffusion.cpp and its own `--int8` settings in another, so + each row gives the gmlx figures of its own rounds. +- The second table at each size gives gmlx's `--int8` settings on the + same file, each one's speedup taken over `--int8 off`. + +At 1024x1024: + +| Engine | Weights | Seconds per step | gmlx | Seconds per image | gmlx | Speedup per step | Speedup per image | +|---|---|--:|--:|--:|--:|--:|--:| +| ComfyUI with ComfyUI-GGUF | minimax_h3_image_pruned-UD-Q4_K_XL.gguf | 5.06 | 1.15 | 31.1 | 7.3 | 4.40x | 4.26x | +| stable-diffusion.cpp | minimax_h3_image_pruned-UD-Q4_K_XL.gguf | 2.12 | 1.19 | 14.0 | 7.5 | 1.78x | 1.85x | + +| gmlx setting | Seconds per step | Seconds per image | Speedup per step | Speedup per image | +|---|--:|--:|--:|--:| +| `--int8 off` | 1.19 | 7.5 | 1.00x | 1.00x | +| `--int8 attention` | 1.19 | 7.5 | 1.00x | 1.00x | +| `--int8 linears` | 0.68 | 4.5 | 1.75x | 1.67x | +| `--int8 all` | 0.68 | 4.6 | 1.74x | 1.66x | + +At 4096x4096: + +| Engine | Weights | Seconds per step | gmlx | Seconds per image | gmlx | Speedup per step | Speedup per image | +|---|---|--:|--:|--:|--:|--:|--:| +| ComfyUI with ComfyUI-GGUF | minimax_h3_image_pruned-UD-Q4_K_XL.gguf | 39.21 | 30.56 | 239.2 | 188.0 | 1.28x | 1.27x | +| stable-diffusion.cpp | minimax_h3_image_pruned-UD-Q4_K_XL.gguf | 91.05 | 30.60 | 570.7 | 188.0 | 2.98x | 3.04x | + +| gmlx setting | Seconds per step | Seconds per image | Speedup per step | Speedup per image | +|---|--:|--:|--:|--:| +| `--int8 off` | 30.60 | 188.0 | 1.00x | 1.00x | +| `--int8 attention` | 28.39 | 175.0 | 1.08x | 1.07x | +| `--int8 linears` | 24.71 | 152.9 | 1.24x | 1.23x | +| `--int8 all` | 22.51 | 139.8 | 1.36x | 1.35x | + ## Serving measurements These measurements back the performance pages' guidance. Unless a diff --git a/docs/cli.md b/docs/cli.md index 36cc7dcdf..e48ff14b7 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -765,7 +765,8 @@ The recommended models: An image model name, `z-image-turbo`, `qwen-image`, `qwen-image-turbo`, `krea-2-turbo`, `flux-2-klein`, `flux-2-klein-base`, `flux-2-klein-9b`, `flux-2-klein-base-9b`, `flux-2-klein-9b-kv`, `flux-3-klein`, -`flux-3-klein-base`, `moss-image` or `moss-image-base`, pulls its DiT, text encoder and VAE, checks the VAE +`flux-3-klein-base`, `moss-image`, `moss-image-base` or +`minimax-h3-image`, pulls its DiT, text encoder and VAE, checks the VAE against its published sha256, packs it to GGUF, and adds an `image_models` entry. The quants default to the ones for this Mac's memory, and an encoder already on disk is used @@ -773,7 +774,8 @@ again when its weights match. `gmlx pull --list` prints its quants with their downloads for this Mac and downloads nothing. On a Mac with less than 16 GB, where no image model makes an image, `pull` downloads nothing, names 16 GB, and takes a DiT only when `--quant` names -it. When the three parts do not fit the Mac's memory together, or an image +it, and so does a `minimax-h3-image` pull on a Mac with less than 32 GB, +naming 32 GB. When the three parts do not fit the Mac's memory together, or an image does not fit at all, the plan gives the peak of an image at the entry's size, as `image generate` plans it. A VAE GGUF on disk packed from the recipe's source is used again. Without one, a pack from another source serves when @@ -1354,6 +1356,7 @@ the weights load. | FLUX.3 klein | Qwen3-VL-4B-Instruct, its text GGUF | The FLUX.2 autoencoder | 16 steps and guidance 1. Base: 50 steps and guidance 3.5. | | FLUX.2 klein | Qwen3-4B | The FLUX.2 autoencoder | 4 steps and guidance 1, which is the only guidance it takes. Base: 50 steps and guidance 4. | | FLUX.2 klein 9B | Qwen3-8B | The FLUX.2 autoencoder | The same as FLUX.2 klein's. Its license allows non-commercial use only. | +| MiniMax-H3-Image | Qwen3-VL-32B-Instruct, its text GGUF | The MiniMax-H3-Image autoencoder | 6 steps at 2048x2048 and guidance 1, the only guidance it takes. Other steps need `--sigmas`. | FLUX.3 klein Base shares the distilled model's architecture, encoder and VAE, and gmlx tells the two apart by their tensors. The distilled model @@ -1403,6 +1406,19 @@ the output of a single reference is cropped back to the scaled image. FLUX.3 klein sizes its references by this rule, and `--ref-size` exits 2 on it. +`--ref` gives MiniMax-H3-Image up to 16 reference images, the first the +picture to edit, and the prompt names them as Picture 1, Picture 2 and so +on. Each reference has two copies, as ComfyUI's MiniMax H3 Image +Conditioning node makes them: the VAE's, its short side scaled into 1024 +to 2048 pixels, and the vision tower's, its short side scaled to 1024, +each side a multiple of 32, and an alpha channel is dropped. The text +encoder reads the vision copies through its vision tower, which +`--encoder-mmproj` loads (`gmlx pull minimax-h3-image` fetches it), and +the VAE encodes the VAE copies. A reference outside 1:3 to 3:1 exits 2. +Without `--size` the output has the first reference's VAE copy's size. +MiniMax-H3-Image sizes its references by this rule, and `--ref-size` +exits 2 on it. + `--ref` gives FLUX.2 klein up to 10 reference images as well, read as FLUX.3 klein reads them, with no `--encoder-mmproj`. A single reference is scaled down to at most the area of 2024x2024 pixels, and each of several @@ -1416,7 +1432,10 @@ too. `--adapter` applies a LoRA safetensors file to the DiT, live beside the quantized weights, so the file is read once and nothing is merged. The -kohya, diffusers, PEFT and OneTrainer key spellings are read. The rank and +kohya, diffusers, PEFT and OneTrainer key spellings are read. A +MiniMax-H3-Image file may name MiniMax's modules, such as +`blocks.0.attn.qkv_proj`, or diffusers' modules, such as +`transformer_blocks.0.attn.to_q`, bare or under `transformer.`. The rank and alpha in a diffusers file's PEFT header scale each pair as the diffusers loader scales it, rank-stabilized LoRA included. ComfyUI does not read that header, so such a file runs at another strength there, and gmlx warns of @@ -1427,9 +1446,18 @@ its header, before any model loads. So is a file for another model family or one that match no module of the DiT, which its GGUF header names. An adapter's text encoder pairs are applied to the text encoder at the same strength. +An adapter can bring the schedule it was trained on, from its entry in the +config, its sidecar or gmlx's table of known adapters, as +[Adapter schedules](images.md#adapter-schedules) describes. The command +then prints a line that names the adapter and what it sets. +`--sigmas`, `--steps` and `--size` win over it. Adapters that set +different values exit 2 and name the flag that chooses, as does a sidecar +that does not read or was written for another file. + A PNG holds a text chunk keyed `gmlx` with the prompt, seed, steps, size, sampler, scheduler, guidance, adapters, file names and gmlx version, unless -`--no-metadata` is set. Each adapter is recorded with its file name, its +`--no-metadata` is set, with the `sigmas` and `heads` of a schedule +other than the model's. Each adapter is recorded with its file name, its strength, the `sha256` of the file, and `rows_sha256`, a digest of the LoRA pairs gmlx applied and the layers it applied them to. Each reference is recorded with its file name, the size it ran at and the `sha256` of the @@ -1450,16 +1478,19 @@ and `crop`, the left, top, right and bottom of the image in it. | `--negative-prompt TEXT` | Empty | Guide away from this prompt, or from the empty prompt without it. It is unused when `--guidance` is 1. | | `--upsampler GGUF` | The entry's `upsampler` | Rewrite the prompt with this chat model, a GGUF or a `models` id, as [Prompt upsampling](images.md#prompt-upsampling) describes. | | `--no-upsample` | Off | Run the prompt as typed, without the upsampler. | -| `--upsample-prompt FILE` | The entry's `upsample_prompt` | The upsampler takes the system prompt in this text file in place of the family's. Qwen-Image 2.1 ships none and needs one. | -| `--size WxH` | The init image's, else a FLUX.2 klein or FLUX.3 klein reference's, else the entry's `defaults.size`, else the variant's | Set the width and height, each a multiple of 32 on Qwen-Image 2.1 and of 16 on the others. Another size exits 2 and names the multiple. | -| `--steps N` | The variant's | Sample for N steps. | +| `--upsample-prompt FILE` | The entry's `upsample_prompt` | Take the upsampler's system prompt from this file. Qwen-Image 2.1 ships none and needs one; MiniMax-H3-Image reads MiniMax's `prompt/manifest.json`. | +| `--upsampler-mmproj GGUF` | The `mmproj` of the upsampler's `models` entry | Read the `--ref` images with this vision tower of `--upsampler`. MiniMax-H3-Image's upsampler sees the references, and needs it with `--ref`. | +| `--size WxH` | The init image's, else the first `--ref`'s, as above, else `defaults.size`, else a LoRA's [schedule](images.md#adapter-schedules), else the variant's | Set the width and height, each a multiple of 32 on Qwen-Image 2.1 and MiniMax-H3-Image and of 16 on the others. Another size exits 2 and names the multiple. | +| `--steps N` | The variant's | Sample for N steps on the variant's schedule, in place of an adapter's. | +| `--sigmas LIST` | An adapter's [schedule](images.md#adapter-schedules), else the variant's | Sample on these noise levels, such as `1,12/13,0`, one step between each two. On MiniMax-H3-Image step i reads step head i. | +| `--save-adapter-schedule` | Off | Write `--sigmas` and `--size` to the sidecar of the one `--adapter` file, `.gmlx.json`, then generate. Exits 2 when the folder is not writable. | | `--seed N` | Random, and printed | Seed the first image. | | `--guidance CFG` | The variant's | Set classifier-free guidance. 1 turns it off. | | `--sampler NAME` | `euler` | Sample with `euler` or `uni_pc_bh2`. | | `--init-image PATH` | None | Start from this image, resized to `--size` (img2img). | | `--mask PATH` | None | Change only where this mask is white (inpainting). It needs `--init-image`. | | `--strength F` | `0.6`, or `1` with `--mask` | Set how far img2img moves from the init image, from 0.01 to 1. | -| `--ref PATH` | None | Edit from this reference image, on Qwen-Image 2.1, FLUX.2 klein and FLUX.3 klein. Repeat the flag for up to 10 images, in the order the prompt names them. | +| `--ref PATH` | None | Edit from this reference image, on Qwen-Image 2.1, FLUX.2 klein, FLUX.3 klein and MiniMax-H3-Image. Repeat it for each image, in the prompt's order. | | `--ref-size N` | `1024` | On Qwen-Image 2.1, resize each reference to about N x N pixels at its own aspect ratio, from 256 to 1024. It needs `--ref`. | | `--count N` | `1` | Generate N images. | | `--output PATH` | `./gmlx-