Use adaptive CUDA latent upscale chunking

This commit is contained in:
2026-09-04 12:09:59 +00:00
parent 7bb0b0abea
commit 32a16645b5
2 changed files with 29 additions and 14 deletions
+14 -10
View File
@@ -55,12 +55,16 @@ def _uses_cuda_model_upscale(param):
return device == "cuda" and (mode == "model" or has_model_name)
def _effective_temporal_params(param):
def _effective_temporal_params(param, frame_count=None):
chunk_length = int(param.get("chunk_length", 0) or 0)
temporal_overlap = int(param.get("temporal_overlap", 0) or 0)
if _uses_cuda_model_upscale(param):
chunk_length = CUDA_MODEL_CHUNK_LENGTH if chunk_length <= 0 else min(chunk_length, CUDA_MODEL_CHUNK_LENGTH)
temporal_overlap = min(max(0, temporal_overlap), max(0, chunk_length - 17))
if chunk_length <= 0:
chunk_length = 85
temporal_overlap = 17
if frame_count is not None and CUDA_MODEL_CHUNK_LENGTH < int(frame_count) <= chunk_length:
chunk_length = CUDA_MODEL_CHUNK_LENGTH
temporal_overlap = 0
return chunk_length, temporal_overlap
@@ -771,13 +775,13 @@ def upscale_video_interp(video, param):
def _upscale_video_temporal_chunks(video, param, upscaler):
if video.device.type != "cpu":
video = video.to(device="cpu", copy=True)
chunk_length, temporal_overlap = _effective_temporal_params(param)
t = int(video.shape[2])
frame_count = _frames_for_tokens(t)
chunk_length, temporal_overlap = _effective_temporal_params(param, frame_count)
chunk_param = dict(param)
chunk_param["chunk_length"] = chunk_length
chunk_param["temporal_overlap"] = temporal_overlap
anchor_strength = float(param.get("anchor_strength", 0.999) or 0.999)
t = int(video.shape[2])
frame_count = _frames_for_tokens(t)
if chunk_length <= 0 or frame_count <= chunk_length:
return upscaler(video, chunk_param)
@@ -918,10 +922,10 @@ class H3LatentUpscaleParams:
"tooltip": "Temporal fade schedule over each tile's sampling. Off keeps the fade fixed; narrowing shrinks it over steps; widening grows it over steps."}),
"dynamic_fade_min": ("INT", {"default": 32, "min": 0, "max": 4096, "step": 32,
"tooltip": "Minimum fade width used by dynamic_fade when it is enabled."}),
"chunk_length": ("INT", {"default": 17, "min": 17, "max": 100000, "step": 17,
"tooltip": "Temporal chunk length for latent upscale. CUDA model upscale is capped to 17 internally so short long-video shots do not bypass splitting and OOM."}),
"temporal_overlap": ("INT", {"default": 0, "min": 0, "max": 100000, "step": 17,
"tooltip": "Temporal overlap between latent chunks. CUDA model upscale uses 0 when capped to one H3 block to minimize peak VRAM."}),
"chunk_length": ("INT", {"default": 85, "min": 17, "max": 100000, "step": 17,
"tooltip": "Temporal chunk length for latent upscale. CUDA model upscale keeps this when it splits the shot, but uses 17/0 if this would otherwise process the whole shot as one OOM-prone batch."}),
"temporal_overlap": ("INT", {"default": 17, "min": 0, "max": 100000, "step": 17,
"tooltip": "Temporal overlap between latent chunks. 17 matches the upstream split example; CUDA model upscale drops overlap only for the emergency 17-frame guard path."}),
"resize_conditioning": ("BOOLEAN", {"default": False,
"tooltip": "Reserved for upstream split compatibility. Leave OFF unless you need the original fallback behavior."}),
"anchor_strength": ("FLOAT", {"default": 0.999, "min": 0.0, "max": 1.0, "step": 0.01,