Compare commits

...

3 Commits

Author SHA1 Message Date
Octopus
0686001f8e
Merge 7b5e2b5662 into d0f0b15cf5 2026-05-03 19:59:49 +08:00
Alexis Rolland
7b5e2b5662
Merge branch 'master' into fix/issue-13366-taesd-preview-corrupts-latent 2026-04-25 12:15:54 +08:00
octo-patch
ce6b8b72de 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.
2026-04-13 12:39:51 +08:00

View File

@ -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):