LTXVImgToVideoConditionOnly modifies its input latent in place, so cached runs can condition on a previous prompt's image

Open Beginner friendly
#569 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start in latents.py at LTXVImgToVideoConditionOnly.generate, where samples = latent["samples"] is written in place by samples[:, :, : t.shape[2]] = t and the same tensor is returned. Confirm that the input comes from the cached EmptyLTXVLatentVideo output. To reproduce, run two i2v prompts with different images (A then B), then rerun A with a new text prompt and check that the first frame still matches A. Done when the cloned-tensor change makes that rerun start from image A and the first frame is no longer overwritten.

Written by the indexing model from the issue text.

Description

LTXVImgToVideoConditionOnly.generate in latents.py writes the encoded image into the input latent tensor in place:

samples = latent["samples"]
t = self.encode_image(image, samples.shape, vae)
# Apply encoded image to first frames
samples[:, :, : t.shape[2]] = t

and it returns that same tensor. When the input comes from EmptyLTXVLatentVideo (the usual i2v setup), ComfyUI caches that empty latent and reuses the same tensor object for every prompt with the same width, height and length. Each run of LTXVImgToVideoConditionOnly overwrites the shared cached tensor with its own first frame.

The node's own cached output holds a reference to that same tensor. So when a later prompt reuses the node's cached output (same image, same inputs, with only something downstream changed, such as the text prompt or the seed), the "conditioned" latent no longer contains that prompt's image. It contains whatever image the most recent other run wrote.

Reproduction (the same graph each time: LoadImage → resize → LTXVPreprocess → LTXVImgToVideoConditionOnly(latent = EmptyLTXVLatentVideo) → sampler):

  1. Queue a prompt with image A and text prompt P1, then let it finish.
  2. Queue a prompt with image B (and anything else), then let it finish.
  3. Queue image A again with a different text prompt, P2. The image chain is served from cache (execution_cached lists the LoadImage, preprocess and LTXVImgToVideoConditionOnly nodes).

Expected: the video in step 3 starts from image A.
Actual: the video in step 3 starts from image B. We confirmed that the LoadImage file in step 3 is image A (its hash matches), and that the step-3 video's first frame matches image B.

Fix: copy before writing, for example:

samples = latent["samples"].clone()

With that one change, the step-3 video starts from image A. We verified this on the same setup. The rest of latents.py looks fine: the other latent["samples"] use writes into a new tensor, and the AV path already clones its mask.

Environment: ComfyUI 0.28.0 (Linux, CUDA, --disable-smart-memory), ComfyUI-LTXVideo at the current master (latents.py last changed in 63a7f34e, 2026-09-17), LTX-2.3 22B fp8 distilled, i2v at 832×480, 73 frames.

Dominant language
Python
Stars
4.2k
Forks
508
Avg merge
7h 14m
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Lightricks/ComfyUI-LTXVideo

All issues in Lightricks/ComfyUI-LTXVideo

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.