Comfy-Org/ComfyUI · error · ValueError
Latent spatial size {latent_width}x{latent_height} must be d
Error message
Latent spatial size {latent_width}x{latent_height} must be divisible by reference_downscale_factor {latent_downscale_factor} from the IC-LoRA parameters. What it means
Raised by the LTX guide node's execute() when iclora_parameters declares reference_downscale_factor > 1 and the latent's spatial dims (latent_width x latent_height, i.e. after VAE downscaling) are not divisible by that factor. IC-LoRA reference branches need to cleanly crop/align the latent grid to the downscale factor; a non-divisible size would misalign the reference conditioning.
Source
Thrown at comfy_extras/nodes_lt.py:442
noise_mask = noise_mask.clone()
latent_image[:, :, latent_idx : latent_idx + cond_length] = guiding_latent
noise_mask[:, :, latent_idx : latent_idx + cond_length] = mask
return latent_image, noise_mask
@classmethod
def execute(cls, positive, negative, vae, latent, image, frame_idx, strength, attention_mask=None, iclora_parameters=None) -> io.NodeOutput:
scale_factors = vae.downscale_index_formula
latent_image = latent["samples"]
noise_mask = get_noise_mask(latent)
_, _, latent_length, latent_height, latent_width = latent_image.shape
latent_downscale_factor = cls.get_reference_downscale_factor(iclora_parameters)
if latent_downscale_factor > 1:
if latent_width % latent_downscale_factor != 0 or latent_height % latent_downscale_factor != 0:
raise ValueError(
f"Latent spatial size {latent_width}x{latent_height} must be divisible by "
f"reference_downscale_factor {latent_downscale_factor} from the IC-LoRA parameters."
)
# For mid-video multi-frame guides, prepend+strip a throwaway first frame so the VAE's "first latent = 1 pixel frame" asymmetry lands on the discarded slot
time_scale_factor = scale_factors[0]
num_frames_to_keep = ((image.shape[0] - 1) // time_scale_factor) * time_scale_factor + 1
resolved_frame_idx = frame_idx
if frame_idx < 0:
_, num_keyframes = get_keyframe_idxs(positive, latent_image.shape)
resolved_frame_idx = max((latent_length - num_keyframes - 1) * time_scale_factor + 1 + frame_idx, 0)
causal_fix = resolved_frame_idx == 0 or num_frames_to_keep == 1
if not causal_fix:
image = torch.cat([image[:1], image], dim=0)
image, t = cls.encode(vae, latent_width, latent_height, image, scale_factors, latent_downscale_factor)
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Round the video resolution so that (H/VAE_downscale) and (W/VAE_downscale) are divisible by reference_downscale_factor — practically, make pixel H and W divisible by vae_downscale * reference_downscale_factor.
- Or set reference_downscale_factor to 1 in the IC-LoRA parameters if the model tolerates full-res references.
- Use a resize/crop node to snap dimensions to a multiple of 32/64 before the VAE encode.
Example fix
# before video = video[:, :, :831, :] # latent height 831//32 = 25 (odd) -> raises with factor 2 # after video = video[:, :, :832, :] # latent height 26, divisible by 2
Defensive patterns
Strategy: validation
Validate before calling
latent_h, latent_w = latent["samples"].shape[3:5]
factor = get_reference_downscale_factor(iclora_parameters)
assert latent_h % factor == 0 and latent_w % factor == 0, (
f"resize video so latent dims are divisible by {factor}: currently {latent_w}x{latent_h}") Try / catch
try:
out = LTXGuide.execute(...)
except ValueError as e:
if "reference_downscale_factor" in str(e):
# snap pixel dims to a multiple of vae_downscale * factor and retry
out = LTXGuide.execute(..., image=snap_dims(image, vae_ds * factor))
else:
raise Prevention
- Choose resolutions divisible by vae_downscale * reference_downscale_factor (e.g. 64px steps).
- Read reference_downscale_factor out of the IC-LoRA metadata at workflow setup time.
- Avoid arbitrary hand-typed resolutions with IC-LoRA models.
When it happens
Trigger: Using an IC-LoRA trained with reference_downscale_factor 2 or 4 with a video whose pixel resolution yields latent dims like 65 or 63 (odd numbers after the VAE's 1/32 or 1/64 downscale); custom resolutions not aligned to factor * vae_downscale * 8 pixels.
Common situations: Hand-typed resolutions (e.g. 1216x831) with IC-LoRA models that specify a downscale factor; cropping videos to arbitrary sizes before VAE encoding.
Related errors
- Adding guide to a combined AV latent is not supported.
- audio latent {} cannot be fitted to {}
- Unsupported spatial_scale {scale}. Choose from {list(mapping
- Input audio must have {expected_channels} channels, got {wav
- SeedVR2 expected {name} to be 5-D native latent, got shape {
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/b8bbf571379f561e.
Report an issue: GitHub.