revert: remove Moxie MultiTrack Project Slow and restore the certified project nodes

Tree restored to 0a9416b (before the Slow arc): the Slow node and its
registration, the upscale_model/tiling widgets, the even-latent
first-pass snap, and every Slow-motivated change to the shared project
nodes (first-pass sizing hooks, tile_count relaxation, preview widget
minimum) are gone. LoRA removal and the context_frames feature predate
the Slow arc and are kept.
This commit is contained in:
Z User 2026-10-15 04:30:50 +00:00
parent 5347719cdd
commit 078a7749b3
6 changed files with 64 additions and 798 deletions

View File

@ -6,7 +6,7 @@
### ⚡ Improvements
- **Moxie MultiTrack Project Slow**: New project node variant that replaces the RTX VSR restore with a latent-upscale refine pass. The pipeline stays identical to Moxie MultiTrack Project — hidden half-resolution first pass with euler + beta sigmas from `steps` — but the low-resolution latent is upscaled to the final (editor) size by a latent upscaler checkpoint and refined with a hidden 2-step euler pass at 0.33 denoise. The refine pass samples through **automatic spatial tiling**: the engine picks the tile count from the available accelerator memory and bypasses tiling entirely when the full evaluation fits, so projects up to **1920x1080** also run on 12 GB cards and on **AMD/Intel GPUs** (the tiling machinery uses only device-agnostic ComfyUI memory helpers — nothing in this node requires CUDA; non-NVIDIA machines should pick the `pytorch_attention` backend on the loader, since the INT8 attention backend is Nvidia/AMD-only). The new `tiling` switch next to `upscale_model` turns the tiles off for machines that prefer the refine pass sampled in one piece — it defaults to **on**, so old workflows and fresh drops keep the memory-adaptive behaviour. Segments are saved at the project resolution, so the Video Combine restore passes through untouched and nothing in the node requires NVIDIA RTX VSR. The upscaler is chosen in a new `upscale_model` dropdown on the node (placed with the model inputs; lists everything under `ComfyUI/models/latent_upscale_models/`, defaults to `minimax_h3_latent_upscaler_3d_fp16.safetensors`, and rejects `None` with a clear error since the node always upscales in latent space). End users still only set `steps` and `seed` (plus the shared `context_frames` overlap). The engine's first-pass downscale and upscale-skip logic were generalized (class hook + true size comparison) with zero behavior change for existing nodes; `tile_count` values of `0` (automatic) are additionally accepted alongside the fixed 2–8 range.
- **Moxie MultiTrack Project Slow**: Removed the experimental node again, together with its `upscale_model` / `tiling` widgets and the even-latent first-pass snap — the shared project-node internals are restored byte-for-byte to their certified behavior. Workflows that referenced the Slow node need rewiring to **Moxie MultiTrack Project**.
- **MultiTrack Project**: The inter-segment context overlap is now configurable. The new `context_frames` widget (5 / 22 / 39 / 56 frames, default 22) chooses how many frames of the previous segment are copied in as continuation context for segments using Context or Context Swap continuity — previously this was fixed at 22 frames in code. Longer values hand off motion more smoothly but generate that many extra frames per continued segment (each continuation also generates 12 grid-alignment tail frames that are trimmed after decode). Values are the H3 temporal-grid lengths already offered by the Moxie context sampler nodes; existing workflows keep 22 and behave exactly as before. The same widget (between `steps` and `seed`) is also exposed on **Moxie MultiTrack Project** — its baked euler/beta sampling stack is unchanged, so end users still only need `steps` and `seed` unless they touch the overlap.
@ -27,10 +27,6 @@
- **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
- **Moxie MultiTrack Project Slow** (Slow node only — every other node keeps its certified behavior byte for byte): multi-segment projects at 1920x1080 crashed on the first continuation segment with `RuntimeError: shape '[1, 24, 1, 1, 8, 2, 15, 2]' is invalid for input of size 12240` (`patchify_video`). The Slow node's hidden half-resolution first pass declared its size with plain integer halving, so a 1080p editor sampled at 960x540 — and a latent encoded from 540px carries an odd 17-row count. Odd latents sample fine, but when the segment tail comes back as motion-context keyframes on the next segment, the model's `patchify_video` (2x2 latent patches) cannot reshape them. The Slow node now snaps its hidden first pass onto the nearest 64px grid (`MoxieProjectSlow._h3_first_pass_size` override): 1920x1080 samples at 960x512, 1344x768 at 704x384, 3840x2160 at 1920x1088 (unchanged vs the VAE round-up). Output sizes and the second pass are unchanged; only Slow continuation segments that previously crashed now run. Regression tests pin the certified plain-halving first pass of `MultiTrack Project` and `Moxie MultiTrack Project` (672x384 at a 1344x768 editor) and the certified decision rules of the sampling preview sampler node (widget text, default 2, max 8 — its `min` is widened to 0 only because the engine passes the Slow node's automatic `tile_count 0` through it and ComfyUI validates inputs against `min` at execution; certified `tile_count` values validate exactly as before).
## [1.3.3] - 2026-09-25
### ✨ New Features

View File

@ -12,7 +12,7 @@ from .utils.bernini_s2v_model_patch import apply_bernini_s2v_model_patches
from .utils.log import install_console_privacy_filter
from .moxie_loader import MoxieMultimediaLoader
from .moxie_project import MoxieProject, MoxieProjectSlow
from .moxie_project import MoxieProject
from .moxie_combine import MoxieCombine
from .moxie_preview import ModelPreviewOverrideKJ as MoxiePreviewOverride
@ -82,7 +82,6 @@ class EasyMediaExtension(ComfyExtension):
MoxieMultimediaLoader,
MoxiePreviewOverride,
MoxieProject,
MoxieProjectSlow,
MoxieCombine,
# TimelineEditor
TimelineEditor,

View File

@ -1,8 +1,6 @@
from __future__ import annotations
import comfy.samplers
import folder_paths
import math
from comfy_api.latest import io
from .nodes.project import (
@ -30,106 +28,6 @@ BAKED_PROJECT_SETTINGS = {
BAKED_SAMPLER_NAME = "euler"
BAKED_SCHEDULER = "beta"
# Moxie MultiTrack Project Slow: the hidden half-resolution first pass is
# upscaled to the final size by the H3 latent upscaler model and refined with
# a short low-denoise euler pass instead of the RTX VSR pixel restore.
SLOW_UPSCALE_MODEL = "minimax_h3_latent_upscaler_3d_fp16.safetensors"
SLOW_SECOND_PASS_STEPS = 2
SLOW_SECOND_PASS_DENOISE = 0.33
# Spatial tiling of the second pass with an automatic tile count: 0 lets the
# engine choose how many tiles fit into the available accelerator memory and
# skip tiling entirely when the full evaluation fits. The tiling module only
# uses device-agnostic ComfyUI memory helpers, so this also brings 1920x1080
# output within reach of 12 GB cards and AMD/Intel GPUs.
SLOW_TILING_SETTINGS = {"enabled_tiling": "true", "tile_count": 0}
# The tiling toggle OFF: the engine skips tiling and samples the refine pass
# in one piece (plain SamplerCustomAdvanced, the pre-tiling behaviour).
SLOW_TILING_DISABLED = {"enabled_tiling": "false", "tile_count": 0}
SLOW_PROJECT_SETTINGS_DELTA = {
"sampling_mode": "dual",
# The first pass already runs at half the editor resolution, so the final
# size IS the editor size: a scale factor of 1.0 keeps the project
# manifest at the editor dimensions while the latent upscaler (target
# dimensions mode) bridges the half-res gap. The upscaler checkpoint is
# NOT baked and neither is tiling: the Slow node exposes the
# upscale_model widget and the tiling toggle instead.
"upscale_by": 1.0,
}
_TILING_ON_VALUES = frozenset({"true", "enable", "enabled", "on", "1"})
def _tiling_switch(value, default: bool = True) -> bool:
"""Resolve the tiling toggle; tolerates booleans and legacy strings."""
enabled = _first_input(value, default)
if isinstance(enabled, str):
return enabled.strip().lower() in _TILING_ON_VALUES
return bool(enabled)
def _h3_even_latent_size(pixels: int) -> int:
"""Snap a pixel size onto the H3 latent grid with even row/column counts.
H3 video patches cover 2x2 latent cells on the 32px latent grid, so a
latent encoded from a size that is not a multiple of 64 ends up with an
odd row/column count (540px encodes to 17 rows). Odd latents sample
fine, but they cannot be patchified when they come back as context
keyframes on a continuation segment: patchify_video computes the patch
grid with floor division and the reshape fails with "shape ... is
invalid for input of size ...". Landing the size on the nearest 64px
multiple keeps every latent in the Slow pipeline (initial latent,
reference conditioning, saved context tail) on one consistent,
patchable grid: 540 -> 512, 672 -> 704, 1080 -> 1088.
Scoped to the Slow node on purpose: the other project nodes are
certified and keep their plain-halving first pass.
"""
if pixels <= 32:
return max(32, pixels)
return max(64, int(math.floor(pixels / 64 + 0.5)) * 64)
def _require_moxie_components(model, clip, video_vae, audio_vae) -> None:
missing = [
name
for name, value in (
("model", model),
("clip", clip),
("video_vae", video_vae),
("audio_vae", audio_vae),
)
if value is None
]
if missing:
raise ValueError(
"MoxieProject: Missing required model components: "
+ ", ".join(missing)
+ ". Wire model, clip, video_vae, and audio_vae from Moxie Multimedia Loader."
)
def _denoise_truncated_sigmas(
model_sampling, scheduler: str, steps: int, denoise: float
):
"""Sigma schedule for `steps` steps at `denoise`, matching KSampler.
Replicates comfy KSampler.set_steps: build the schedule at
int(steps / denoise) total steps, then keep the last steps + 1 sigmas.
Written out because newer ComfyUI builds dropped the denoise kwarg from
comfy.samplers.calculate_sigmas.
"""
if denoise <= 0.0:
raise ValueError("denoise must be positive")
if denoise > 0.9999:
total_steps = steps
else:
total_steps = int(steps / denoise)
schedule = comfy.samplers.calculate_sigmas(
model_sampling, scheduler, total_steps
).cpu()
return schedule[-(steps + 1):]
class MoxieProject(EasyMultiTrackProject):
"""MultiTrack Project with the sampling stack consolidated.
@ -140,62 +38,6 @@ class MoxieProject(EasyMultiTrackProject):
internally from the exposed `steps` widget.
"""
@classmethod
def _baked_project_settings(cls) -> dict:
return dict(BAKED_PROJECT_SETTINGS)
@classmethod
def _component_inputs(cls) -> list:
"""Extra inputs subclasses slot in after the model components."""
return []
@classmethod
def _project_inputs(cls) -> list:
inputs = [
TYPE_TRACKS_INFO.Input("tracks_info"),
io.Model.Input("model", tooltip="Diffusion model from Moxie Multimedia Loader (attention backend already applied)."),
io.Clip.Input("clip", tooltip="CLIP text encoder from Moxie Multimedia Loader."),
io.Vae.Input("video_vae", tooltip="Video VAE from Moxie Multimedia Loader."),
io.Vae.Input("audio_vae", tooltip="Audio VAE from Moxie Multimedia Loader (required to decode Moxie audio)."),
]
inputs.extend(cls._component_inputs())
inputs.extend(
[
io.String.Input("project_name", default="",
tooltip="Name of the project; used for output folders."),
io.Int.Input(
"steps",
default=3,
min=1,
max=10000,
tooltip="Sampling steps for the beta scheduler (3 for the baked-in 3-step distill; "
"8 for busy motion, 6 low motion, 4 runs/no dialogue).",
),
io.Combo.Input(
"context_frames",
options=[str(option) for option in H3_CONTEXT_LENGTH_OPTIONS],
default=str(H3_CONTEXT_SOURCE_FRAMES),
tooltip=(
"Video frames copied from the previous segment as "
"continuation context for segments whose continuity "
"mode is Context or Context Swap. Longer values hand "
"off motion more smoothly but generate that many extra "
"frames per segment. Values are H3 temporal-grid "
"lengths shared with the Moxie context sampler nodes."
),
),
io.Int.Input(
"seed",
default=42,
min=0,
max=0xFFFFFFFFFFFFFFFF,
step=1,
control_after_generate=io.ControlAfterGenerate.randomize,
),
]
)
return inputs
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
@ -210,7 +52,44 @@ class MoxieProject(EasyMultiTrackProject):
is_input_list=True,
enable_expand=True,
not_idempotent=True,
inputs=cls._project_inputs(),
inputs=[
TYPE_TRACKS_INFO.Input("tracks_info"),
io.Model.Input("model", tooltip="Diffusion model from Moxie Multimedia Loader (attention backend already applied)."),
io.Clip.Input("clip", tooltip="CLIP text encoder from Moxie Multimedia Loader."),
io.Vae.Input("video_vae", tooltip="Video VAE from Moxie Multimedia Loader."),
io.Vae.Input("audio_vae", tooltip="Audio VAE from Moxie Multimedia Loader (required to decode Moxie audio)."),
io.String.Input("project_name", default="",
tooltip="Name of the project; used for output folders."),
io.Int.Input(
"steps",
default=3,
min=1,
max=10000,
tooltip="Sampling steps for the beta scheduler (3 for the baked-in 3-step distill; "
"8 for busy motion, 6 low motion, 4 runs/no dialogue).",
),
io.Combo.Input(
"context_frames",
options=[str(option) for option in H3_CONTEXT_LENGTH_OPTIONS],
default=str(H3_CONTEXT_SOURCE_FRAMES),
tooltip=(
"Video frames copied from the previous segment as "
"continuation context for segments whose continuity "
"mode is Context or Context Swap. Longer values hand "
"off motion more smoothly but generate that many extra "
"frames per segment. Values are H3 temporal-grid "
"lengths shared with the Moxie context sampler nodes."
),
),
io.Int.Input(
"seed",
default=42,
min=0,
max=0xFFFFFFFFFFFFFFFF,
step=1,
control_after_generate=io.ControlAfterGenerate.randomize,
),
],
hidden=[io.Hidden.prompt, io.Hidden.unique_id],
outputs=[
io.String.Output("PROJECT_NAME"),
@ -226,7 +105,13 @@ class MoxieProject(EasyMultiTrackProject):
clip = _first_input(kwargs.get("clip"))
video_vae = _first_input(kwargs.get("video_vae"))
audio_vae = _first_input(kwargs.get("audio_vae"))
_require_moxie_components(model, clip, video_vae, audio_vae)
if model is None or clip is None or video_vae is None or audio_vae is None:
missing = [k for k, v in [("model", model), ("clip", clip), ("video_vae", video_vae), ("audio_vae", audio_vae)] if v is None]
raise ValueError(
"MoxieProject: Missing required model components: " + ", ".join(missing) +
". Wire model, clip, video_vae, and audio_vae from Moxie Multimedia Loader."
)
# Pack the direct inputs into the loader dict consumed by
# EasyMultiTrackProject.execute (internal plumbing only).
@ -245,188 +130,8 @@ class MoxieProject(EasyMultiTrackProject):
sampler = comfy.samplers.sampler_object(BAKED_SAMPLER_NAME)
baked = dict(kwargs)
baked.update(cls._baked_project_settings())
baked.update(BAKED_PROJECT_SETTINGS)
baked["model_loader"] = synthesized_loader
baked["sampler"] = sampler
baked["sigmas"] = sigmas
return super().execute(**baked)
class MoxieProjectSlow(MoxieProject):
"""Moxie MultiTrack Project with a latent-upscale refine pass.
Identical pipeline to MoxieProject (hidden half-resolution first pass,
euler + beta sampling from `steps`), except the low-resolution latent is
upscaled to the final size by a latent upscaler model chosen in the
`upscale_model` widget and refined with a 2-step euler pass at 0.33
denoise. The refine pass samples through automatic spatial tiling, so
large projects (up to 1920x1080) also run on 12 GB cards and on AMD or
Intel GPUs; the tile count adapts to the machine and tiling is skipped
entirely when the whole evaluation fits in memory. The `tiling` switch
turns the tiles off for machines that prefer the refine pass sampled in
one piece. Unlike the certified project nodes, the Slow node's hidden
first pass is snapped onto the even-latent grid (nearest 64px multiple)
so continuation segments can patchify the context tail; output sizes
are unchanged. Segments are saved at the project resolution, so the
Video Combine RTX restore passes through untouched - no NVIDIA RTX VSR
is used anywhere.
"""
@classmethod
def _latent_upscaler_options(cls) -> list:
models = list(folder_paths.get_filename_list("latent_upscale_models"))
if SLOW_UPSCALE_MODEL not in models:
# Keep the bundled checkpoint selectable even before it is
# downloaded; the combo default must always be a valid option.
models.append(SLOW_UPSCALE_MODEL)
return ["None"] + models
@classmethod
def _component_inputs(cls) -> list:
return [
io.Combo.Input(
"upscale_model",
options=cls._latent_upscaler_options(),
default=SLOW_UPSCALE_MODEL,
tooltip=(
"Latent upscaler checkpoint that brings the hidden "
"half-resolution first pass to the final size before "
"the 2-step refine. Files live under "
"ComfyUI/models/latent_upscale_models/; None is "
"rejected because this node always upscales in latent "
"space instead of the RTX restore."
),
),
io.Boolean.Input(
"tiling",
default=True,
tooltip=(
"Tile the 2-step refine pass so large projects (up to "
"1920x1080) also fit on 12 GB cards and on AMD or Intel "
"GPUs; the tile count adapts to the available memory and "
"tiling is skipped entirely when the whole pass fits "
"anyway. Disable to sample the refine pass in one piece."
),
),
]
@classmethod
def _baked_project_settings(cls) -> dict:
settings = dict(BAKED_PROJECT_SETTINGS)
# The upscaler checkpoint and the tiling switch come from widgets.
settings.pop("upscale_model", None)
settings.pop("enabled_tiling", None)
settings.update(SLOW_PROJECT_SETTINGS_DELTA)
return settings
@classmethod
def _h3_first_pass_resolution_scale(cls, sampling_mode: str) -> float:
# Dual mode would sample the first pass at the editor size; the Slow
# node keeps MoxieProject's hidden half-resolution speed trick and
# lets the latent upscaler bridge the gap instead of RTX VSR.
return 0.5
@classmethod
def _h3_first_pass_size(
cls, editor_width: int, editor_height: int, first_pass_scale: float
) -> tuple[int, int]:
# Slow-only deviation from the certified first pass: snap the hidden
# pass onto the even-latent grid so continuation segments can
# patchify the context tail (odd latents crash patchify_video on
# scene 2+). The certified project nodes keep the plain-halving
# behavior via the base class default.
return (
_h3_even_latent_size(int(editor_width * first_pass_scale)),
_h3_even_latent_size(int(editor_height * first_pass_scale)),
)
@classmethod
def _h3_needs_latent_upscale(
cls,
audio_only: bool,
first_pass_width: int,
first_pass_height: int,
target_width: int,
target_height: int,
upscale_by: float,
) -> bool:
# The Slow node samples the first pass at half resolution and always
# bridges the gap with the latent upscaler, so the decision is a true
# size comparison instead of the certified upscale_by rule (which
# would skip at upscale_by 1.0 and leave the refine pass at half
# size).
return not (
audio_only
or (first_pass_width, first_pass_height)
== (target_width, target_height)
)
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
node_id="MoxieProjectSlow",
display_name="Moxie MultiTrack Project Slow",
category="EasyUse/MultiTrackEditor",
description=(
"Build and execute a multi-track Moxie project with a "
"latent-upscale refine pass. Takes model, clip, video_vae and "
"audio_vae directly from the Moxie Multimedia Loader and an "
"upscale_model checkpoint from latent_upscale_models. The "
"first pass samples euler + beta sigmas from steps, the "
"half-resolution latent is upscaled to the final size with "
"the chosen latent upscaler, and a 2-step euler pass at "
"0.33 denoise refines it through automatic spatial tiling "
"(scales to the available VRAM, enabling up to 1920x1080 "
"output on 12 GB and AMD/Intel GPUs); the tiling switch "
"turns the tiles off; set only steps and seed."
),
is_input_list=True,
enable_expand=True,
not_idempotent=True,
inputs=cls._project_inputs(),
hidden=[io.Hidden.prompt, io.Hidden.unique_id],
outputs=[
io.String.Output("PROJECT_NAME"),
io.Audio.Output("LOCKED_AUDIO"),
],
)
@classmethod
def execute(cls, **kwargs) -> io.NodeOutput:
model = _first_input(kwargs.get("model"))
clip = _first_input(kwargs.get("clip"))
video_vae = _first_input(kwargs.get("video_vae"))
audio_vae = _first_input(kwargs.get("audio_vae"))
_require_moxie_components(model, clip, video_vae, audio_vae)
upscale_model = _first_input(kwargs.get("upscale_model"))
if upscale_model is None:
upscale_model = SLOW_UPSCALE_MODEL
upscale_model = str(upscale_model).strip()
if not upscale_model or upscale_model == "None":
raise ValueError(
"Moxie MultiTrack Project Slow always upscales the "
"half-resolution latent in latent space, so it needs a "
"model: pick a checkpoint in the upscale_model dropdown "
"(files under ComfyUI/models/latent_upscale_models/)."
)
sigmas_2nd = _denoise_truncated_sigmas(
model.get_model_object("model_sampling"),
BAKED_SCHEDULER,
SLOW_SECOND_PASS_STEPS,
SLOW_SECOND_PASS_DENOISE,
)
# The tiling toggle: ON (default, also for old workflows without the
# widget) keeps the memory-adaptive automatic tile count; OFF hands
# the engine an explicit disabled config so the refine pass is
# sampled in one piece.
tiling_on = _tiling_switch(kwargs.get("tiling"))
injected = dict(kwargs)
injected["sampler_2nd"] = comfy.samplers.sampler_object(BAKED_SAMPLER_NAME)
injected["sigmas_2nd"] = sigmas_2nd
injected["upscale_model"] = upscale_model
injected["enabled_tiling"] = (
SLOW_TILING_SETTINGS if tiling_on else SLOW_TILING_DISABLED
)
return super().execute(**injected)

View File

@ -421,8 +421,8 @@ def _h3_tiling_config(value: Any) -> tuple[bool, int]:
if not enabled:
return False, 0
tile_count = int(_first_input(config.get("tile_count"), 2))
if tile_count != 0 and not 2 <= tile_count <= 8:
raise ValueError("tile_count must be 0 (automatic) or between 2 and 8")
if not 2 <= tile_count <= 8:
raise ValueError("tile_count must be between 2 and 8")
return True, tile_count
@ -491,12 +491,7 @@ class EasyH3SamplingPreviewSampler(io.ComfyNode):
io.Int.Input(
"tile_count",
default=2,
# min 0 is required by Moxie MultiTrack Project Slow: the
# engine builds this node with tile_count 0 (automatic,
# memory-based) and ComfyUI validates inputs against min
# at execution (execution.py "smaller than min"). Values
# 2-8 and the default validate exactly as before.
min=0,
min=2,
max=8,
step=1,
optional=True,
@ -885,52 +880,6 @@ class EasyMultiTrackProject(io.ComfyNode):
"""Return sorted sampling plan keys: user presets first, then 'custom'."""
return get_h3_preset_keys()
@classmethod
def _h3_first_pass_resolution_scale(cls, sampling_mode: str) -> float:
"""Hidden first-pass downscale applied before sampling.
Single-pass projects sample at half the editor resolution and recover
the exact editor size in pixel space through the Video Combine RTX
restore (utils/rtx_vsr.py). Project variants that upscale the latent
to the final size instead override this to keep the same speed trick
on other sampling modes; every other mode keeps the editor size.
"""
return 0.5 if sampling_mode == "single" else 1.0
@classmethod
def _h3_first_pass_size(
cls, editor_width: int, editor_height: int, first_pass_scale: float
) -> tuple[int, int]:
"""Scaled hidden first-pass size for the given editor dimensions.
Default is the certified plain-halving behavior. Subclasses may
override this to adjust their own hidden pass without changing how
this node or any other project variant samples.
"""
return (
max(32, int(editor_width * first_pass_scale)),
max(32, int(editor_height * first_pass_scale)),
)
@classmethod
def _h3_needs_latent_upscale(
cls,
audio_only: bool,
first_pass_width: int,
first_pass_height: int,
target_width: int,
target_height: int,
upscale_by: float,
) -> bool:
"""Whether the second pass needs the latent upscaled to the target.
Default is the certified rule: skip whenever no upscale factor is
configured. Variants that sample the first pass below the target
size (latent-upscale refine) override this with a true size
comparison.
"""
return not (audio_only or upscale_by <= 1)
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
@ -1259,19 +1208,17 @@ class EasyMultiTrackProject(io.ComfyNode):
editor_height = int(info["height"])
audio_only = (editor_width, editor_height) == (32, 32)
fps = float(info["frame_rate"])
# Hidden first-pass downscale: project classes may sample below the
# editor-selected resolution (single-pass Moxie projects use half)
# and recover the editor size later - in pixel space via the Video
# Combine RTX restore, or in latent space via the upscaler pass on
# the Slow variant. The hook returns 1.0 unless overridden.
# Hidden half-res sampling (single-pass projects only): condition and
# sample at half the editor-selected resolution; Moxie Project Video
# Combine restores the exact editor resolution in pixel space before
# its images output (utils/rtx_vsr.py). Every other sampling mode
# keeps the editor size exactly as configured.
first_pass_width, first_pass_height = editor_width, editor_height
first_pass_scale = float(cls._h3_first_pass_resolution_scale(sampling_mode))
if first_pass_scale != 1.0 and not audio_only:
scaled_width, scaled_height = cls._h3_first_pass_size(
editor_width, editor_height, first_pass_scale
)
if (scaled_width, scaled_height) != (32, 32):
first_pass_width, first_pass_height = scaled_width, scaled_height
if sampling_mode == "single" and not audio_only:
half_width = max(32, editor_width // 2)
half_height = max(32, editor_height // 2)
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(
editor_width,
editor_height,
@ -1944,17 +1891,7 @@ class EasyMultiTrackProject(io.ComfyNode):
and context_second_pass_sigmas is not None
):
segment_second_pass_sigmas = context_second_pass_sigmas
# No upscale pass is needed when the certified rule says the
# factor does not ask for one, or when a variant sampled the
# first pass directly at the target size.
if not cls._h3_needs_latent_upscale(
audio_only,
first_pass_width,
first_pass_height,
target_width,
target_height,
upscale_by,
):
if audio_only or upscale_by <= 1:
report_segment_step(0.46)
upscaled_latent = final_latent
else:

View File

@ -268,7 +268,6 @@ custom 示例:
- `sampling_mode`: `single` 或 `dual`;`sampling_plan` 必须是当前节点可用预设。不要仅凭另一份流程中的值假设当前环境支持。
- `context_frames`(默认 `"22"`,可选 `"5"` / `"22"` / `"39"` / `"56"`)控制 Context / Context Swap 续接片段从上一段拷贝为延续上下文的视频帧数;取值必须落在 H3 时间潜空间网格(17k+5 帧)上,与 Moxie 上下文采样节点的选项一致。数值越大运动衔接越平滑,但每个续接片段会多生成等量帧(实际生成长度为 `任务长度 + context_frames + 12`,其中 12 帧为网格尾帧,解码后裁掉)。
- `Moxie MultiTrack Project`(`MoxieProject`)同样暴露同一个 `context_frames` 下拉,位于 `steps` 与 `seed` 之间;该节点的其余采样设置仍保持隐藏(euler + beta sigmas 由 `steps` 推导)。
- `Moxie MultiTrack Project Slow`(`MoxieProjectSlow`)是 Moxie 变体:参数与 `Moxie MultiTrack Project` 完全一致,但用潜空间放大替代 RTX VSR——隐藏的半分辨率一采之后,用 `models/latent_upscale_models/` 下选定的潜空间放大模型把潜空间升到最终(编辑器)尺寸,再以 2 步 euler、0.33 denoise 的隐藏二采精修;片段按项目分辨率保存,Video Combine 的 RTX 还原会直接跳过。该节点在 `audio_vae` 之后新增 `upscale_model` 下拉(默认 `minimax_h3_latent_upscaler_3d_fp16.safetensors`,列出 `models/latent_upscale_models/` 全部检查点);选 `None` 会直接报错,因为该节点始终走潜空间放大。旧工作流没有该控件时自动回落到默认检查点。二采默认启用**自动空间分块**(`tile_count=0` 表示按可用显存自动选择分块数、放得下则完全不分块),因此 1920x1080 输出在 12GB 显存及 AMD/Intel GPU 上也可运行;`upscale_model` 旁新增 `tiling` 开关(Boolean,默认 **on**)可整体关闭分块——关闭时引擎向二采注入 `{"enabled_tiling":"false","tile_count":0}`,二采改走普通 `SamplerCustomAdvanced` 一体化采样;旧工作流没有该开关时保持分块开启。分块实现只用 ComfyUI 的设备无关显存接口,不含 CUDA 专属代码(AMD/Intel 机器上 Loader 的注意力后端应选 `pytorch_attention`,INT8 注意力仅支持 Nvidia/AMD)。此外,Slow 节点隐藏一采的尺寸会在半分辨率基础上吸附到最近的 64px 网格(1080p 编辑器一采 960x512、1344x768 一采 704x384、4K 编辑器一采 1920x1088 不变),保证续接片段的 context 关键帧 latent 行列数为偶数、可被 `patchify_video` 处理(否则多片段 1080p 项目在第二段崩溃)——该吸附**仅作用于 Slow 节点**,`MultiTrack Project` 与 `Moxie MultiTrack Project` 保持认证的整数减半一采行为(如 1344x768 编辑器一采 672x384),输出尺寸不受影响。
- 编辑器分辨率是一采尺寸;`dual` 不会反算缩小一采。二采宽高分别为 `round(编辑器尺寸 * upscale_by / 32) * 32`,采用 Python `round` 就近对齐,恰好居中时取偶数,不是固定向上对齐。
- `upscale_by` 是 Project 的独立参数,默认 `1.250`,三位小数,步长 `0.001`;旧工作流保留已保存的值。两条放大路径及合并导出均使用放大并对齐后的尺寸。例如 `1344 × 768`、倍率 `1.250` 的二采为 `1664 × 960`。若用户指定最终输出尺寸,应同时核对编辑器尺寸与倍率,不能将编辑器尺寸直接当作双采样的最终尺寸。
- 单采样、仅一采预览保持编辑器尺寸;`upscale_by = 1.000` 不放大但可二采;纯音频项目(`32 × 32`)不放大。旧版反算缩小尺寸的一采检查点和上下文潜空间应重新生成后再按新规则续跑。

View File

@ -2332,9 +2332,7 @@ def test_multitrack_h3_project_expands_single_task_sampling_pipeline(monkeypatch
conditioning = nodes_by_type["easy minimaxH3ToVideo"]["inputs"]
assert conditioning["mode"] == "multi_frames"
assert conditioning["ref_image_size"] == "match"
# Certified plain-halving first pass: 1344x768 editor samples at half
# size (672x384). The even-latent snap is a Slow-node-only deviation.
assert (conditioning["width"], conditioning["height"]) == (672, 384)
assert (conditioning["width"], conditioning["height"]) == (1344, 768)
assert "SamplerCustomAdvanced" in nodes_by_type
assert "easy h3SegmentSamplingStart" in nodes_by_type
assert (
@ -2417,9 +2415,7 @@ def test_h3_sampling_preview_sampler_exposes_optional_tiling(monkeypatch):
assert inputs["enabled_tiling"].kwargs["default"] is False
assert inputs["enabled_tiling"].kwargs["optional"] is True
assert inputs["tile_count"].kwargs["default"] == 2
# 0 is allowed so engine-built graph nodes can request the automatic
# memory-based tile count (Moxie MultiTrack Project Slow bakes it).
assert inputs["tile_count"].kwargs["min"] == 0
assert inputs["tile_count"].kwargs["min"] == 2
assert inputs["tile_count"].kwargs["max"] == 8
assert inputs["preview_vae"].kwargs["optional"] is True
@ -2445,25 +2441,6 @@ def test_multitrack_project_tiles_inside_second_pass_sampler(monkeypatch):
assert not any(node["class_type"] == "easy h3TiledModel" for node in nodes)
def test_multitrack_project_passes_automatic_tile_count_to_second_pass(
monkeypatch,
):
module = _load_minimax_node(monkeypatch)
module.comfy_nodes.NODE_CLASS_MAPPINGS["ImageResizeKJv2"] = _ImageResizeKJWithNvidia
# The baked Slow form: a plain dict (no list wrapping, no DynamicCombo
# envelope) with tile_count 0 for the memory-based automatic count.
inputs = _h3_project_inputs(
sampling_mode=_h3_sampling_mode("dual"),
enabled_tiling=[{"enabled_tiling": "true", "tile_count": 0}],
)
result = module.EasyMultiTrackProject.execute(**inputs)
tiled_sampler = _graph_node(result, "easy h3SamplingPreviewSampler")
assert tiled_sampler["inputs"]["enabled_tiling"] is True
assert tiled_sampler["inputs"]["tile_count"] == 0
def test_multitrack_project_adds_preview_inputs_to_selflift_sampler(monkeypatch):
module = _load_minimax_node(monkeypatch)
module.EasyMultiTrackProject.hidden = types.SimpleNamespace(unique_id="84")
@ -6290,350 +6267,3 @@ def test_moxie_project_forwards_context_frames_to_engine(monkeypatch):
assert captured["sampling_mode"] == "single"
assert captured["sampler"] == {"sampler": "euler"}
assert captured["sigmas"].shape == (5,)
def test_moxie_project_slow_schema_mirrors_moxie_project(monkeypatch):
module = _load_moxie_project(monkeypatch)
slow = module.MoxieProjectSlow.define_schema()
base = module.MoxieProject.define_schema()
slow_inputs = {port.name: port for port in slow.inputs}
base_inputs = {port.name: port for port in base.inputs}
assert slow.node_id == "MoxieProjectSlow"
assert slow.display_name == "Moxie MultiTrack Project Slow"
assert slow.is_input_list is True
assert slow.enable_expand is True
base_names = list(base_inputs)
# The Slow node adds exactly two widgets: the upscale_model combo and
# the tiling switch, placed with the model components (after audio_vae).
assert list(slow_inputs) == (
base_names[:5] + ["upscale_model", "tiling"] + base_names[5:]
)
assert [out.name for out in slow.outputs] == [out.name for out in base.outputs]
assert "context_frames" in slow_inputs
assert slow_inputs["context_frames"].kwargs["options"] == ["5", "22", "39", "56"]
canonical = "minimax_h3_latent_upscaler_3d_fp16.safetensors"
upscale = slow_inputs["upscale_model"]
# The harness folder listing is empty, so only "None" plus the bundled
# default (always kept selectable) appear.
assert upscale.kwargs["options"] == ["None", canonical]
assert upscale.kwargs["default"] == canonical
tiling = slow_inputs["tiling"]
assert tiling.kwargs["default"] is True
assert "1920x1080" in tiling.kwargs["tooltip"]
assert "Disable" in tiling.kwargs["tooltip"]
def test_moxie_project_slow_upscale_model_lists_folder_without_duplicates(
monkeypatch,
):
module = _load_moxie_project(monkeypatch)
canonical = "minimax_h3_latent_upscaler_3d_fp16.safetensors"
monkeypatch.setattr(
module.folder_paths,
"get_filename_list",
lambda category: (
[canonical, "alt_upscaler.safetensors"]
if category == "latent_upscale_models"
else []
),
)
slow_inputs = {
port.name: port for port in module.MoxieProjectSlow.define_schema().inputs
}
assert slow_inputs["upscale_model"].kwargs["options"] == [
"None",
canonical,
"alt_upscaler.safetensors",
]
assert slow_inputs["upscale_model"].kwargs["default"] == canonical
def test_moxie_project_slow_bakes_latent_upscale_refine(monkeypatch):
module = _load_moxie_project(monkeypatch)
calls = []
def fake_calculate_sigmas(model_sampling, scheduler, steps):
calls.append((scheduler, steps))
return torch.arange(float(steps) + 7.0)
monkeypatch.setattr(
module.comfy.samplers, "calculate_sigmas", fake_calculate_sigmas
)
captured = {}
def fake_execute(cls, **kwargs):
captured.update(kwargs)
return "sentinel-output"
monkeypatch.setattr(
module.EasyMultiTrackProject, "execute", classmethod(fake_execute)
)
model = types.SimpleNamespace(
get_model_object=lambda name: f"sampling:{name}"
)
result = module.MoxieProjectSlow.execute(
tracks_info=[{"tracks": []}],
model=[model],
clip=[types.SimpleNamespace()],
video_vae=[types.SimpleNamespace()],
audio_vae=[types.SimpleNamespace()],
project_name=["demo"],
steps=["3"],
context_frames=["5"],
upscale_model=["my_upscaler.safetensors"],
tiling=[True],
seed=["7"],
)
assert result == "sentinel-output"
# Second-pass schedule runs first (Slow.execute), then the first-pass
# schedule inside MoxieProject.execute. 2 steps at denoise 0.33 must
# build the schedule at int(2 / 0.33) = 6 total steps and keep the
# last 3 sigmas (steps + 1), exactly like KSampler.set_steps.
assert calls == [
("beta", 6),
("beta", 3),
]
assert calls[0] == ("beta", 6)
assert captured["sigmas_2nd"].shape == (3,)
assert torch.equal(captured["sigmas_2nd"], torch.tensor([10.0, 11.0, 12.0]))
assert captured["sampler_2nd"] == {"sampler": "euler"}
# Baked Slow settings reach the engine.
assert captured["sampling_mode"] == "dual"
assert captured["upscale_by"] == 1.0
# The refine pass samples through automatic spatial tiling: the engine
# picks the tile count from the available memory (0) and skips tiling
# entirely when the full evaluation fits. The tiling switch is ON.
assert captured["enabled_tiling"] == {"enabled_tiling": "true", "tile_count": 0}
# The connected/picked upscale_model widget value wins over any default.
assert captured["upscale_model"] == "my_upscaler.safetensors"
assert captured["sampling_plan"] == "custom"
assert captured["disable_2nd_noise"] is False
# First pass unchanged: euler + beta from steps (3 -> 4 sigmas).
assert captured["sampler"] == {"sampler": "euler"}
assert captured["sigmas"].shape == (4,)
assert torch.equal(captured["sigmas"], torch.tensor([6.0, 7.0, 8.0, 9.0]))
assert captured["context_frames"] == ["5"]
def test_moxie_project_slow_defaults_to_bundled_upscaler(monkeypatch):
module = _load_moxie_project(monkeypatch)
captured = {}
def fake_execute(cls, **kwargs):
captured.update(kwargs)
return "sentinel-output"
monkeypatch.setattr(
module.EasyMultiTrackProject, "execute", classmethod(fake_execute)
)
model = types.SimpleNamespace(
get_model_object=lambda name: f"sampling:{name}"
)
module.MoxieProjectSlow.execute(
tracks_info=[{"tracks": []}],
model=[model],
clip=[types.SimpleNamespace()],
video_vae=[types.SimpleNamespace()],
audio_vae=[types.SimpleNamespace()],
project_name=["demo"],
steps=["3"],
context_frames=["5"],
seed=["7"],
)
# Workflows saved before the widget existed keep the bundled checkpoint.
assert (
captured["upscale_model"]
== "minimax_h3_latent_upscaler_3d_fp16.safetensors"
)
assert captured["sampling_mode"] == "dual"
assert captured["upscale_by"] == 1.0
# Workflows saved before the tiling switch existed keep tiling ON with
# the memory-adaptive automatic tile count.
assert captured["enabled_tiling"] == {"enabled_tiling": "true", "tile_count": 0}
def test_moxie_project_slow_tiling_toggle_off(monkeypatch):
module = _load_moxie_project(monkeypatch)
captured = {}
def fake_execute(cls, **kwargs):
captured.update(kwargs)
return "sentinel-output"
monkeypatch.setattr(
module.EasyMultiTrackProject, "execute", classmethod(fake_execute)
)
model = types.SimpleNamespace(
get_model_object=lambda name: f"sampling:{name}"
)
module.MoxieProjectSlow.execute(
tracks_info=[{"tracks": []}],
model=[model],
clip=[types.SimpleNamespace()],
video_vae=[types.SimpleNamespace()],
audio_vae=[types.SimpleNamespace()],
project_name=["demo"],
steps=["3"],
context_frames=["5"],
tiling=[False],
seed=["7"],
)
# The switch OFF hands the engine an explicitly disabled tiling config:
# the refine pass is then sampled in one piece (plain
# SamplerCustomAdvanced instead of the tiled preview sampler).
assert captured["enabled_tiling"] == {"enabled_tiling": "false", "tile_count": 0}
# The rest of the pipeline is untouched.
assert captured["sampling_mode"] == "dual"
assert captured["upscale_by"] == 1.0
def test_moxie_project_slow_rejects_missing_upscaler(monkeypatch):
module = _load_moxie_project(monkeypatch)
model = types.SimpleNamespace(
get_model_object=lambda name: f"sampling:{name}"
)
common = {
"tracks_info": [{"tracks": []}],
"model": [model],
"clip": [types.SimpleNamespace()],
"video_vae": [types.SimpleNamespace()],
"audio_vae": [types.SimpleNamespace()],
"project_name": ["demo"],
"steps": ["3"],
"context_frames": ["5"],
"seed": ["7"],
}
for upscale_model in (["None"], [""]):
with pytest.raises(ValueError, match="latent upscaler|latent_upscale_models"):
module.MoxieProjectSlow.execute(
upscale_model=upscale_model, **common
)
def test_moxie_project_slow_keeps_half_res_first_pass(monkeypatch):
module = _load_moxie_project(monkeypatch)
base = module.EasyMultiTrackProject
assert base._h3_first_pass_resolution_scale("single") == 0.5
assert base._h3_first_pass_resolution_scale("dual") == 1.0
assert base._h3_first_pass_resolution_scale("selflift") == 1.0
assert base._h3_first_pass_resolution_scale("passthrough") == 1.0
slow = module.MoxieProjectSlow
for mode in ("single", "dual", "selflift", "passthrough"):
assert slow._h3_first_pass_resolution_scale(mode) == 0.5
def test_h3_tiling_config_accepts_automatic_tile_count(monkeypatch):
module = _load_moxie_project(monkeypatch)
project_module = sys.modules["easy_media.nodes.project"]
config = project_module._h3_tiling_config
assert config(None) == (False, 0)
assert config("false") == (False, 0)
# Plain-string enablement keeps the historical fixed count of 2.
assert config("true") == (True, 2)
# Baked Slow settings: automatic tile count chosen from free memory.
assert config({"enabled_tiling": "true", "tile_count": 0}) == (True, 0)
# DynamicCombo widget payloads arrive with list-wrapped children.
assert config({"enabled_tiling": ["true"], "tile_count": [3]}) == (True, 3)
assert config({"enabled_tiling": "true"}) == (True, 2)
assert config({"enabled_tiling": "false", "tile_count": 0}) == (False, 0)
for bad_count in (1, -1, 9):
with pytest.raises(
ValueError, match=r"tile_count must be 0 \(automatic\) or between 2 and 8"
):
config({"enabled_tiling": "true", "tile_count": bad_count})
def test_h3_sampling_preview_sampler_keeps_certified_tile_count_schema(monkeypatch):
module = _load_moxie_project(monkeypatch)
project_module = sys.modules["easy_media.nodes.project"]
schema = project_module.EasyH3SamplingPreviewSampler.define_schema()
inputs = {port.name: port for port in schema.inputs}
# The certified widget text and default are untouched; the only widening
# is min 2 -> 0, which Moxie MultiTrack Project Slow requires because the
# engine builds this node with tile_count 0 (automatic) and ComfyUI
# validates inputs against min at execution. Certified workflows send
# 2-8 (or nothing) and validate exactly as before.
tile_count = inputs["tile_count"]
assert tile_count.kwargs["default"] == 2
assert tile_count.kwargs["min"] == 0
assert tile_count.kwargs["max"] == 8
assert tile_count.kwargs.get("tooltip") is None
def test_moxie_project_slow_snaps_first_pass_even_latent_grid_scoped_to_slow(
monkeypatch,
):
module = _load_moxie_project(monkeypatch)
snap = module._h3_even_latent_size
# Pure helper: nearest 64px multiple keeps even latent row/column counts.
assert snap(540) == 512
assert snap(672) == 704
assert snap(1080) == 1088
assert snap(384) == 384
assert snap(32) == 32
assert snap(31) == 32
assert snap(33) == 64
# Certified nodes keep the plain-halving first pass, byte for byte.
base = module.EasyMultiTrackProject
easy = module.MoxieProject
for project_class in (base, easy):
assert project_class._h3_first_pass_size(1344, 768, 0.5) == (672, 384)
assert project_class._h3_first_pass_size(1920, 1080, 0.5) == (960, 540)
assert project_class._h3_first_pass_size(3840, 2160, 0.5) == (1920, 1080)
# Only the Slow node snaps its hidden pass onto the even-latent grid.
slow = module.MoxieProjectSlow
assert slow._h3_first_pass_size(1344, 768, 0.5) == (704, 384)
assert slow._h3_first_pass_size(1920, 1080, 0.5) == (960, 512)
assert slow._h3_first_pass_size(3840, 2160, 0.5) == (1920, 1088)
# Certified upscale rule: skip exactly when the factor does not ask for
# one. Slow decides by size comparison instead (its first pass sits at
# half resolution and must always be bridged by the upscaler).
for project_class in (base, easy):
assert project_class._h3_needs_latent_upscale(False, 672, 384, 840, 480, 1.25)
assert not project_class._h3_needs_latent_upscale(False, 672, 384, 672, 384, 1.0)
assert not project_class._h3_needs_latent_upscale(True, 32, 32, 32, 32, 1.25)
assert slow._h3_needs_latent_upscale(False, 960, 512, 1920, 1080, 1.0)
assert not slow._h3_needs_latent_upscale(False, 1920, 1080, 1920, 1080, 1.0)
assert not slow._h3_needs_latent_upscale(True, 32, 32, 32, 32, 1.0)
def test_denoise_truncated_sigmas_matches_ksampler_math(monkeypatch):
module = _load_moxie_project(monkeypatch)
calls = []
def fake_calculate_sigmas(model_sampling, scheduler, steps):
calls.append((scheduler, steps))
return torch.linspace(1.0, 0.0, steps + 1)
monkeypatch.setattr(
module.comfy.samplers, "calculate_sigmas", fake_calculate_sigmas
)
sigmas = module._denoise_truncated_sigmas("ms", "beta", 2, 0.33)
assert calls == [("beta", 6)]
assert sigmas.shape == (3,)
assert sigmas[-1] == 0.0
full = module._denoise_truncated_sigmas("ms", "beta", 4, 1.0)
assert calls == [("beta", 6), ("beta", 4)]
assert full.shape == (5,)
with pytest.raises(ValueError, match="denoise must be positive"):
module._denoise_truncated_sigmas("ms", "beta", 2, 0.0)