Comfy-Org/ComfyUI · error · ValueError
SeedVR2 patch input temporal size must satisfy T % {t} == 1,
Error message
SeedVR2 patch input temporal size must satisfy T % {t} == 1, got {vid.size(2)}. What it means
SeedVR2's PatchIn keeps the very first frame unpatched and patches groups of t consecutive frames (it duplicates frame 0 t-1 times before reshaping), so the input temporal length T must satisfy T % t == 1. A video whose frame count does not leave remainder 1 modulo the temporal patch size cannot be reshaped, hence the ValueError. This is an input-length contract on the video latent frames.
Source
Thrown at comfy/ldm/seedvr/model.py:951
self,
in_channels: int,
patch_size: Union[int, Tuple[int, int, int]],
dim: int,
device, dtype, operations
):
super().__init__()
t, h, w = _triple(patch_size)
self.patch_size = t, h, w
self.proj = operations.Linear(in_channels * t * h * w, dim, device=device, dtype=dtype)
def forward(
self,
vid: torch.Tensor,
) -> torch.Tensor:
t, h, w = self.patch_size
if t > 1:
if vid.size(2) % t != 1:
raise ValueError(
f"SeedVR2 patch input temporal size must satisfy T % {t} == 1, got {vid.size(2)}."
)
vid = torch.cat([vid[:, :, :1]] * (t - 1) + [vid], dim=2)
b, c, Tt, Hh, Ww = vid.shape
vid = vid.view(b, c, Tt // t, t, Hh // h, h, Ww // w, w).permute(0, 2, 4, 6, 3, 5, 7, 1).reshape(b, Tt // t, Hh // h, Ww // w, t * h * w * c)
vid = self.proj(vid)
return vid
class NaPatchIn(PatchIn):
def forward(
self,
vid: torch.Tensor, # l c
vid_shape: torch.LongTensor,
cache: Optional[Cache] = None,
) -> torch.Tensor:
if cache is None:
cache = Cache(disable=True)
cache = cache.namespace("patch")View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Adjust the frame count so T % t == 1 (for t=2 that means an odd frame count: 1, 3, 5, ...).
- Drop or duplicate trailing frames in preprocessing to reach a valid length, e.g. keep the first (T // t) * t + 1 frames.
- Check the model config's patch_size triple to learn t and validate before loading the video.
- If frames come from a VAE encode of raw video, fix the count before encoding so latent frames align.
Example fix
# before vid = load_video(path) # T=16, t=2 -> raises # after t = 2 T_valid = (vid.size(2) // t) * t + 1 # 17 -> still even split issue; instead trim to odd vid = vid[:, :, :T_valid] if T_valid <= vid.size(2) else torch.cat([vid, vid[:, :, -1:].repeat(1, 1, T_valid - vid.size(2), 1, 1)], dim=2)
Defensive patterns
Strategy: validation
Validate before calling
def validate_seedvr2_temporal(vid, patch_t):
T = vid.size(2)
if T % patch_t != 1:
target = (T // patch_t) * patch_t + 1
raise ValueError(f"frame count {T} invalid for patch_t={patch_t}; trim/pad to {target} frames")
return vid Type guard
def temporal_ok(T, t) -> bool:
return T % t == 1 Prevention
- Compute the valid frame count ((T // t) * t + 1) in preprocessing, before VAE encode.
- Read patch_size from the model config and assert the contract in pipeline code.
- Prefer trimming trailing frames over duplicating when adjusting counts.
When it happens
Trigger: Feeding SeedVR2 a video latent with a frame count that is a multiple of t (or arbitrary) — e.g. T=16 frames with temporal patch size 2 (16 % 2 == 0, not 1). Common with arbitrary frame counts produced by trimming, looping, or frame-interpolation preprocessing.
Common situations: Loading a video with an even frame count into a model with temporal patch size 2; trimming frames to a round number like 32; frame-count arithmetic in a preprocessing pipeline that ignores the model's T % t == 1 contract.
Related errors
- SeedVR2 expected {name} to be 5-D native latent, got shape {
- SeedVR2 conditioning shape must match latent batch/temporal/
- ar_video sampler requires 5-D video latents [B,C,T,H,W], got
- unknown merge strategy {self.merge_strategy}
- PixDiT_T2I requires context (text embeddings) of shape [B, L
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/54df064d16015d68.
Report an issue: GitHub.