From d2191678490d61103cda69892115a09ff7ae6584 Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Wed, 13 Sep 2023 09:40:06 -0700 Subject: [PATCH] fix(latent): remove temporary workaround for lack of TAESD tiling support. Now available in diffusers 0.21: https://github.com/huggingface/diffusers/pull/4627 --- invokeai/app/invocations/latent.py | 35 +++++++----------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/invokeai/app/invocations/latent.py b/invokeai/app/invocations/latent.py index 6a07891a74..71670d37e1 100644 --- a/invokeai/app/invocations/latent.py +++ b/invokeai/app/invocations/latent.py @@ -48,7 +48,6 @@ from ...backend.stable_diffusion.diffusers_pipeline import ( from ...backend.stable_diffusion.diffusion.shared_invokeai_diffusion import PostprocessingSettings from ...backend.stable_diffusion.schedulers import SCHEDULER_MAP from ...backend.util.devices import choose_precision, choose_torch_device -from ...backend.util.logging import InvokeAILogger from ..models.image import ImageCategory, ResourceOrigin from .baseinvocation import ( BaseInvocation, @@ -608,19 +607,10 @@ class LatentsToImageInvocation(BaseInvocation): vae.to(dtype=torch.float16) latents = latents.half() - try: - if self.tiled or context.services.configuration.tiled_decode: - vae.enable_tiling() - else: - vae.disable_tiling() - except AttributeError as err: - # FIXME: This is a TEMPORARY measure until AutoencoderTiny gets tiling support from https://github.com/huggingface/diffusers/pull/4627 - if err.name.endswith("_tiling"): - InvokeAILogger.getLogger(self.__class__.__name__).debug( - "ignoring tiling error for %s", vae.__class__, exc_info=err - ) - else: - raise + if self.tiled or context.services.configuration.tiled_decode: + vae.enable_tiling() + else: + vae.disable_tiling() # clear memory as vae decode can request a lot torch.cuda.empty_cache() @@ -783,19 +773,10 @@ class ImageToLatentsInvocation(BaseInvocation): vae.to(dtype=torch.float16) # latents = latents.half() - try: - if tiled: - vae.enable_tiling() - else: - vae.disable_tiling() - except AttributeError as err: - # FIXME: This is a TEMPORARY measure until AutoencoderTiny gets tiling support from https://github.com/huggingface/diffusers/pull/4627 - if err.name.endswith("_tiling"): - InvokeAILogger.getLogger(ImageToLatentsInvocation.__name__).debug( - "ignoring tiling error for %s", vae.__class__, exc_info=err - ) - else: - raise + if tiled: + vae.enable_tiling() + else: + vae.disable_tiling() # non_noised_latents_from_image image_tensor = image_tensor.to(device=vae.device, dtype=vae.dtype)