Log H3 latent upscale tiling plan

This commit is contained in:
2026-09-04 14:14:24 +00:00
parent 32a16645b5
commit 49e099ee7f
2 changed files with 45 additions and 0 deletions
+40
View File
@@ -2,6 +2,7 @@ from contextlib import contextmanager
from functools import lru_cache
import gc
import glob
import logging
import math
import os
import re
@@ -41,6 +42,7 @@ LATENTS_STD = [
]
_LATENT_UPSCALE_FOLDER = "latent_upscale_models"
LOGGER = logging.getLogger(__name__)
MP_UNIT = 1024 * 1024
RES_MULTIPLE = 32
CUDA_MODEL_CHUNK_LENGTH = 17
@@ -645,6 +647,14 @@ def upscale_video_model(video, param):
"H3 latent upscale exhausted its GPU spatial fallbacks. "
"Reduce the target size, tile size, or split the shot earlier."
) from exc
LOGGER.info(
"H3 latent upscale model OOM: retrying with tile_size_mode=%s rows=%s cols=%s tile=%sx%s",
smaller.get("tile_size_mode"),
smaller.get("grid_rows"),
smaller.get("grid_cols"),
smaller.get("tile_width"),
smaller.get("tile_height"),
)
try:
gc.collect()
except Exception:
@@ -705,12 +715,22 @@ def _upscale_video_model_tiled(video, param):
# If the requested tile is not smaller than the target on either axis,
# the tiled path would just duplicate work.
if len(rows) == 1 and len(cols) == 1:
LOGGER.info(
"H3 latent upscale model: single core pass, tokens=%s target=%sx%s",
int(video.shape[2]), w_out, h_out,
)
return _upscale_video_model_core(video, param)
scale_h = h_out / float(h_in)
scale_w = w_out / float(w_in)
orig_dtype = video.dtype
out = torch.zeros((video.shape[0], video.shape[1], video.shape[2], h_out, w_out), device="cpu", dtype=orig_dtype)
LOGGER.info(
"H3 latent upscale model: %s spatial tiles, tokens=%s target=%sx%s tile_mode=%s tile=%sx%s overlap=%sx%s",
len(rows) * len(cols), int(video.shape[2]), w_out, h_out, mode, tile_w, tile_h,
spatial_w_overlap if mode == "rows_cols" else overlap,
spatial_h_overlap if mode == "rows_cols" else overlap,
)
for i, r0 in enumerate(rows):
tr = trows[i]
@@ -783,17 +803,33 @@ def _upscale_video_temporal_chunks(video, param, upscaler):
chunk_param["temporal_overlap"] = temporal_overlap
anchor_strength = float(param.get("anchor_strength", 0.999) or 0.999)
if chunk_length <= 0 or frame_count <= chunk_length:
LOGGER.info(
"H3 latent upscale: single temporal chunk, tokens=%s frames=%s chunk_length=%s overlap=%s",
t, frame_count, chunk_length, temporal_overlap,
)
return upscaler(video, chunk_param)
bounds = _temporal_segments(t, chunk_length, temporal_overlap)
if len(bounds) <= 1:
LOGGER.info(
"H3 latent upscale: single temporal segment, tokens=%s frames=%s chunk_length=%s overlap=%s",
t, frame_count, chunk_length, temporal_overlap,
)
return upscaler(video, chunk_param)
orig_dtype = video.dtype
out = None
out_h = out_w = None
LOGGER.info(
"H3 latent upscale: %s temporal chunks, tokens=%s frames=%s chunk_length=%s overlap=%s",
len(bounds), t, frame_count, chunk_length, temporal_overlap,
)
for i, (k0, f0, k1, f1) in enumerate(bounds):
chunk = video[:, :, k0:k1].contiguous()
LOGGER.info(
"H3 latent upscale: temporal chunk %s/%s tokens %s:%s frames %s:%s",
i + 1, len(bounds), k0, k1, f0, f1,
)
try:
chunk_out, chunk_h, chunk_w = upscaler(chunk, chunk_param)
except RuntimeError as exc:
@@ -802,6 +838,10 @@ def _upscale_video_temporal_chunks(video, param, upscaler):
smaller = _shrink_temporal_param(chunk_param)
if smaller is None:
raise
LOGGER.info(
"H3 latent upscale temporal OOM: retrying with chunk_length=%s overlap=%s",
smaller.get("chunk_length"), smaller.get("temporal_overlap"),
)
try:
gc.collect()
except Exception:
+5
View File
@@ -6811,6 +6811,11 @@ class H3LongVideos:
rows, cols, trows, tcols, row_ovl, col_ovl = compute_spatial_grid(
int(up_h), int(up_w), tile_th, tile_tw, ol_th, ol_tw, min_tile_tw, min_tile_tw
)
logging.info(
"H3 latent refine: %s spatial sampler tiles, target=%sx%s tile_mode=%s tile=%sx%s overlap=%sx%s",
len(rows) * len(cols), target_w, target_h, tile_size_mode, tile_w_px, tile_h_px,
spatial_w_overlap_px, spatial_h_overlap_px,
)
if len(rows) == 1 and len(cols) == 1:
(refined_out,) = nodes.common_ksampler(
model, seed, refine_steps, cfg, refine_sampler, refine_scheduler, upscale_cond, negative, upscale_latent,