fix(minimax-h3): support ComfyUI GGUF tensor layouts - #30
Conversation
|
Automated findings: will review manually a bit later
src/model/diffusion/minimax_h3.hpp lines 298-302 Previously force_f32 was the 4th Linear argument, so AdaLN-curve models (adaln_t_table present) stored modulation weights as F32. Now that That is accumulator precision, not F32 weights. It changes Unsloth/leejet H3 too, not just realrebelai. For this architecture that is a The PR itself says there is no frame-by-frame A/B. I would not ship this mixed into the layout fix. Split it, or keep F32 storage on the
src/model_io/gguf_io.cpp lines 137-141 This is necessary for K-quants (blck=256) with logical ne[0] like 96 (video_patch_proj is Linear(96, 5376)). You cannot view Q4_K Q4_0-on-Q4_0 packed files are fine without transcode: flatten order is unchanged and 96 is a multiple of 32, so memcpy of the same bytes is • Q8_0 / Q6_K / Q5_K sources also get crushed to Q4_0 Prefer dest by source (Q8_0 if the source is Q5+ and 32-aligned; Q4_0 only for Q4/Q3/Q2), and log how many tensors were remapped.
If gguf_init_from_file fails, the reader path still builds TensorStorage from the physical shape. Packed H3 then detects ──────────────────────────────────────── |
Review StatusCurrent Status: ❌ PENDING Pending reviews: Needs 1 Management or Team Lead, and 1 more from Management, Team Lead, or Member. |
Validate restored shapes, preserve standard AdaLN precision, and transcode packed quantized tensors in bounded aligned groups with regression coverage.
Avoid a redundant local buffer when restoring validated ComfyUI tensor shapes.
Preserve valid GGML physical layouts for Qwen vision patch embeddings while continuing to restore representable ComfyUI tensor shapes.
Keep the regular GGUF reader consistent with the fallback reader for the five-dimensional Qwen vision patch embedding.
Restore five-dimensional Qwen patch embeddings as valid GGML four-dimensional shapes while preserving element counts and quantization metadata.
Scope ComfyUI precision detection to the H3 AdaLN tensor, make supported quantized remaps cover the remaining block-256 types, expose unsupported fallbacks in the loader log, and keep regression checks active in Release.
Summary
comfy.gguf.orig_shapemetadata so MiniMax-H3 tensors use their logical dimensions.Model and quantization comparison
comfy.gguf.orig_shapeAt the same quantization level, there is no evidence that the ComfyUI GGUF is inherently higher quality than the leejet or Unsloth GGUF. The main difference addressed here is tensor layout and memory handling, not an improvement to the underlying model fidelity.
What this PR enables
Realrebelai/ComfyUI MiniMax-H3 GGUF denoisers can now load in stable-diffusion.cpp. ComfyUI stores some tensors in quantization-friendly physical shapes and records the original PyTorch dimensions in
comfy.gguf.orig_shape.*; the loader now restores those logical shapes while preserving an efficient quantized representation.The tested configuration used the ComfyUI/realrebelai FL2VA Q4 denoiser together with the compatible Qwen3-VL encoder and MiniMax-H3 video/audio VAEs. It is specifically targeted at the ComfyUI-exported H3 denoiser layout, not a claim that every ComfyUI model is automatically supported.
Why memory usage improves
Previously, incompatible quantized rows could be expanded to F32 during conversion. For a large H3 denoiser this required tens of gigabytes of temporary/runtime memory. Conversion now runs in block-aligned row groups, avoiding a full-tensor F32 scratch buffer, and AdaLN modulation weights are no longer unconditionally forced to F32.
The tested ComfyUI Q4 parameter footprint decreased from approximately 86 GB to 43 GB. The Q3/Q2 configuration decreased from approximately 79 GB to 36 GB. Both allowed full-resolution 960×544 H3 coffee-commercial generation on an RTX 5090.
Validation
src/model/diffusion/minimax_h3.hpp,src/model_io/gguf_io.cpp, andsrc/model_loader.cpp; noggmlimplementation files were modified.Related addon controls
The separate QVAC addon PR #3923 exposes
backend,params_backend,max_vram, andstream_layersfor constrained execution. Those runtime controls are complementary to this PR's ComfyUI tensor-layout and loader changes.References
Speed comparison
Measured on the same RTX 5090 using the 960×544, 124-frame, 8-step coffee-commercial recipe, with native stereo audio:
The ComfyUI Q4 path is approximately 1.47× slower than Unsloth Q4 in this test. The loader PR primarily solves compatibility and memory expansion; it is not a speed optimization. The ComfyUI Q4 export still has more F32 diffusion tensors than the Unsloth Q4 export, which helps explain the higher runtime.
The standard leejet MiniMax-H3 GGUF has not yet been benchmarked with identical settings. A leejet Q4 run should be added before making a three-way speed claim.
Streaming smoke tests were not included in the controlled table: 5 frames / 1 step completed in approximately 20–24 seconds depending on CPU versus disk-backed parameters, but that workload is too small to predict full-render throughput.