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.
This commit is contained in:
Z User 2026-10-15 19:16:24 +00:00
parent 078a7749b3
commit e83beb18bd
3 changed files with 59 additions and 5 deletions

View File

@ -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**: 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. - **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 ## [1.3.3] - 2026-09-25
### ✨ New Features ### ✨ New Features

View File

@ -57,6 +57,25 @@ from ..utils.video import passthrough_video_media
CATEGORY_MINIMAX = "EasyUse/MiniMax" CATEGORY_MINIMAX = "EasyUse/MiniMax"
CANVAS_MULTIPLE = 32 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 BASE_SHORT_EDGE = 768
MAX_PIXELS = 768 * 1344 MAX_PIXELS = 768 * 1344
REF_IMAGE_SHORT_EDGE = 2048 REF_IMAGE_SHORT_EDGE = 2048
@ -489,6 +508,8 @@ class MiniMaxH3ImageToVideoFallback(io.ComfyNode):
first_frame: torch.Tensor | None = None, first_frame: torch.Tensor | None = None,
last_frame: torch.Tensor | None = None, last_frame: torch.Tensor | None = None,
) -> io.NodeOutput: ) -> io.NodeOutput:
width = _align_canvas_dimension(width)
height = _align_canvas_dimension(height)
latent, frame_count = _empty_av_latent(width, height, length) latent, frame_count = _empty_av_latent(width, height, length)
token_images: list[torch.Tensor] = [] token_images: list[torch.Tensor] = []
keyframes: list[dict[str, Any]] = [] 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_video_audios: dict[str, dict[str, Any] | None] | None = None,
ref_audios: dict[str, dict[str, Any]] | None = None, ref_audios: dict[str, dict[str, Any]] | None = None,
) -> io.NodeOutput: ) -> io.NodeOutput:
width = _align_canvas_dimension(width)
height = _align_canvas_dimension(height)
latent, frame_count = _empty_av_latent(width, height, length) latent, frame_count = _empty_av_latent(width, height, length)
reference_items: list[dict[str, Any]] = [] reference_items: list[dict[str, Any]] = []
reference_blocks: list[dict[str, Any]] = [] reference_blocks: list[dict[str, Any]] = []
@ -2742,8 +2765,8 @@ class EasyMiniMaxH3ToVideo(io.ComfyNode):
selected_vae = _first_input(vae) selected_vae = _first_input(vae)
selected_audio_vae = _first_input(audio_vae) selected_audio_vae = _first_input(audio_vae)
prompt_text = str(_first_input(prompt, "")) prompt_text = str(_first_input(prompt, ""))
target_width = int(_first_input(width, 1344)) target_width = _align_canvas_dimension(_first_input(width, 1344))
target_height = int(_first_input(height, 768)) target_height = _align_canvas_dimension(_first_input(height, 768))
target_length = int(_first_input(length, 124)) target_length = int(_first_input(length, 124))
locked_timing_frames = int(_first_input(locked_video_timing_frames, 0)) locked_timing_frames = int(_first_input(locked_video_timing_frames, 0))
expanded_images = expand_image_inputs(images) expanded_images = expand_image_inputs(images)

View File

@ -46,6 +46,7 @@ from ..utils.multitrack import (
MULTITRACK_RUNTIME_CACHE_KEY, MULTITRACK_RUNTIME_CACHE_KEY,
multitrack_runtime_cache, multitrack_runtime_cache,
) )
from .minimax import CANVAS_MULTIPLE
TYPE_FAST_MODEL_LOADER = io.Custom(io_type="FAST_MODEL_LOADER") 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. # keeps the editor size exactly as configured.
first_pass_width, first_pass_height = editor_width, editor_height first_pass_width, first_pass_height = editor_width, editor_height
if sampling_mode == "single" and not audio_only: if sampling_mode == "single" and not audio_only:
half_width = max(32, editor_width // 2) # The half-resolution canvas must stay on the H3 32px grid
half_height = max(32, editor_height // 2) # (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): if (half_width, half_height) != (32, 32):
first_pass_width, first_pass_height = half_width, half_height first_pass_width, first_pass_height = half_width, half_height
target_width, target_height = h3_second_pass_dimensions( target_width, target_height = h3_second_pass_dimensions(
@ -1244,8 +1260,19 @@ class EasyMultiTrackProject(io.ComfyNode):
segment_count, segment_count,
) )
if not selected_entries: 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( 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] first_selected_index, first_selected_entry = selected_entries[0]