From 963940b9ae4d4d60837b332b00799d49916c575b Mon Sep 17 00:00:00 2001 From: Disty0 Date: Wed, 21 Aug 2024 22:45:02 +0300 Subject: [PATCH] Fix no half vae --- modules/processing_vae.py | 5 ++++- modules/sd_models_compile.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/processing_vae.py b/modules/processing_vae.py index 2a7907bce..dd4174d02 100644 --- a/modules/processing_vae.py +++ b/modules/processing_vae.py @@ -44,7 +44,10 @@ def full_vae_decode(latents, model): upcast = (model.vae.dtype == torch.float16) and getattr(model.vae.config, 'force_upcast', False) and hasattr(model, 'upcast_vae') if upcast: # this is done by diffusers automatically if output_type != 'latent' model.upcast_vae() - if getattr(model.vae, "post_quant_conv", None) is not None: + + if shared.opts.no_half_vae: + latents = latents.to(torch.float32) + elif getattr(model.vae, "post_quant_conv", None) is not None: latents = latents.to(next(iter(model.vae.post_quant_conv.parameters())).dtype) # normalize latents diff --git a/modules/sd_models_compile.py b/modules/sd_models_compile.py index 65c3ed7f6..5819866ef 100644 --- a/modules/sd_models_compile.py +++ b/modules/sd_models_compile.py @@ -270,7 +270,7 @@ def optimum_quanto_weights(sd_model): else: sd_models.move_model(sd_model, devices.device) with quanto.Calibration(momentum=0.9): - sd_model(prompt="dummy", height=512, width=512, guidance_scale=4.0, num_inference_steps=10) + sd_model(prompt="dummy prompt", num_inference_steps=10) sd_model = apply_compile_to_model(sd_model, optimum_quanto_freeze, shared.opts.optimum_quanto_weights, op="optimum-quanto-freeze") if shared.opts.diffusers_offload_mode == "model": sd_models.disable_offload(sd_model)