Comfy-Org/ComfyUI · error · ValueError
The generated keyframes were recorded at {generated_keyframe
Error message
The generated keyframes were recorded at {generated_keyframes['tokens_per_frame']} tokens per latent frame but this latent has {tokens_per_frame}. Separate the generated keyframes before upscaling the latent. What it means
generated_keyframes carries the tokens_per_frame it was recorded with; when the current latent's tokens_per_latent_frame differs (different spatial resolution), the frame-slot boolean built from it would mark wrong token ranges, so the model refuses. Same family as errors 174/175: keyframe bookkeeping is resolution-bound.
Source
Thrown at comfy/ldm/lightricks/model.py:1202
return (orig_shape[3] // patch_size[1]) * (orig_shape[4] // patch_size[2])
def keyframes_abs_pos_mask(self, pixel_coords, orig_shape, grid_mask, num_guide_tokens, generated_keyframes):
"""Per-token mask selecting the latents that encode a single standalone pixel frame.
Returns a (batch, tokens) boolean mask over the already grid-filtered token sequence.
"""
temporal_start = pixel_coords[:, 0]
if temporal_start.ndim == 3: # (batch, tokens, [start, end])
temporal_start = temporal_start[..., 0]
mask = temporal_start == 0
if num_guide_tokens > 0:
mask[:, -num_guide_tokens:] = False
if generated_keyframes is not None:
# The temporal patch size is always 1, so one latent frame is one row of tokens.
tokens_per_frame = self.tokens_per_latent_frame(orig_shape)
if generated_keyframes["tokens_per_frame"] != tokens_per_frame:
raise ValueError(
f"The generated keyframes were recorded at {generated_keyframes['tokens_per_frame']} tokens "
f"per latent frame but this latent has {tokens_per_frame}. Separate the generated keyframes "
"before upscaling the latent."
)
first_token = generated_keyframes["first_latent_frame"] * tokens_per_frame
num_slot_tokens = generated_keyframes["num_keyframes"] * tokens_per_frame
slots = torch.zeros(orig_shape[2] * tokens_per_frame, dtype=torch.bool, device=mask.device)
slots[first_token:first_token + num_slot_tokens] = True
if grid_mask is not None:
slots = slots[grid_mask]
mask = mask | slots
return mask
def apply_keyframes_abs_pos_embedding(self, x, pixel_coords, orig_shape, grid_mask, num_guide_tokens, generated_keyframes):
"""Add the learned keyframe marker to the single-pixel-frame tokens.
A no-op for every checkpoint built without the parameter.View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Remove generated_keyframes (separate them) before the upscaling sampling pass
- Or regenerate the generated_keyframes dict against the upscaled latent's resolution, with first_latent_frame/num_keyframes recomputed
- Keep a single resolution for the whole keyframe-conditioned chain
Defensive patterns
Strategy: validation
Validate before calling
tpf = model.tokens_per_latent_frame(orig_shape) assert generated_keyframes['tokens_per_frame'] == tpf, (generated_keyframes['tokens_per_frame'], tpf)
Prevention
- Drop generated_keyframes when crossing a resolution boundary (upscaling)
- Recompute keyframe bookkeeping if you deliberately re-res guides
When it happens
Trigger: Passing generated_keyframes from a base-resolution pass into an upsampled pass where each latent frame has 4x the tokens (2x spatial upscale).
Common situations: LTX upscale pipelines that keep generated-keyframe conditioning wired across the resolution boundary.
Related errors
- keyframe_idxs holds {keyframe_idxs.shape[2]} tokens, which i
- Either spatial_upsample or temporal_upsample must be True
- guide pre_filter_counts ({total_pfc}) != keyframe grid mask
- Unrecognized interpolation method '{method}'.
- DurationHead requires at least one of video_tokens / audio_t
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/257bb2d4c7b646e0.
Report an issue: GitHub.