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

Aperta Adatta ai principianti
#569 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia da latents.py, in LTXVImgToVideoConditionOnly.generate, dove samples = latent["samples"] viene scritto sul posto da samples[:, :, : t.shape[2]] = t e viene restituito lo stesso tensore. Verifica che l'input provenga dall'output in cache di EmptyLTXVLatentVideo. Per riprodurre, esegui due prompt i2v con immagini diverse (prima A, poi B), poi rilancia A con un nuovo prompt di testo e controlla che il primo fotogramma corrisponda ancora ad A. È completato quando la modifica con tensore clonato fa partire questo rilancio dall'immagine A e il primo fotogramma non viene più sovrascritto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
4.2k
Fork
508
Merge medio
7h 14m
PR unite (30g)
3

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Lightricks/ComfyUI-LTXVideo

Tutte le issue di Lightricks/ComfyUI-LTXVideo

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.