From e83beb18bdd9027dc3c10fd23e74bf01098f029e Mon Sep 17 00:00:00 2001 From: Z User Date: Thu, 15 Oct 2026 19:16:24 +0000 Subject: [PATCH] fix: keep every H3 canvas on the 32px grid (odd-latent patchify crash) Users on 960x544 / 544x960 projects (and 8 more single-pass editor resolutions) crashed on the first sampling step: the hidden half-res first pass produced an odd latent side and comfy core's patchify_video could not split it into 2x2 patches. Floor the half-res first pass onto CANVAS_MULTIPLE and align width/height at every H3 conditioning entry point; also make the 'No H3 task segments' error actionable. Applied verbatim from the external app team's verified fix brief (HF main 2026-10-16): fixed files match the brief's reference md5s (e98df714fba97074938f372891802caa / 0bc6cc304fcc45ff1b335539b6ff9e44), py_compile clean, shape-math checks 10/10. Users must update the pack and restart ComfyUI. --- CHANGELOG.md | 4 ++++ nodes/minimax.py | 27 +++++++++++++++++++++++++-- nodes/project.py | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2fef6..940d806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ - **Moxie Multimedia Loader**: Locked the loader to the MiniMax H3 model set. The `clip_type` dropdown (which previously exposed every CLIP recipe in ComfyUI) was removed; the H3 Qwen3-VL text encoder is now always loaded with the `minimax` CLIP recipe. Any older ComfyUI build without `CLIPType.MINIMAX` raises a clear startup error instead of silently loading the wrong encoder. - **Moxie Multimedia Loader / Moxie MultiTrack Project**: Removed the legacy `FAST_MODEL_LOADER` (`model_loader`) bundle. The loader now outputs exactly `model`, `clip`, `video_vae`, and `audio_vae` (with the attention backend and LoRA already applied to the model), and the Moxie MultiTrack Project takes those four outputs as required direct inputs instead of a bundled loader. `Moxie Preview Override` likewise dropped its `model_loader` pass-through slots and now patches the `model` input directly. The generic `easy multitrackProject` node keeps its `model_loader` input for non-Moxie workflows. +### 🐛 Bug Fixes + +- **MultiTrack Project / MiniMax H3 nodes**: Fixed the first-step `patchify_video` crash (`RuntimeError: shape '[1, 24, 1, 1, ...]' is invalid for input of size N`) that hit 11 of the 17 editor resolution dropdown entries in single-pass mode — including the app's default 960x544 and the auto fallback 544x960. The hidden half-resolution first pass floored off the H3 32px canvas grid (544x960 halved to 272x480 encodes to a 17x30 latent whose odd side comfy core cannot split into 2x2 patches); the first pass now floors onto the grid (544x960 samples at 256x480, and Moxie Project Video Combine still restores the exact editor resolution, so output size and quality are unchanged). The MiniMax H3 conditioning entry points (`MiniMaxH3ImageToVideoFallback`, `MiniMaxH3ReferenceToVideoFallback`, `EasyMiniMaxH3ToVideo`) align their canvas the same way, which also fixes dual-pass and SelfLift at any editor size that is not a multiple of 32. The misleading "No H3 task segments are available from segment_start_number." error now distinguishes an empty timeline from an out-of-range `segment_start_number` and says what to do about each. **After updating, restart ComfyUI once** — a stale off-grid latent cached in the temp directory otherwise survives the pack update and the crash appears to persist. + ## [1.3.3] - 2026-09-25 ### ✨ New Features diff --git a/nodes/minimax.py b/nodes/minimax.py index 656284b..766eac5 100644 --- a/nodes/minimax.py +++ b/nodes/minimax.py @@ -57,6 +57,25 @@ from ..utils.video import passthrough_video_media CATEGORY_MINIMAX = "EasyUse/MiniMax" CANVAS_MULTIPLE = 32 + + +def _align_canvas_dimension(value: Any) -> int: + """Floor a canvas side onto the H3 32px grid (CANVAS_MULTIPLE). + + The video VAE latent grid is pixels // 16 and the diffusion model + patchifies that latent with a 2x2 patch, so every canvas side must be a + multiple of 32. Anything else produces an odd latent dimension and crashes + comfy's patchify_video reshape ("shape '[1, 24, ...]' is invalid for input + of size N"). Floors instead of rounds so alignment never upsamples past + the requested size. + """ + try: + number = int(value) + except (TypeError, ValueError): + return CANVAS_MULTIPLE + return max(CANVAS_MULTIPLE, number // CANVAS_MULTIPLE * CANVAS_MULTIPLE) + + BASE_SHORT_EDGE = 768 MAX_PIXELS = 768 * 1344 REF_IMAGE_SHORT_EDGE = 2048 @@ -489,6 +508,8 @@ class MiniMaxH3ImageToVideoFallback(io.ComfyNode): first_frame: torch.Tensor | None = None, last_frame: torch.Tensor | None = None, ) -> io.NodeOutput: + width = _align_canvas_dimension(width) + height = _align_canvas_dimension(height) latent, frame_count = _empty_av_latent(width, height, length) token_images: list[torch.Tensor] = [] keyframes: list[dict[str, Any]] = [] @@ -617,6 +638,8 @@ class MiniMaxH3ReferenceToVideoFallback(io.ComfyNode): ref_video_audios: dict[str, dict[str, Any] | None] | None = None, ref_audios: dict[str, dict[str, Any]] | None = None, ) -> io.NodeOutput: + width = _align_canvas_dimension(width) + height = _align_canvas_dimension(height) latent, frame_count = _empty_av_latent(width, height, length) reference_items: list[dict[str, Any]] = [] reference_blocks: list[dict[str, Any]] = [] @@ -2742,8 +2765,8 @@ class EasyMiniMaxH3ToVideo(io.ComfyNode): selected_vae = _first_input(vae) selected_audio_vae = _first_input(audio_vae) prompt_text = str(_first_input(prompt, "")) - target_width = int(_first_input(width, 1344)) - target_height = int(_first_input(height, 768)) + target_width = _align_canvas_dimension(_first_input(width, 1344)) + target_height = _align_canvas_dimension(_first_input(height, 768)) target_length = int(_first_input(length, 124)) locked_timing_frames = int(_first_input(locked_video_timing_frames, 0)) expanded_images = expand_image_inputs(images) diff --git a/nodes/project.py b/nodes/project.py index 405017d..06870ce 100644 --- a/nodes/project.py +++ b/nodes/project.py @@ -46,6 +46,7 @@ from ..utils.multitrack import ( MULTITRACK_RUNTIME_CACHE_KEY, multitrack_runtime_cache, ) +from .minimax import CANVAS_MULTIPLE TYPE_FAST_MODEL_LOADER = io.Custom(io_type="FAST_MODEL_LOADER") @@ -1215,8 +1216,23 @@ class EasyMultiTrackProject(io.ComfyNode): # keeps the editor size exactly as configured. first_pass_width, first_pass_height = editor_width, editor_height if sampling_mode == "single" and not audio_only: - half_width = max(32, editor_width // 2) - half_height = max(32, editor_height // 2) + # The half-resolution canvas must stay on the H3 32px grid + # (CANVAS_MULTIPLE): the video VAE downsamples by 16 and the + # diffusion model patchifies the latent with a 2x2 patch, so a + # first-pass side that is not a multiple of 32 yields an odd + # latent dimension and crashes comfy's patchify_video with + # "shape '[1, 24, 1, 1, ...]' is invalid for input of size N" + # (e.g. a 544x960 editor project halved to 272x480 produces a + # 17x30 latent). Floor to the grid instead of rounding so the + # first pass never upsamples past half the editor resolution. + half_width = max( + 32, + (editor_width // 2) // CANVAS_MULTIPLE * CANVAS_MULTIPLE, + ) + half_height = max( + 32, + (editor_height // 2) // CANVAS_MULTIPLE * CANVAS_MULTIPLE, + ) if (half_width, half_height) != (32, 32): first_pass_width, first_pass_height = half_width, half_height target_width, target_height = h3_second_pass_dimensions( @@ -1244,8 +1260,19 @@ class EasyMultiTrackProject(io.ComfyNode): segment_count, ) if not selected_entries: + if not all_entries: + raise ValueError( + "No H3 task segments are available: the MultiTrack timeline " + "does not contain any task-track segments. Add at least one " + "task segment in the MultiTrack Editor and run the project " + "again." + ) raise ValueError( - "No H3 task segments are available from segment_start_number." + "No H3 task segments are available from segment_start_number=" + f"{segment_start_number} (segment_count={segment_count}): the " + f"timeline only contains {len(all_entries)} task segment(s), " + "numbered from 1. Lower segment_start_number or add more task " + "segments in the MultiTrack Editor." ) first_selected_index, first_selected_entry = selected_entries[0]