mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-27 19:02:31 +08:00
fix: clone latent before TAESD preview decode to prevent corruption (fixes #13366)
The TAESD preview decoders (TAESDPreviewerImpl and TAEHVPreviewerImpl) were passing tensor views (slices) of x0 directly to the decoder. This allowed the decoder's internal operations to potentially modify the original latent in-place, corrupting the midsampling latent. The fix clones the sliced tensor before passing it to the decoder, ensuring the original x0 is never affected by any in-place operations within the preview decode path. This specifically addresses the case where lighttaew2_1.safetensors (WanVAE) is used as the TAESD preview decoder for models using the Wan21 latent format (e.g., QwenImage), where the full VAE decode pipeline could write back to the input slice.
This commit is contained in:
parent
c2657d5fb9
commit
ce6b8b72de
@ -41,12 +41,14 @@ class TAESDPreviewerImpl(LatentPreviewer):
|
||||
self.taesd = taesd
|
||||
|
||||
def decode_latent_to_preview(self, x0):
|
||||
x_sample = self.taesd.decode(x0[:1])[0].movedim(0, 2)
|
||||
# Clone to prevent the decoder from modifying the latent in-place
|
||||
x_sample = self.taesd.decode(x0[:1].clone())[0].movedim(0, 2)
|
||||
return preview_to_image(x_sample)
|
||||
|
||||
class TAEHVPreviewerImpl(TAESDPreviewerImpl):
|
||||
def decode_latent_to_preview(self, x0):
|
||||
x_sample = self.taesd.decode(x0[:1, :, :1])[0][0]
|
||||
# Clone to prevent the decoder from modifying the latent in-place
|
||||
x_sample = self.taesd.decode(x0[:1, :, :1].clone())[0][0]
|
||||
return preview_to_image(x_sample, do_scale=False)
|
||||
|
||||
class Latent2RGBPreviewer(LatentPreviewer):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user