feat: add a tiling on/off switch to Moxie MultiTrack Project Slow

Tiling stops being a baked setting and becomes a widget: the new Boolean
tiling switch next to upscale_model (default on) turns the memory-adaptive
spatial tiles of the 2-step refine pass off, so the pass can be sampled in
one piece on machines that prefer the pre-tiling behaviour.

- OFF injects {enabled_tiling: "false", tile_count: 0}; the engine then
  builds the plain SamplerCustomAdvanced second pass instead of the tiled
  preview sampler
- ON keeps tile_count 0 (automatic): the engine picks the tile count from
  the available accelerator memory and skips tiling when the full
  evaluation fits, keeping 1920x1080 within reach of 12 GB and AMD/Intel
  GPUs
- workflows saved before the switch existed keep tiling on
- tests: schema slot order + defaults, switch ON/OFF passthrough, legacy
  fallback; docs: CHANGELOG + multitrack-schema reference
This commit is contained in:
Z User 2026-10-15 00:43:30 +00:00
parent ce03875c69
commit 68d30bd69a
4 changed files with 98 additions and 14 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). 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**: 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.
- **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.

View File

@ -41,18 +41,32 @@ SLOW_SECOND_PASS_DENOISE = 0.33
# 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: the Slow node exposes an upscale_model widget instead.
# NOT baked and neither is tiling: the Slow node exposes the
# upscale_model widget and the tiling toggle instead.
"upscale_by": 1.0,
"enabled_tiling": SLOW_TILING_SETTINGS,
}
_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 _require_moxie_components(model, clip, video_vae, audio_vae) -> None:
missing = [
name
@ -225,9 +239,11 @@ class MoxieProjectSlow(MoxieProject):
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. Segments are saved at
the project resolution, so the Video Combine RTX restore passes through
untouched - no NVIDIA RTX VSR is used anywhere.
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. Segments are saved at the project resolution, so the Video
Combine RTX restore passes through untouched - no NVIDIA RTX VSR is
used anywhere.
"""
@classmethod
@ -254,14 +270,26 @@ class MoxieProjectSlow(MoxieProject):
"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 comes from the upscale_model widget.
# 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
@ -288,7 +316,8 @@ class MoxieProjectSlow(MoxieProject):
"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); set only steps and seed."
"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,
@ -327,8 +356,16 @@ class MoxieProjectSlow(MoxieProject):
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

@ -268,7 +268,7 @@ 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` 会直接报错,因为该节点始终走潜空间放大。旧工作流没有该控件时自动回落到默认检查点。二采默认启用**自动空间分块**(烘焙 `enabled_tiling={"enabled_tiling":"true","tile_count":0}`,`tile_count=0` 表示按可用显存自动选择分块数、放得下则完全不分块),因此 1920x1080 输出在 12GB 显存及 AMD/Intel GPU 上也可运行;分块实现只用 ComfyUI 的设备无关显存接口,不含 CUDA 专属代码(AMD/Intel 机器上 Loader 的注意力后端应选 `pytorch_attention`,INT8 注意力仅支持 Nvidia/AMD)。
- `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)。
- 编辑器分辨率是一采尺寸;`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

@ -6302,9 +6302,11 @@ def test_moxie_project_slow_schema_mirrors_moxie_project(monkeypatch):
assert slow.is_input_list is True
assert slow.enable_expand is True
base_names = list(base_inputs)
# The Slow node adds exactly one widget: the upscale_model combo, placed
# with the model components (after audio_vae).
assert list(slow_inputs) == base_names[:5] + ["upscale_model"] + base_names[5:]
# 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"]
@ -6314,6 +6316,10 @@ def test_moxie_project_slow_schema_mirrors_moxie_project(monkeypatch):
# 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(
@ -6377,6 +6383,7 @@ def test_moxie_project_slow_bakes_latent_upscale_refine(monkeypatch):
steps=["3"],
context_frames=["5"],
upscale_model=["my_upscaler.safetensors"],
tiling=[True],
seed=["7"],
)
@ -6398,7 +6405,7 @@ def test_moxie_project_slow_bakes_latent_upscale_refine(monkeypatch):
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.
# 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"
@ -6445,6 +6452,46 @@ def test_moxie_project_slow_defaults_to_bundled_upscaler(monkeypatch):
)
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):