Fix: clone latent samples in LTXVImgToVideoConditionOnly to prevent in-place mutation across list/batch execution - #552
Open
kb999-coder wants to merge 1 commit into
Conversation
…n-place mutation of cached tensor across list iterations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug: In-place mutation of shared latent tensor breaks batch/list execution
Description
LTXVImgToVideoConditionOnly.generate()mutates the input latent tensor in place instead of cloning it first:When this node is used inside a ComfyUI list-based batch workflow (e.g. generating one video per image from a folder via
Image Batch to Image List), thelatentinput typically comes fromEmptyLTXVLatentVideo. Since that node's inputs (width,height,length,batch_size) are fixed values — not part of the list — ComfyUI executes it only once and caches its output. The same tensor object is then reused across every iteration of the list.Because
LTXVImgToVideoConditionOnlywrites into this shared tensor instead of a copy, each iteration overwrites the data written by the previous one. The net effect: every generated video ends up conditioned on the last image in the batch, regardless of which image was actually passed to that iteration — even though upstream nodes (image loading, preprocessing, sampler) all execute correctly and independently per list item.How to reproduce
Load Images (Path)→Image Batch to Image List→ (resize/preprocess) →LTXV Img To Video Condition Only→ sampler → VAE decode → Save Video, withlatentfed by a singleEmptyLTXVLatentVideonode.Fix
Clone the tensor before writing to it:
This is a minimal, side-effect-free change: it only adds a copy before the in-place write, with no impact on single-image (non-list) usage, and negligible performance cost.
Testing
Verified locally: after applying
.clone(), running the same batch workflow with 2–3 images now produces distinct output videos, each correctly conditioned on its corresponding source image.Generated with Claude