Add per-clip tiled latent upscale node
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-10-14 14:21:23 +00:00
parent 5a9ef64f0e
commit 92f6ab860d
6 changed files with 409 additions and 7 deletions
+10
View File
@@ -0,0 +1,10 @@
# Dumas fork notice
This repository is a personal fork of
`ukr8b3g-cmyk/ComfyUI-H3-Continuum`, retaining its upstream license and
attribution. The fork adds the `H3 Continuum Tiled Latent Upscale (Per Clip)`
node and changes package metadata to identify the Dumas repository.
The added node is intentionally an adapter around ComfyUI's installed native
`MMH3UltimateUpscale` node. It does not redistribute model weights or copy the
upstream model implementation.
+17 -1
View File
@@ -1,4 +1,20 @@
# ComfyUI-H3-Continuum 3.9.4 — V3.9
# ComfyUI-H3-Continuum-Tiled 3.9.4.post1 — V3.9 fork
## Dumas per-clip tiled latent upscale
This fork adds **H3 Continuum Tiled Latent Upscale (Per Clip)**. Connect the
`video_latents` list from a Continuum sampler, the same model/conditioning,
and the native `MMH3 Latent Upscale` and `MMH3 Spatial Split Params` nodes.
Each physical clip is sent through `MMH3UltimateUpscale` independently, with
its own upscale sampler, scheduler, steps, denoise, CFG and seed controls.
The result remains a LATENT list, so clips do not get concatenated into one
larger VRAM allocation before the tiled pass. Temporal length is validated and
cannot silently change.
The node is an adapter around ComfyUI's native MiniMax H3 tiled-upscale
implementation; it does not include model weights or vendor the upstream
implementation. Install this repository as a normal custom-node folder and
restart ComfyUI after updating it.
**Latest package: 3.9.4.** Use the fixed-version GitHub downloads below. Registry publication is verified separately.
+11
View File
@@ -440,6 +440,14 @@ from .v3.latent_resize_nodes import (
NODE_CLASS_MAPPINGS.update(V35_RESIZE_NODE_CLASS_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(V35_RESIZE_NODE_DISPLAY_NAME_MAPPINGS)
from .v3.tiled_latent_upscale_nodes import (
NODE_CLASS_MAPPINGS as TILED_UPSCALE_NODE_CLASS_MAPPINGS,
NODE_DISPLAY_NAME_MAPPINGS as TILED_UPSCALE_NODE_DISPLAY_NAME_MAPPINGS,
)
NODE_CLASS_MAPPINGS.update(TILED_UPSCALE_NODE_CLASS_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(TILED_UPSCALE_NODE_DISPLAY_NAME_MAPPINGS)
from .v3.hires_fix_nodes import (
NODE_CLASS_MAPPINGS as V35_HIRES_FIX_NODE_CLASS_MAPPINGS,
NODE_DISPLAY_NAME_MAPPINGS as V35_HIRES_FIX_NODE_DISPLAY_NAME_MAPPINGS,
@@ -473,6 +481,9 @@ _PUBLIC_NODE_DISPLAY_NAMES = {
"H3ContinuumVideoAdapter": "H3 Continuum Video Adapter",
"H3ContinuumSecondPassV35": "H3 Continuum Second Pass",
"H3DecodeCacheHelper": "Decode Cache Helper",
"H3ContinuumTiledLatentUpscalePerClip": (
"H3 Continuum Tiled Latent Upscale (Per Clip)"
),
}
NODE_CLASS_MAPPINGS = {
node_id: NODE_CLASS_MAPPINGS[node_id]
+6 -6
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-h3-continuum"
version = "3.9.4"
description = "Integrated N-chunk continuation for ComfyUI native MiniMax H3 video and audio"
name = "comfyui-h3-continuum-dumas"
version = "3.9.4.post1"
description = "H3 Continuum fork with per-clip tiled latent upscaling"
readme = "README.md"
requires-python = ">=3.10"
license = { file = "LICENSE" }
@@ -10,9 +10,9 @@ dependencies = []
keywords = ["comfyui", "minimax-h3", "video", "audio", "continuation"]
[project.urls]
Repository = "https://github.com/ukr8b3g-cmyk/ComfyUI-H3-Continuum"
Repository = "https://git.dumas.ddns.net/chris.dumas/ComfyUI-H3-Continuum-Tiled"
[tool.comfy]
PublisherId = "ukr8b3g-cmyk"
DisplayName = "H3 Continuum"
PublisherId = "chris.dumas"
DisplayName = "H3 Continuum Tiled"
requires-comfyui = ">=0.32.0"
+105
View File
@@ -0,0 +1,105 @@
import importlib.util
import pathlib
import unittest
MODULE_PATH = pathlib.Path(__file__).parents[1] / "v3" / "tiled_latent_upscale_nodes.py"
SPEC = importlib.util.spec_from_file_location("h3_tiled_test", MODULE_PATH)
MODULE = importlib.util.module_from_spec(SPEC)
assert SPEC.loader is not None
SPEC.loader.exec_module(MODULE)
class FakeSamples:
def __init__(self, shape):
self.shape = shape
self.ndim = len(shape)
class FakeNoise:
def get_noise(self, seed):
return ("noise", seed)
class FakeSampler:
def get_sampler(self, name):
return ("sampler", name)
class FakeScheduler:
def get_sigmas(self, model, scheduler, steps, denoise):
return ("sigmas", scheduler, steps, denoise)
class FakeUpscale:
calls = []
def upscale(self, **kwargs):
self.calls.append(kwargs)
source = kwargs["latent"]["samples"]
_, _, frames, height, width = source.shape
return ({"samples": FakeSamples((1, 16, frames, height * 2, width * 2))},)
class TiledUpscaleTests(unittest.TestCase):
def setUp(self):
self.original = MODULE._native_node
FakeUpscale.calls = []
MODULE._native_node = lambda name: {
"MMH3UltimateUpscale": FakeUpscale,
"RandomNoise": FakeNoise,
"KSamplerSelect": FakeSampler,
"BasicScheduler": FakeScheduler,
}.get(name)
def tearDown(self):
MODULE._native_node = self.original
def test_each_clip_is_upscaled_independently(self):
node = MODULE.H3ContinuumTiledLatentUpscalePerClip()
clips = [
{"samples": FakeSamples((1, 16, 85, 48, 84))},
{"samples": FakeSamples((1, 16, 141, 48, 84))},
]
outputs, report = node.upscale(
["model"],
["conditioning"],
clips,
["upscale"],
["spatial"],
["euler"],
["simple"],
[3],
[0.2],
[1.0],
[100],
)
self.assertEqual(len(outputs), 2)
self.assertEqual([call["latent"] for call in FakeUpscale.calls], clips)
self.assertEqual([call["noise"] for call in FakeUpscale.calls], [("noise", 100), ("noise", 101)])
self.assertIn("clips=2", report)
def test_rejects_temporal_resize(self):
class BadUpscale(FakeUpscale):
def upscale(self, **kwargs):
source = kwargs["latent"]["samples"]
return ({"samples": FakeSamples((1, 16, source.shape[2] + 1, 96, 168))},)
MODULE._native_node = lambda name: {
"MMH3UltimateUpscale": BadUpscale,
"RandomNoise": FakeNoise,
"KSamplerSelect": FakeSampler,
"BasicScheduler": FakeScheduler,
}.get(name)
node = MODULE.H3ContinuumTiledLatentUpscalePerClip()
with self.assertRaisesRegex(RuntimeError, "temporal length"):
node.upscale(
["model"], ["conditioning"],
[{"samples": FakeSamples((1, 16, 85, 48, 84))}],
["upscale"], ["spatial"], ["euler"], ["simple"],
[3], [0.2], [1.0], [100],
)
if __name__ == "__main__":
unittest.main()
+260
View File
@@ -0,0 +1,260 @@
"""Per-clip tiled latent upscaling for MiniMax H3 Continuum.
Continuum exposes physical video groups as a LATENT list. The native
``MMH3UltimateUpscale`` node operates on one H3 latent at a time, so this
adapter deliberately applies it independently to each physical clip instead
of concatenating the clips into one larger VRAM allocation.
"""
from __future__ import annotations
from typing import Any
def _sampler_options() -> list[str]:
try:
import comfy.samplers
return list(comfy.samplers.KSampler.SAMPLERS)
except Exception: # pragma: no cover - exercised on a ComfyUI host
return ["euler", "euler_ancestral", "res_multistep", "sa_solver"]
def _scheduler_options() -> list[str]:
try:
import comfy.samplers
return list(comfy.samplers.KSampler.SCHEDULERS)
except Exception: # pragma: no cover - exercised on a ComfyUI host
return ["simple", "beta", "sgm_uniform", "karras", "exponential"]
def _native_node(name: str):
try:
import nodes
return (getattr(nodes, "NODE_CLASS_MAPPINGS", {}) or {}).get(name)
except Exception:
return None
def _one(value: Any, name: str) -> Any:
"""Unwrap ComfyUI list inputs while rejecting ambiguous values."""
if isinstance(value, list):
if len(value) != 1:
raise ValueError(f"{name} must contain one shared value")
return value[0]
return value
def _clips(value: Any) -> list[Any]:
if isinstance(value, list):
return value
return [value]
def _per_clip(value: Any, count: int, name: str) -> list[Any]:
values = _clips(value)
if len(values) == 1:
return values * count
if len(values) != count:
raise ValueError(f"{name} has {len(values)} values for {count} clips")
return values
class H3ContinuumTiledLatentUpscalePerClip:
"""Upscale each Continuum physical clip separately with tiled H3 latent work.
This is intentionally a thin adapter around ComfyUI's native
``MMH3UltimateUpscale`` implementation. It does not vendor or replace
the model-specific implementation; it only supplies an independent
sampler/scheduler/noise/CFG schedule for each clip and preserves list
boundaries so clips never become one oversized VRAM job.
"""
DESCRIPTION = (
"Apply native MiniMax H3 tiled latent upscaling independently to every "
"Continuum physical clip. Clips remain separate LATENT list items."
)
SEARCH_ALIASES = [
"H3 tiled upscale per clip",
"MiniMax H3 clip upscale",
"Continuum latent upscale",
]
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"model": ("MODEL",),
"conditioning": ("CONDITIONING",),
"video_latents": ("LATENT",),
"latent_upscale_param": ("H3_UPSCALE_PARAM",),
"spatial_split_param": ("H3_SPATIAL_PARAM",),
"upscale_sampler": (
_sampler_options(),
{"default": "euler_ancestral"},
),
"upscale_scheduler": (
_scheduler_options(),
{"default": "simple"},
),
"upscale_steps": ("INT", {"default": 3, "min": 1, "max": 50}),
"upscale_denoise": (
"FLOAT",
{"default": 0.2, "min": 0.0, "max": 1.0, "step": 0.01},
),
"upscale_cfg": (
"FLOAT",
{"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1},
),
"upscale_noise_seed": (
"INT",
{
"default": 363742558835919,
"min": 0,
"max": 0xFFFFFFFFFFFFFFFF,
"control_after_generate": True,
},
),
},
"optional": {
"negative": ("CONDITIONING",),
"temporal_split_param": ("H3_TEMPORAL_PARAM",),
"upscale_sigmas": ("SIGMAS",),
},
}
INPUT_IS_LIST = True
RETURN_TYPES = ("LATENT", "STRING")
RETURN_NAMES = ("upscaled_video_latents", "report")
OUTPUT_IS_LIST = (True, False)
FUNCTION = "upscale"
CATEGORY = "MiniMax H3/Continuum/Upscale"
def upscale(
self,
model,
conditioning,
video_latents,
latent_upscale_param,
spatial_split_param,
upscale_sampler,
upscale_scheduler,
upscale_steps,
upscale_denoise,
upscale_cfg,
upscale_noise_seed,
negative=None,
temporal_split_param=None,
upscale_sigmas=None,
):
native = _native_node("MMH3UltimateUpscale")
random_noise = _native_node("RandomNoise")
sampler_select = _native_node("KSamplerSelect")
scheduler = _native_node("BasicScheduler")
missing = [
name
for name, value in (
("MMH3UltimateUpscale", native),
("RandomNoise", random_noise),
("KSamplerSelect", sampler_select),
("BasicScheduler", scheduler),
)
if value is None
]
if missing:
raise RuntimeError("Missing native ComfyUI nodes: " + ", ".join(missing))
latents = _clips(video_latents)
if not latents:
raise ValueError("video_latents must contain at least one clip")
models = _per_clip(model, len(latents), "model")
conditionings = _per_clip(conditioning, len(latents), "conditioning")
negatives = (
[None] * len(latents)
if negative is None
else _per_clip(negative, len(latents), "negative")
)
temporal = (
[None] * len(latents)
if temporal_split_param is None
else _per_clip(temporal_split_param, len(latents), "temporal_split_param")
)
sigma_values = (
[None] * len(latents)
if upscale_sigmas is None
else _per_clip(upscale_sigmas, len(latents), "upscale_sigmas")
)
sampler_name = str(_one(upscale_sampler, "upscale_sampler"))
scheduler_name = str(_one(upscale_scheduler, "upscale_scheduler"))
steps = int(_one(upscale_steps, "upscale_steps"))
denoise = float(_one(upscale_denoise, "upscale_denoise"))
cfg = float(_one(upscale_cfg, "upscale_cfg"))
seed = int(_one(upscale_noise_seed, "upscale_noise_seed"))
upscale_param = _one(latent_upscale_param, "latent_upscale_param")
spatial_param = _one(spatial_split_param, "spatial_split_param")
outputs = []
reports = []
for index, (clip_latent, clip_model, clip_conditioning) in enumerate(
zip(latents, models, conditionings), start=1
):
samples = clip_latent.get("samples") if isinstance(clip_latent, dict) else None
if samples is None or getattr(samples, "ndim", None) != 5:
raise ValueError(f"clip {index} is not a 5-D H3 LATENT")
noise = random_noise().get_noise(seed + index - 1)
sampler = sampler_select().get_sampler(sampler_name)
sigmas = sigma_values[index - 1]
if sigmas is None:
sigmas = scheduler().get_sigmas(
clip_model, scheduler_name, steps, denoise
)
kwargs = {
"model": clip_model,
"conditioning": clip_conditioning,
"latent": clip_latent,
"noise": noise,
"sampler": sampler,
"sigmas": sigmas,
"cfg": cfg,
"latent_upscale_param": upscale_param,
"temporal_split_param": temporal[index - 1],
"spatial_split_param": spatial_param,
}
if negatives[index - 1] is not None:
kwargs["negative"] = negatives[index - 1]
result = native().upscale(**kwargs)
if not isinstance(result, (tuple, list)) or not result:
raise RuntimeError(f"native upscale returned no output for clip {index}")
output = result[0]
output_samples = output.get("samples") if isinstance(output, dict) else None
if output_samples is None or output_samples.ndim != 5:
raise RuntimeError(f"native upscale returned an invalid clip {index}")
if output_samples.shape[2] != samples.shape[2]:
raise RuntimeError(f"tiled upscale changed temporal length for clip {index}")
outputs.append(output)
reports.append(
f"clip {index}: {tuple(samples.shape)} -> {tuple(output_samples.shape)}"
)
return (
outputs,
"H3 Continuum per-clip tiled upscale; "
f"clips={len(outputs)}, sampler={sampler_name}, scheduler={scheduler_name}, "
f"steps={steps}, denoise={denoise:g}, cfg={cfg:g}, seed_base={seed}; "
+ "; ".join(reports),
)
NODE_CLASS_MAPPINGS = {
"H3ContinuumTiledLatentUpscalePerClip": H3ContinuumTiledLatentUpscalePerClip,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"H3ContinuumTiledLatentUpscalePerClip": (
"H3 Continuum Tiled Latent Upscale (Per Clip)"
),
}