LSDJesus commited on
Commit
7d2ed44
·
verified ·
1 Parent(s): bb6a4e7

Add ComfyUI-GGUF patch script; README: how to use it

Browse files
Files changed (2) hide show
  1. README.md +17 -4
  2. patch_comfyui_gguf.py +73 -0
README.md CHANGED
@@ -52,15 +52,28 @@ w4a8 is 12.5 GB, like Q4_K.
52
 
53
  - **ComfyUI with MiniMax-H3-Image support**, merged on 10 November 2026
54
  (ComfyUI 0.44). Older versions do not know the model.
55
- - **ComfyUI-GGUF that accepts the `minimax_h3` architecture.** Until the
56
- upstream change is merged, add `"minimax_h3"` to `IMG_ARCH_LIST` near the top
57
- of `custom_nodes/ComfyUI-GGUF/loader.py`:
 
 
 
 
 
 
 
 
 
 
58
 
59
  ```python
60
  IMG_ARCH_LIST = {"flux", "sd1", "sdxl", "sd3", "aura", "hidream", "cosmos", "ltxv", "hyvid", "wan", "lumina2", "qwen_image", "minimax_h3"}
61
  ```
62
 
63
- Without it the loader stops with `Unexpected architecture type in GGUF file: 'minimax_h3'`.
 
 
 
64
  - The text encoder (`qwen3vl_32b_minimax_h3_nvfp4_awq` or `_int8_convrot`) and
65
  the VAE (`minimax_h3_image_vae_fp16`) from
66
  [Comfy-Org/MiniMax-H3-Image](https://huggingface.co/Comfy-Org/MiniMax-H3-Image).
 
52
 
53
  - **ComfyUI with MiniMax-H3-Image support**, merged on 10 November 2026
54
  (ComfyUI 0.44). Older versions do not know the model.
55
+ - **ComfyUI-GGUF that accepts the `minimax_h3` architecture.** Without it the
56
+ loader stops with `Unexpected architecture type in GGUF file: 'minimax_h3'`.
57
+ Until the upstream change is merged, either run the patch script from this
58
+ repo with the Python that runs your ComfyUI, then restart ComfyUI:
59
+
60
+ ```
61
+ python patch_comfyui_gguf.py PATH/TO/ComfyUI
62
+ python_embeded\python.exe patch_comfyui_gguf.py ComfyUI (Windows portable)
63
+ ```
64
+
65
+ or make the same one-word edit yourself: add `"minimax_h3"` to
66
+ `IMG_ARCH_LIST` near the top of `custom_nodes/ComfyUI-GGUF/loader.py`
67
+ (the folder may be called `comfyui-gguf`):
68
 
69
  ```python
70
  IMG_ARCH_LIST = {"flux", "sd1", "sdxl", "sd3", "aura", "hidream", "cosmos", "ltxv", "hyvid", "wan", "lumina2", "qwen_image", "minimax_h3"}
71
  ```
72
 
73
+ The script finds the node under any folder name, changes only that line,
74
+ keeps a `loader.py.bak`, and does nothing if the line is already there. If a
75
+ later ComfyUI-GGUF update complains about local changes to `loader.py`,
76
+ restore the original, update, and run it again.
77
  - The text encoder (`qwen3vl_32b_minimax_h3_nvfp4_awq` or `_int8_convrot`) and
78
  the VAE (`minimax_h3_image_vae_fp16`) from
79
  [Comfy-Org/MiniMax-H3-Image](https://huggingface.co/Comfy-Org/MiniMax-H3-Image).
patch_comfyui_gguf.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Let ComfyUI-GGUF load MiniMax-H3-Image GGUF files.
2
+
3
+ ComfyUI-GGUF only loads GGUF files whose architecture is on its list, and
4
+ "minimax_h3" isn't on it yet. This adds it: one word in
5
+ custom_nodes/ComfyUI-GGUF/loader.py. Nothing else changes.
6
+
7
+ Usage, from anywhere, with the Python that runs your ComfyUI:
8
+
9
+ python patch_comfyui_gguf.py PATH/TO/ComfyUI
10
+ python_embeded\\python.exe patch_comfyui_gguf.py ComfyUI (Windows portable)
11
+
12
+ Then restart ComfyUI. Running it twice is harmless. A copy of the original
13
+ is saved next to it as loader.py.bak.
14
+
15
+ If updating ComfyUI-GGUF later complains about local changes to loader.py,
16
+ restore the original (git checkout loader.py, or copy loader.py.bak back),
17
+ update, and run this again. Once ComfyUI-GGUF includes minimax_h3 itself,
18
+ you no longer need it.
19
+ """
20
+ import glob
21
+ import os
22
+ import re
23
+ import shutil
24
+ import sys
25
+
26
+ ARCH = b'"minimax_h3"'
27
+
28
+
29
+ def find_loaders(root):
30
+ """ComfyUI-GGUF's loader.py under root/custom_nodes (any folder name)."""
31
+ hits = []
32
+ for path in glob.glob(os.path.join(root, "custom_nodes", "*", "loader.py")):
33
+ with open(path, "rb") as f:
34
+ if b"IMG_ARCH_LIST" in f.read():
35
+ hits.append(path)
36
+ return hits
37
+
38
+
39
+ def patch(path):
40
+ with open(path, "rb") as f:
41
+ src = f.read()
42
+ m = re.search(rb"^IMG_ARCH_LIST\s*=\s*\{([^}\r\n]*)\}", src, re.M)
43
+ if not m:
44
+ print(f" {path}: no IMG_ARCH_LIST line in the expected form; edit it by hand")
45
+ return False
46
+ if ARCH in m.group(1):
47
+ print(f" {path}: already allows minimax_h3")
48
+ return True
49
+ body = m.group(1).rstrip()
50
+ new_body = (body + b", " if body else b"") + ARCH
51
+ out = src[:m.start(1)] + new_body + src[m.end(1):]
52
+ shutil.copy2(path, path + ".bak")
53
+ with open(path, "wb") as f:
54
+ f.write(out)
55
+ print(f" {path}: patched (original saved as loader.py.bak)")
56
+ return True
57
+
58
+
59
+ def main():
60
+ root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
61
+ if os.path.basename(os.path.normpath(root)) == "custom_nodes":
62
+ root = os.path.dirname(os.path.normpath(root))
63
+ loaders = find_loaders(root)
64
+ if not loaders:
65
+ sys.exit(f"No ComfyUI-GGUF found in {os.path.join(root, 'custom_nodes')}. "
66
+ "Pass your ComfyUI folder: python patch_comfyui_gguf.py PATH/TO/ComfyUI")
67
+ ok = all(patch(p) for p in loaders)
68
+ print("Done. Restart ComfyUI." if ok else "Not every copy could be patched; see above.")
69
+ sys.exit(0 if ok else 1)
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()