Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix case where pixel space VAE could cause issues. (#13030)

comfyanonymous68d542cc0602
diff --git a/comfy/sd.py b/comfy/sd.py
index 652e76d3e..df0c4d1d1 100644
--- a/comfy/sd.py
+++ b/comfy/sd.py
@@ -952,8 +952,8 @@ class VAE:
batch_number = max(1, batch_number)
for x in range(0, samples_in.shape[0], batch_number):
- samples = samples_in[x:x+batch_number].to(self.vae_dtype).to(self.device)
- out = self.process_output(self.first_stage_model.decode(samples, **vae_options).to(self.output_device).to(dtype=self.vae_output_dtype()))
+ samples = samples_in[x:x + batch_number].to(device=self.device, dtype=self.vae_dtype)
+ out = self.process_output(self.first_stage_model.decode(samples, **vae_options).to(device=self.output_device, dtype=self.vae_output_dtype(), copy=True))
if pixel_samples is None:
pixel_samples = torch.empty((samples_in.shape[0],) + tuple(out.shape[1:]), device=self.output_device, dtype=self.vae_output_dtype())
pixel_samples[x:x+batch_number] = out