Skip to content

fix: Stop LTXVCropGuides leaving stray latent frames when guides share a start position (CORE-206)#13882

Open
drozbay wants to merge 2 commits into
Comfy-Org:masterfrom
drozbay:20260513a_ltx_keyframe_count_derivation
Open

fix: Stop LTXVCropGuides leaving stray latent frames when guides share a start position (CORE-206)#13882
drozbay wants to merge 2 commits into
Comfy-Org:masterfrom
drozbay:20260513a_ltx_keyframe_count_derivation

Conversation

@drozbay
Copy link
Copy Markdown
Contributor

@drozbay drozbay commented May 14, 2026

When two LTXVAddGuide nodes target the same starting frame, LTXVCropGuides undercounts 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

image

Before fix - Output has extra latent after incorrect CropGuide, resulting in 8 extra frames:

image

After fix - Properly trimmed latent, correct number of frames

image

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR enhances keyframe index and count computation by making it shape-aware. The utility function get_keyframe_idxs now accepts optional latent shape information and uses it to derive accurate token-per-frame counts. When shape is unavailable, it falls back to metadata from guide attention entries. All call sites in LTXVAddGuide.execute and LTXVCropGuides.execute now pass the latent image shape to enable this shape-aware behavior throughout the keyframe resolution system.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: preventing LTXVCropGuides from leaving stray latent frames when guides share a start position.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly describes the bug fix for LTXVCropGuides undercounting guide frames when multiple guides share a starting frame, with concrete examples and before/after images.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 26515ac and 09f15d8.

📒 Files selected for processing (1)
  • comfy_extras/nodes_lt.py

Comment thread comfy_extras/nodes_lt.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants