From 8bef48e5013bdf515850da62344e7c93ed360f22 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Sun, 4 Jun 2023 12:22:56 +0300 Subject: [PATCH] Fix GroupNorm.forward with IPEX --- modules/devices.py | 9 ++++++++- modules/shared.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/devices.py b/modules/devices.py index 9fc0359bb..510e02a03 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -145,8 +145,15 @@ def set_cuda_params(): args = cmd_args.parser.parse_args() if args.use_ipex: + #Fix broken function in ipex 1.13.120+xpu + from modules.sd_hijack_utils import CondFunc + CondFunc('torch.nn.modules.GroupNorm.forward', + lambda orig_func, *args, **kwargs: orig_func(args[0], args[1].to(args[0].weight.data.dtype)), + lambda *args, **kwargs: args[2].dtype != args[1].weight.data.dtype) + + #Use XPU instead of CPU. %20 Perf improvement on weak CPUs. if args.device_id is not None: - cpu = torch.device(f"xpu:{args.device_id}") #Use XPU instead of CPU. %20 Perf improvement on weak CPUs. + cpu = torch.device(f"xpu:{args.device_id}") else: cpu = torch.device("xpu") else: diff --git a/modules/shared.py b/modules/shared.py index c29be04ae..09c070de9 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -304,7 +304,7 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cuda_dtype": OptionInfo("FP32" if sys.platform == "darwin" else "FP16", "Device precision type", gr.Radio, lambda: {"choices": ["FP32", "FP16", "BF16"]}), "no_half": OptionInfo(False, "Use full precision for model (--no-half)", None, None, None), "no_half_vae": OptionInfo(False, "Use full precision for VAE (--no-half-vae)"), - "upcast_sampling": OptionInfo(True if sys.platform == "darwin" or cmd_opts.use_ipex else False, "Enable upcast sampling"), + "upcast_sampling": OptionInfo(True if sys.platform == "darwin" else False, "Enable upcast sampling"), "upcast_attn": OptionInfo(False, "Enable upcast cross attention layer"), "disable_nan_check": OptionInfo(True, "Disable NaN check in produced images/latent spaces"), "rollback_vae": OptionInfo(False, "Attempt to roll back VAE when produced NaN values, requires NaN check (experimental)"),