fix: Stop LTXVCropGuides leaving stray latent frames when guides share a start position (CORE-206)#13882
Conversation
…e a start position
📝 WalkthroughWalkthroughThis PR enhances keyframe index and count computation by making it shape-aware. The utility function 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_extras/nodes_lt.py`:
- Around line 195-198: The current code assumes every item in
conditioning_get_any_value(cond, "guide_attention_entries", None) has a
"latent_shape" key which can raise KeyError and skip the fallback; update the
parsing to only include entries that have a valid "latent_shape" (e.g.,
"latent_shape" in e and e["latent_shape"] and isinstance(e["latent_shape"][0],
int)) when computing num_keyframes, compute num_keyframes =
sum(e["latent_shape"][0] for e in entries_filtered), and only return
keyframe_idxs, num_keyframes if that sum is > 0 (otherwise do not return so the
original fallback behavior continues). Ensure you reference
conditioning_get_any_value, guide_attention_entries, latent_shape, keyframe_idxs
and num_keyframes in your change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d6a7e0fc-34d8-4b26-afb6-8fdea6e62f89
📒 Files selected for processing (1)
comfy_extras/nodes_lt.py
When two
LTXVAddGuidenodes target the same starting frame,LTXVCropGuidesundercounts the guide frames it added and leaves one stray latent frame behind. That frame decodes as a visible artifact at the end of the generated video.Here is an example workflow to show this. The input latent has 17 frames and 2 LTXVAddGuide nodes, both adding a single image to index 0.
droz_CORE206_guide_frame_miscount_example2.json
Before fix - Output has extra latent after incorrect CropGuide, resulting in 8 extra frames:
After fix - Properly trimmed latent, correct number of frames
The CropGuides cleanup step was counting guide frames by looking at distinct starting positions in the conditioning. That works as long as no two guides share a start, but undercounts as soon as they do. The fix uses token data instead, which doesn't have that ambiguity, and threads the count to the three places that consume it.
I think that the bug has been around since LTXV 0.9.5 in March 2025. It just doesn't surface unless guides overlap on a starting frame.