h3-image-mlx 0.1.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. h3_image_mlx-0.1.0a1/LICENSE +202 -0
  2. h3_image_mlx-0.1.0a1/PKG-INFO +86 -0
  3. h3_image_mlx-0.1.0a1/README.md +64 -0
  4. h3_image_mlx-0.1.0a1/pyproject.toml +32 -0
  5. h3_image_mlx-0.1.0a1/setup.cfg +4 -0
  6. h3_image_mlx-0.1.0a1/src/h3_image_mlx/MODEL_LICENSE.txt +84 -0
  7. h3_image_mlx-0.1.0a1/src/h3_image_mlx/NOTICE.txt +7 -0
  8. h3_image_mlx-0.1.0a1/src/h3_image_mlx/__init__.py +4 -0
  9. h3_image_mlx-0.1.0a1/src/h3_image_mlx/__main__.py +3 -0
  10. h3_image_mlx-0.1.0a1/src/h3_image_mlx/_portable.py +41 -0
  11. h3_image_mlx-0.1.0a1/src/h3_image_mlx/_stage.py +64 -0
  12. h3_image_mlx-0.1.0a1/src/h3_image_mlx/cli.py +56 -0
  13. h3_image_mlx-0.1.0a1/src/h3_image_mlx/core.py +148 -0
  14. h3_image_mlx-0.1.0a1/src/h3_image_mlx/dit.py +185 -0
  15. h3_image_mlx-0.1.0a1/src/h3_image_mlx/download.py +63 -0
  16. h3_image_mlx-0.1.0a1/src/h3_image_mlx/kernels/LICENSE +31 -0
  17. h3_image_mlx-0.1.0a1/src/h3_image_mlx/kernels/mpp_tensor_ops.metal +3 -0
  18. h3_image_mlx-0.1.0a1/src/h3_image_mlx/kernels/w8a8_epi_plain.metal +17 -0
  19. h3_image_mlx-0.1.0a1/src/h3_image_mlx/kernels/w8a8_gemm_body.metal +18 -0
  20. h3_image_mlx-0.1.0a1/src/h3_image_mlx/models.py +25 -0
  21. h3_image_mlx-0.1.0a1/src/h3_image_mlx/pipeline.py +47 -0
  22. h3_image_mlx-0.1.0a1/src/h3_image_mlx/ref_vae.py +107 -0
  23. h3_image_mlx-0.1.0a1/src/h3_image_mlx/text.py +49 -0
  24. h3_image_mlx-0.1.0a1/src/h3_image_mlx/vae.py +112 -0
  25. h3_image_mlx-0.1.0a1/src/h3_image_mlx/vision.py +141 -0
  26. h3_image_mlx-0.1.0a1/src/h3_image_mlx/weights.json +43 -0
  27. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/PKG-INFO +86 -0
  28. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/SOURCES.txt +32 -0
  29. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/dependency_links.txt +1 -0
  30. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/entry_points.txt +2 -0
  31. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/requires.txt +5 -0
  32. h3_image_mlx-0.1.0a1/src/h3_image_mlx.egg-info/top_level.txt +1 -0
  33. h3_image_mlx-0.1.0a1/tests/test_distribution.py +86 -0
  34. h3_image_mlx-0.1.0a1/tests/test_portable.py +102 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: h3-image-mlx
3
+ Version: 0.1.0a1
4
+ Summary: Local MiniMax H3 Image generation and editing with MLX on Apple Silicon
5
+ License-Expression: Apache-2.0 AND MIT
6
+ Project-URL: Source, https://github.com/Anionex/h3-image-mlx
7
+ Project-URL: Issues, https://github.com/Anionex/h3-image-mlx/issues
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Operating System :: MacOS :: MacOS X
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ License-File: src/h3_image_mlx/kernels/LICENSE
16
+ Requires-Dist: mlx<0.33,>=0.32.3
17
+ Requires-Dist: numpy>=1.26
18
+ Requires-Dist: Pillow>=10
19
+ Requires-Dist: tokenizers<0.24,>=0.21
20
+ Requires-Dist: httpx<1,>=0.27
21
+ Dynamic: license-file
22
+
23
+ # H3 Image MLX
24
+
25
+ Generate and edit images locally with MiniMax H3 Image and the Comfy-Org INT8 ConvRot weights. The runtime accepts ordered reference files and runs the text encoder, optional reference VAE, six-step DiT and image decoder in separate processes.
26
+
27
+ ## Install
28
+
29
+ Use Python 3.11+ on an Apple Silicon Mac with Metal. In a fresh environment, install the alpha release:
30
+
31
+ ```bash
32
+ uv venv --python 3.13
33
+ uv pip install 'h3-image-mlx==0.1.0a1'
34
+ source .venv/bin/activate
35
+ ```
36
+
37
+ ## Model files
38
+
39
+ Supply a directory containing these five files. Their source revisions, sizes and SHA-256 digests are pinned in the package's `weights.json`. You can reuse an existing model directory or link to its files. A fresh download needs 49.30 GB of disk space. The runtime loads all weights locally. Review the [MiniMax model license](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/main/LICENSE) for its territorial, use and distribution terms before fetching or using the model.
40
+
41
+ ```text
42
+ diffusion_models/minimax_h3_image_pruned_int8_convrot.safetensors
43
+ text_encoders/qwen3vl_32b_minimax_h3_int8_convrot.safetensors
44
+ vae/minimax_h3_image_vae_fp16.safetensors
45
+ vae/config.json
46
+ tokenizer.json
47
+ ```
48
+
49
+ ```bash
50
+ h3-image-mlx verify --models ./models
51
+ # To fetch the five files into an empty directory, select a source:
52
+ h3-image-mlx fetch --models ./models --source modelscope
53
+ # --source huggingface selects the pinned Hugging Face files instead.
54
+ ```
55
+
56
+ ## Generate and edit
57
+
58
+ ```bash
59
+ h3-image-mlx generate --models ./models --prompt 'A yellow enamel teapot on a blue wooden table' --output teapot.png
60
+ h3-image-mlx generate --models ./models --reference teapot.png --reference bird.png \
61
+ --prompt 'Edit <Picture 1>. Replace the cup with the bird from <Picture 2>.' --output edit.png
62
+ ```
63
+
64
+ ```python
65
+ from h3_image_mlx import generate
66
+
67
+ im = generate("A red fox in fresh snow", models="./models", width=1024, height=1024,
68
+ seed=42, dit_mode="stream")
69
+ im.save("fox.png")
70
+ ```
71
+
72
+ Images are RGB. Use multiples of 32 from 256 to 4096 for each dimension. Pass up to 16 references in order using repeated `--reference` or the `references` argument. The original desktop pipeline completed single- and two-reference edits on the M5 Pro; its 16-reference run reached denoising step three before cancellation.
73
+
74
+ ## Hardware and memory
75
+
76
+ `--backend auto` selects the W8A8 TensorOps kernel on M5/M6 and the experimental portable path on earlier Apple GPUs. M5 Pro 48 GB is the physically tested hardware. M1–M4 and M6 need on-device validation. Explicit choices are `w8a8` and `portable`.
77
+
78
+ `--dit-mode stream` reads DiT weights one layer at a time; `resident` keeps them between denoising steps. The default `auto` streams when using the portable backend, on machines with less than 32 GiB, or above 8192 packed sequence rows. This selection heuristic does not establish minimum supported machine memory.
79
+
80
+ Existing installations with the four weight and tokenizer files can run `fetch` once to verify them and add the 1,826-byte VAE configuration.
81
+
82
+ ## Attribution
83
+
84
+ This project’s own runtime code is licensed under Apache-2.0. The model and third-party kernels retain their respective licenses.
85
+
86
+ MiniMax developed [H3 Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image). [Comfy-Org](https://huggingface.co/Comfy-Org/MiniMax-H3-Image) provides the pinned quantized weights. The VAE configuration downloads separately from the official [VAE config](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/492fd8c4eca666f1085f57e30738c1e0d86b3439/vae/config.json). The upstream model agreement and attribution are included in the package. The three W8A8 Metal source files come from [mlx-serve](https://github.com/ddalcu/mlx-serve/tree/9191fbdf697df333cac19ec7a93eaa1098ce3ad5/src/kernels) with their MIT license.
@@ -0,0 +1,64 @@
1
+ # H3 Image MLX
2
+
3
+ Generate and edit images locally with MiniMax H3 Image and the Comfy-Org INT8 ConvRot weights. The runtime accepts ordered reference files and runs the text encoder, optional reference VAE, six-step DiT and image decoder in separate processes.
4
+
5
+ ## Install
6
+
7
+ Use Python 3.11+ on an Apple Silicon Mac with Metal. In a fresh environment, install the alpha release:
8
+
9
+ ```bash
10
+ uv venv --python 3.13
11
+ uv pip install 'h3-image-mlx==0.1.0a1'
12
+ source .venv/bin/activate
13
+ ```
14
+
15
+ ## Model files
16
+
17
+ Supply a directory containing these five files. Their source revisions, sizes and SHA-256 digests are pinned in the package's `weights.json`. You can reuse an existing model directory or link to its files. A fresh download needs 49.30 GB of disk space. The runtime loads all weights locally. Review the [MiniMax model license](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/main/LICENSE) for its territorial, use and distribution terms before fetching or using the model.
18
+
19
+ ```text
20
+ diffusion_models/minimax_h3_image_pruned_int8_convrot.safetensors
21
+ text_encoders/qwen3vl_32b_minimax_h3_int8_convrot.safetensors
22
+ vae/minimax_h3_image_vae_fp16.safetensors
23
+ vae/config.json
24
+ tokenizer.json
25
+ ```
26
+
27
+ ```bash
28
+ h3-image-mlx verify --models ./models
29
+ # To fetch the five files into an empty directory, select a source:
30
+ h3-image-mlx fetch --models ./models --source modelscope
31
+ # --source huggingface selects the pinned Hugging Face files instead.
32
+ ```
33
+
34
+ ## Generate and edit
35
+
36
+ ```bash
37
+ h3-image-mlx generate --models ./models --prompt 'A yellow enamel teapot on a blue wooden table' --output teapot.png
38
+ h3-image-mlx generate --models ./models --reference teapot.png --reference bird.png \
39
+ --prompt 'Edit <Picture 1>. Replace the cup with the bird from <Picture 2>.' --output edit.png
40
+ ```
41
+
42
+ ```python
43
+ from h3_image_mlx import generate
44
+
45
+ im = generate("A red fox in fresh snow", models="./models", width=1024, height=1024,
46
+ seed=42, dit_mode="stream")
47
+ im.save("fox.png")
48
+ ```
49
+
50
+ Images are RGB. Use multiples of 32 from 256 to 4096 for each dimension. Pass up to 16 references in order using repeated `--reference` or the `references` argument. The original desktop pipeline completed single- and two-reference edits on the M5 Pro; its 16-reference run reached denoising step three before cancellation.
51
+
52
+ ## Hardware and memory
53
+
54
+ `--backend auto` selects the W8A8 TensorOps kernel on M5/M6 and the experimental portable path on earlier Apple GPUs. M5 Pro 48 GB is the physically tested hardware. M1–M4 and M6 need on-device validation. Explicit choices are `w8a8` and `portable`.
55
+
56
+ `--dit-mode stream` reads DiT weights one layer at a time; `resident` keeps them between denoising steps. The default `auto` streams when using the portable backend, on machines with less than 32 GiB, or above 8192 packed sequence rows. This selection heuristic does not establish minimum supported machine memory.
57
+
58
+ Existing installations with the four weight and tokenizer files can run `fetch` once to verify them and add the 1,826-byte VAE configuration.
59
+
60
+ ## Attribution
61
+
62
+ This project’s own runtime code is licensed under Apache-2.0. The model and third-party kernels retain their respective licenses.
63
+
64
+ MiniMax developed [H3 Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image). [Comfy-Org](https://huggingface.co/Comfy-Org/MiniMax-H3-Image) provides the pinned quantized weights. The VAE configuration downloads separately from the official [VAE config](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/492fd8c4eca666f1085f57e30738c1e0d86b3439/vae/config.json). The upstream model agreement and attribution are included in the package. The three W8A8 Metal source files come from [mlx-serve](https://github.com/ddalcu/mlx-serve/tree/9191fbdf697df333cac19ec7a93eaa1098ce3ad5/src/kernels) with their MIT license.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "h3-image-mlx"
7
+ version = "0.1.0a1"
8
+ description = "Local MiniMax H3 Image generation and editing with MLX on Apple Silicon"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "Apache-2.0 AND MIT"
12
+ license-files = ["LICENSE", "src/h3_image_mlx/kernels/LICENSE"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Operating System :: MacOS :: MacOS X",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
18
+ ]
19
+ dependencies = ["mlx>=0.32.3,<0.33", "numpy>=1.26", "Pillow>=10", "tokenizers>=0.21,<0.24", "httpx>=0.27,<1"]
20
+
21
+ [project.urls]
22
+ Source = "https://github.com/Anionex/h3-image-mlx"
23
+ Issues = "https://github.com/Anionex/h3-image-mlx/issues"
24
+
25
+ [project.scripts]
26
+ h3-image-mlx = "h3_image_mlx.cli:main"
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [tool.setuptools.package-data]
32
+ h3_image_mlx = ["kernels/*.metal", "kernels/LICENSE", "weights.json", "MODEL_LICENSE.txt", "NOTICE.txt"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,84 @@
1
+ MiniMax-H3-Image COMMUNITY LICENSE AGREEMENT
2
+ MiniMax-H3-Image release date/License date: November 10, 2026.
3
+ The scope of this License Agreement (this “Agreement”) is expressly limited to the “Applicable Territory” as defined below.
4
+ By clicking to accept, or by using, reproducing, modifying, distributing, running, or displaying any portion or element of the MiniMax-H3-Image Works (including through any Hosted Service) in any manner, you acknowledge and accept the terms of this Agreement, and this Agreement shall take immediate effect upon the occurrence of such act.
5
+ I. Definitions
6
+ 1. “Acceptable Use Policy” means the policy published by MiniMax in Exhibit A.
7
+ 2. “Agreement” means the terms and conditions set forth herein that govern the use, reproduction, distribution, modification, running, and display of the MiniMax-H3-Image Works or any portion or element thereof.
8
+ 3. “Applicable Territory” means worldwide, excluding the Excluded Territories.
9
+ 4. “Documentation” means the specifications, manuals, and documentation concerning MiniMax-H3-Image that are publicly released by MiniMax.
10
+ 5. “Excluded Territories” means the European Union, the United Kingdom, the Republic of Korea and the United States of America.
11
+ 6. “MiniMax-H3-Image” means the image generation model, together with its software and algorithms, including trained model weights, parameters (including optimizer states), prompt-enhancement models, inference-supporting code, and other elements thereof made publicly available by Us, as released at https://huggingface.co/MiniMaxAI/MiniMax-H3-Image.
12
+ 7. “MiniMax-H3-Image Works” means (i) the Materials, (ii) the Model Derivatives, and (iii) all derivatives thereof.
13
+ 8. “Hosted Service” means a service through which MiniMax-H3-Image or its Model Derivatives is hosted or operated and its functionality is made available to Third Parties, including via application programming interfaces (APIs), web access, or any other electronic or remote means.
14
+ 9. “Licensee,” “you,” or “your” means the natural or legal person exercising rights and/or using the MiniMax-H3-Image Works for any purpose in any field of use under this Agreement.
15
+ 10. “Materials” means, collectively, MiniMax-H3-Image and the Documentation (and any portion thereof), in each case as made available by MiniMax under this Agreement and proprietary to MiniMax.
16
+ 11. “Model Derivatives” means all of the following: (i) any modification of MiniMax-H3-Image or any Model Derivative thereof; (ii) any work based on MiniMax-H3-Image or any Model Derivative thereof; or (iii) any other machine learning model created by transferring the patterns of the weights, parameters, operational patterns, or Outputs of MiniMax-H3-Image or any Model Derivative thereof to another model, such that the latter model exhibits behavior similar to MiniMax-H3-Image or its Model Derivatives, including by distillation methods, methods using intermediate data representations, or methods based on training using synthetic-data Outputs generated by MiniMax-H3-Image or its Model Derivatives. For the avoidance of doubt, Outputs are not deemed Model Derivatives.
17
+ 12. “Output” means any result of operating or otherwise using MiniMax-H3-Image or any Model Derivatives (including through Hosted Service).
18
+ 13. “Third Party” means any natural or legal person that is not under common control with us or with you.
19
+ 14. “Including” means “including but not limited to.”
20
+ 15. “We,” “Us” or “MiniMax” means Nanonoble Pte. Ltd..
21
+ II. Grant of Rights
22
+ Solely within the Applicable Territory, we grant you a non-exclusive, non-transferable, royalty-free, limited license to use, reproduce, distribute, create derivative works (including Model Derivatives), and modify the Materials in accordance with the terms of this Agreement and the Acceptable Use Policy, based on the intellectual property and other rights owned by MiniMax that are embodied in or used by the Materials. You shall not violate (or encourage or permit any person to violate) any term of this Agreement or the Acceptable Use Policy.
23
+ We will continuously evaluate the applicable laws, regulations and compliance requirements for the Excluded Territories. In the meantime, should any person in such Excluded Territories be interested in deploying our models, you are welcome to contact us about obtaining a license, which will be granted based on robust controls and guardrails for purposes of complying with the laws, regulations and compliance requirements of the Excluded Territories.
24
+ III. Distribution and Redistribution
25
+ Subject to and conditioned on your continuing compliance with this Agreement, including its territorial restrictions and the Acceptable Use Policy, and solely within the Applicable Territory, you may distribute or make available the MiniMax-H3-Image Works to Third Parties within the Applicable Territory; provided, that all of the following conditions are met:
26
+ 1. You must provide a copy of this Agreement to all such Third Parties who receive the MiniMax-H3-Image Works or use your products or services related thereto;
27
+ 2. You must cause any modified files to carry prominent notices stating that you have modified such files;
28
+ 3. You are encouraged to:
29
+ a. display a notice on any product or service developed using MiniMax-H3-Image indicating that the product or service is “Powered by MiniMax-H3-Image”;
30
+ b. add an AI-generation identifier to files produced using generative AI models including MiniMax-H3-Image; and
31
+ c. publish at least one technical blog post or a public statement describing your experience using MiniMax-H3-Image Works;
32
+ 4. All distributions to Third Parties (other than through Hosted Service) must be accompanied by a “NOTICE” text file containing the following notice:
33
+ “MiniMax-H3-Image is licensed under the MiniMax-H3-Image Community License Agreement, Copyright © 2026 MiniMax. All Rights Reserved.”
34
+ You may add your own copyright notices on your modifications; except as provided in this Section and in Section V, however, you may not impose additional or different terms and conditions on the use, reproduction, or distribution of your modifications or of any aggregate Model Derivatives, and your use, reproduction, modification, distribution, running, and display of the work must otherwise comply with the terms and conditions of this Agreement (including the provisions concerning the Applicable Territory). If you receive the MiniMax-H3-Image Works from a Licensee as part of an integrated end-user product, the provisions of Section III of this Agreement do not apply to you, but Section V and Exhibit A remain applicable.
35
+ IV. Additional Commercial Terms
36
+ 1. You shall obtain a separate, prior written authorization from MiniMax by sending a request through https://platform.minimax.io/license, if the Annualized Revenue of you and/or your affiliates exceeds 1 Million USD, or, you provide Hosted Service(s) to any Third Parties.
37
+ 2. You shall prominently display “MiniMax-H3-Image”on the user interface of commercial product or service that uses MiniMax-H3-Image or MiniMax-H3-Image Works.
38
+ V. Use Restrictions
39
+ 1. Your use of the MiniMax-H3-Image Works must comply with applicable laws and regulations (including trade-compliance laws and regulations) and must comply with the Acceptable Use Policy for the MiniMax-H3-Image Works, which is incorporated into this Agreement by reference.
40
+ 2. Before providing access to the MiniMax-H3-Image Works or any product, service, or Hosted Service incorporating them, you must bind each recipient or user to enforceable terms at least as protective as the use restrictions in this Section V and Exhibit A, and you must notify each recipient or user that those restrictions apply.
41
+ 3. You may not use the MiniMax-H3-Image Works or any of their Outputs or results to improve any other artificial intelligence model (other than MiniMax-H3-Image or its Model Derivatives).
42
+ 4. You may not use, reproduce, modify, distribute, or display the MiniMax-H3-Image Works or any of their Outputs or results outside the Applicable Territory. Any such use outside the Applicable Territory is not authorized by this Agreement.
43
+ 5. If you provide or make available to any Third Party a product, service, or Hosted Service that permits the generation of Outputs using MiniMax-H3-Image or any Model Derivative, you must, before making that product or service available and throughout its operation, implement, maintain, test, and periodically review reasonable and proportionate technical and organizational safeguards designed to prevent and mitigate access, uses, and Outputs that violate this Section V or Exhibit A, including uses or Outputs that infringe, misappropriate, or otherwise violate any Third Party’s intellectual-property or other rights. You must not knowingly disable, materially weaken, or permit the circumvention of those safeguards. You must maintain a reasonably accessible mechanism for reporting suspected violations. Upon receiving a good-faith report or otherwise obtaining actual knowledge of a violation, you must promptly investigate and take reasonable steps within your control to stop or mitigate the violation, including removing or disabling access to offending content or services and suspending or terminating repeat violators where appropriate. You are responsible for implementing and enforcing these requirements with respect to your products, services, systems, users, and downstream recipients.
44
+ VI. Intellectual Property
45
+ 1. Subject to MiniMax’s rights in the MiniMax-H3-Image Works (and the intellectual property therein), and to your compliance with the terms and conditions of this Agreement, as between you and MiniMax, you will own the derivative works and modifications of the Materials that you have created or had created, as well as any Model Derivatives.
46
+ 2. Except for the limited license expressly granted in this paragraph, no trademark license is granted under this Agreement; with respect to MiniMax-H3-Image Works, the Licensee may not use any name or mark owned by or associated with MiniMax or any of its affiliates, except as reasonably and customarily necessary to describe and distribute the MiniMax-H3-Image Works. MiniMax hereby grants you a license to use the “MiniMax-H3-Image” mark (the “Mark”) within the Applicable Territory solely for the purpose of complying with Section III.3; provided, that you comply with all applicable trademark-protection laws. All goodwill arising from your use of the Mark shall inure to the benefit of MiniMax.
47
+ 3. If you bring or assert any suit or other legal proceeding (including a cross-claim or counterclaim in any action) against us or any other natural or legal person alleging that the Materials, any Output, or any portion of the foregoing infringes any intellectual property right or other right owned by you or for which you can obtain a license, all licenses granted to you under this Agreement will terminate as of the date such suit or proceeding is filed. You shall defend, indemnify, and hold us harmless against any Third-Party claim arising out of or related to the use or distribution of the MiniMax-H3-Image Works by you or by any Third Party.
48
+ 4. MiniMax claims no rights over the Outputs you generate. You and your users are entirely responsible for the Outputs and any subsequent use thereof.
49
+ VII. Disclaimers and Limitations of Liability
50
+ 1. We have no obligation to support, update, provide training for, or develop any further version of the MiniMax-H3-Image Works, or to grant any license with respect thereto.
51
+ 2. UNLESS AND ONLY TO THE EXTENT REQUIRED BY APPLICABLE LAW, THE MiniMax-H3-Image WORKS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND INCLUDING ANY WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, COURSE OF DEALING, USAGE OF TRADE, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE MiniMax-H3-Image WORKS OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR OR A THIRD PARTY’S USE OR DISTRIBUTION OF ANY OF THE MiniMax-H3-Image WORKS OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.
52
+ 3. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL MINIMAX OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, FOR ANY DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO ANY OF THE MiniMax-H3-Image WORKS OR OUTPUTS, EVEN IF MINIMAX OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
53
+ VIII. Term and Termination
54
+ 1. This Agreement is effective from the moment you accept this Agreement or begin accessing the Materials, and, subject to your compliance with its terms and conditions, will remain in effect until terminated as provided herein.
55
+ 2. If you breach any term or condition of this Agreement, we have the right to terminate this Agreement. Upon termination, you must immediately cease accessing, using, and distributing the MiniMax-H3-Image Works; delete or destroy all copies within your possession or control; and notify each downstream recipient that your authorization has ended. The obligations in the preceding sentence and Sections VI.1, VI.3, VII, and IX survive termination.
56
+ IX. Governing Law and Jurisdiction
57
+ 1. This Agreement, and any dispute arising out of or related to this Agreement, shall be governed by the laws of the Hong Kong Special Administrative Region of the People’s Republic of China, without regard to its conflict-of-laws rules. The United Nations Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
58
+ 2. Any dispute arising out of or related to this Agreement shall be subject to the exclusive jurisdiction of the courts of the Hong Kong Special Administrative Region of the People’s Republic of China with competent jurisdiction. Both MiniMax and the Licensee hereby consent to the exclusive jurisdiction of such courts for any such dispute.
59
+ Additional Note: Please note that the text-to-image prompt enhancer model (https://huggingface.co/MiniMaxAI/MiniMax-H3-Image-PE, "T2I PE Model") of MiniMax-H3-Image is derived from Qwen3.8-27B licensed under Apache 2.0 License: https://huggingface.co/Qwen/Qwen3.8-27B. The T2I PE Model is part of MiniMax-H3-Image and is accordingly subject to this Agreement for the avoidance of doubt.
60
+
61
+ Exhibit A — Acceptable Use Policy
62
+ MiniMax reserves the right to update this Acceptable Use Policy from time to time.
63
+ Last revised: November 10, 2026.
64
+ MiniMax is committed to promoting the safe and fair use of its tools and features, including MiniMax-H3-Image. You agree not to use MiniMax-H3-Image, any Model Derivatives, or any Output in any of the following ways:
65
+ 1. Use outside the Applicable Territory;
66
+ 2. Use in any manner that violates any applicable national, federal, state, local, or international law, regulation, or other legal requirement, or that infringes, misappropriates, or otherwise violates any Third Party’s intellectual-property or other proprietary rights, including through unauthorized reproduction, distribution, public display, public performance, or creation of derivative works;
67
+ 3. Use in any manner that may harm yourself or others;
68
+ 4. Use to repurpose or distribute the Outputs of MiniMax-H3-Image or any Model Derivatives in order to harm yourself or others;
69
+ 5. Use to circumvent or bypass any safety guardrails or safeguards we have implemented;
70
+ 6. Use in any manner that exploits or harms, or intends to exploit or harm, minors;
71
+ 7. Use to generate or disseminate verifiably false information and/or content for the purpose of harming others or influencing elections;
72
+ 8. Use to manufacture or facilitate false online engagement, including fake reviews and other means of false online engagement;
73
+ 9. Use to intentionally defame, disparage, or otherwise harass others;
74
+ 10. Use to generate and/or disseminate malware (including ransomware) or any other content intended to damage electronic systems;
75
+ 11. Use to generate or disseminate personally identifiable information for the purpose of harming others;
76
+ 12. Use to generate or disseminate information (including images, code, posts, or articles) in or to any public environment (including via bot tweets or similar means) without clearly and prominently disclosing that such information and/or content is machine-generated;
77
+ 13. Use to impersonate another person without that person’s consent, authorization, or lawful right to do so;
78
+ 14. Use to make high-risk automated decisions in critical domains that affect individual safety, rights, or well-being (such as law enforcement, immigration, healthcare or medical services, critical-infrastructure management, product-safety components, essential services, credit, employment, housing, education, social scoring, or insurance);
79
+ 15. Use in any manner that violates or disregards the social, ethical, or moral standards of other countries or regions;
80
+ 16. Use to carry out, assist, threaten, incite, plan, advocate for, or encourage violent extremism or terrorism;
81
+ 17. Use for any purpose intended to discriminate against, or harm, individuals or groups based on protected characteristics or categories, online or offline social behavior, or known or predicted personality traits;
82
+ 18. Use to intentionally exploit the vulnerabilities of specific populations based on age, social, physical, or psychological characteristics, so as to materially distort the behavior of a member of that group in a manner that causes, or is likely to cause, physical or psychological harm to that person or to others;
83
+ 19. Use for military purposes;
84
+ 20. Use to engage in any unauthorized or unlicensed professional activity, including but not limited to financial, legal, medical or healthcare, or other professional practice.
@@ -0,0 +1,7 @@
1
+ MiniMax-H3-Image is licensed under the MiniMax-H3-Image Community License Agreement, Copyright © 2026 MiniMax. All Rights Reserved.
2
+ Weights: MiniMaxAI/MiniMax-H3-Image, repackaged and quantized by Comfy-Org.
3
+ See MODEL_LICENSE.txt for the upstream model license. Model weights and the VAE configuration are downloaded separately.
4
+ The implementation authored for this project is licensed under Apache-2.0.
5
+ This implementation adapts H3 Image inference to Apple MLX, including staged memory management and ConvRot projections.
6
+ The three Metal kernel source files are from ddalcu/mlx-serve commit 9191fbdf697df333cac19ec7a93eaa1098ce3ad5.
7
+ Their copyright and MIT license are in kernels/LICENSE.
@@ -0,0 +1,4 @@
1
+ """Local H3 Image inference on Apple Silicon."""
2
+ from .pipeline import generate
3
+
4
+ __all__ = ["generate"]
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,41 @@
1
+ """Evaluate H3's quantized projections with standard MLX operations."""
2
+
3
+ import mlx.core as mx
4
+
5
+ # An int8 dot product of length 1024 has an absolute sum <= 2**24, so its
6
+ # integer partial sums are exactly representable in float32. H3's longest
7
+ # projection has K=25600, safely within int32 for the combined sum.
8
+ _DOT_CHUNK = 1024
9
+ _TILE = 1024
10
+
11
+
12
+ def portable_matmul(xq, weight, xs, scale, output_dtype):
13
+ """Compute row-scaled int8 dot products without the M5 Metal TensorOps kernel."""
14
+ rows, width = xq.shape
15
+ channels = weight.shape[0]
16
+ row_scale = xs.reshape(rows, 1).astype(mx.float32)
17
+ channel_scale = mx.broadcast_to(scale.reshape(-1), (channels,)).astype(mx.float32)
18
+
19
+ row_tiles = []
20
+ for r in range(0, rows, _TILE):
21
+ columns = []
22
+ row_slice = slice(r, r + _TILE)
23
+ for c in range(0, channels, _TILE):
24
+ col_slice = slice(c, c + _TILE)
25
+ total = None
26
+ for k in range(0, width, _DOT_CHUNK):
27
+ inner = slice(k, k + _DOT_CHUNK)
28
+ a = xq[row_slice, inner].astype(mx.float32)
29
+ b = weight[col_slice, inner].astype(mx.float32)
30
+ partial = (a @ b.T).astype(mx.int32)
31
+ total = partial if total is None else total + partial
32
+ # Evaluate before advancing to the next tile: no dense floating
33
+ # point copy of an entire large weight is retained across tiles.
34
+ y = total.astype(mx.float32) * row_scale[row_slice] * channel_scale[col_slice]
35
+ y = y.astype(output_dtype)
36
+ mx.eval(y)
37
+ columns.append(y)
38
+ row = mx.concatenate(columns, axis=1) if len(columns) > 1 else columns[0]
39
+ mx.eval(row)
40
+ row_tiles.append(row)
41
+ return mx.concatenate(row_tiles, axis=0) if len(row_tiles) > 1 else row_tiles[0]
@@ -0,0 +1,64 @@
1
+ """Private stage entry point. Each child releases its weights on exit."""
2
+ import json
3
+ import re
4
+ import sys
5
+ from pathlib import Path
6
+ from .models import DIT, TEXT, TOKENIZER, VAE, VAE_CONFIG
7
+
8
+
9
+ def select_backend(requested, device):
10
+ native = bool(re.search(r"\bApple M[56]\b", device))
11
+ if requested == "auto":
12
+ return "w8a8" if native else "portable"
13
+ if requested == "w8a8" and not native:
14
+ raise ValueError(f"The W8A8 TensorOps kernel requires an M5/M6 GPU; found {device}")
15
+ return requested
16
+
17
+
18
+ def main(stage, work):
19
+ import mlx.core as mx
20
+ from . import core
21
+ request = json.loads((work / "request.json").read_text())
22
+ info = mx.device_info()
23
+ backend = select_backend(request["backend"], info["device_name"])
24
+ core.backend.set(backend)
25
+ mx.set_cache_limit(96 << 20)
26
+ models = Path(request["models"])
27
+ refs = request["references"]
28
+ embedding, latents, result = (str(work / (key + ".safetensors")) for key in ("embedding", "references", "latent"))
29
+ if stage == "text":
30
+ from .text import encode
31
+ x, tags, _ = encode(models / TEXT, models / TOKENIZER, request["prompt"], refs)
32
+ mx.save_safetensors(embedding, {"embedding": x, "tags": tags})
33
+ elif stage == "references":
34
+ from .ref_vae import encode_reference
35
+ weights = core.Weights(models / VAE, True)
36
+ stats = json.loads((models / VAE_CONFIG).read_text())
37
+ zs = {}
38
+ for i, ref in enumerate(refs):
39
+ zs[str(i)] = encode_reference(weights, ref, stats)
40
+ mx.eval(zs[str(i)])
41
+ mx.save_safetensors(latents, zs)
42
+ elif stage == "dit":
43
+ from .dit import denoise
44
+ inputs = mx.load(embedding)
45
+ images = mx.load(latents) if refs else {}
46
+ zs = [images[str(i)] for i in range(len(refs))]
47
+ width, height = request["width"], request["height"]
48
+ rows = inputs["embedding"].shape[0] + width * height // 1024 + sum(z.shape[1] * z.shape[2] // 4 for z in zs)
49
+ mode = request["dit_mode"]
50
+ resident = mode == "resident" or (mode == "auto" and backend == "w8a8" and
51
+ info["memory_size"] >= 32 * 1024**3 and rows <= 8192)
52
+ z, _ = denoise(models / DIT, inputs["embedding"], width, height, request["seed"], resident, zs, inputs["tags"])
53
+ mx.save_safetensors(result, {"latent": z})
54
+ elif stage == "vae":
55
+ from .vae import decode
56
+ stats = json.loads((models / VAE_CONFIG).read_text())
57
+ decode(models / VAE, mx.load(result)["latent"], stats).save(work / "image.png")
58
+ else:
59
+ raise ValueError(f"Unknown stage: {stage}")
60
+ mx.synchronize()
61
+
62
+
63
+ if __name__ == "__main__":
64
+ main(sys.argv[1], Path(sys.argv[2]))