From 5f5a564d4138a0fc984cecfdf89574571bd15709 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 3 Aug 2023 22:38:43 +0300 Subject: [PATCH] Update compile settings --- installer.py | 2 +- modules/sd_hijack.py | 8 ++++---- modules/sd_models.py | 6 +++--- modules/shared.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/installer.py b/installer.py index a329c3d83..d235bcc66 100644 --- a/installer.py +++ b/installer.py @@ -387,7 +387,7 @@ def check_torch(): pip('uninstall xformers --yes --quiet', ignore=True, quiet=True) except Exception as e: log.debug(f'Cannot install xformers package: {e}') - if opts.get('cuda_compile_mode', '') == 'hidet': + if opts.get('cuda_compile_backend', '') == 'hidet': install('hidet', 'hidet') if args.profile: print_profile(pr, 'Torch') diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index f07cfef75..a583d79d8 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -183,10 +183,10 @@ class StableDiffusionModelHijack: except Exception as err: shared.log.warning(f"IPEX Optimize not supported: {err}") - if opts.cuda_compile and opts.cuda_compile_mode != 'none' and shared.backend == shared.Backend.ORIGINAL: + if opts.cuda_compile and opts.cuda_compile_backend != 'none' and shared.backend == shared.Backend.ORIGINAL: try: import logging - shared.log.info(f"Compiling pipeline={m.model.__class__.__name__} mode={opts.cuda_compile_mode}") + shared.log.info(f"Compiling pipeline={m.model.__class__.__name__} mode={opts.cuda_compile_backend}") import torch._dynamo # pylint: disable=unused-import,redefined-outer-name log_level = logging.WARNING if opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access if hasattr(torch, '_logging'): @@ -194,11 +194,11 @@ class StableDiffusionModelHijack: torch._dynamo.config.verbose = opts.cuda_compile_verbose # pylint: disable=protected-access torch._dynamo.config.suppress_errors = opts.cuda_compile_errors # pylint: disable=protected-access torch.backends.cudnn.benchmark = True - if opts.cuda_compile_mode == 'hidet': + if opts.cuda_compile_backend == 'hidet': import hidet hidet.torch.dynamo_config.use_tensor_core(True) hidet.torch.dynamo_config.search_space(2) - m.model = torch.compile(m.model, mode=opts.cuda_compile_type, backend=opts.cuda_compile_mode, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) + m.model = torch.compile(m.model, mode=opts.cuda_compile_mode, backend=opts.cuda_compile_backend, fullgraph=opts.cuda_compile_fullgraph, dynamic=False) shared.log.info("Model complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/sd_models.py b/modules/sd_models.py index f581ebf6d..8e9d55042 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -739,16 +739,16 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No shared.log.warning(f"IPEX Optimize not supported: {err}") try: if shared.opts.cuda_compile: - shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_mode}") + shared.log.info(f"Compiling pipeline={sd_model.__class__.__name__} shape={8 * sd_model.unet.config.sample_size} mode={shared.opts.cuda_compile_backend}") import torch._dynamo # pylint: disable=unused-import,redefined-outer-name log_level = logging.WARNING if shared.opts.cuda_compile_verbose else logging.CRITICAL # pylint: disable=protected-access if hasattr(torch, '_logging'): torch._logging.set_logs(dynamo=log_level, aot=log_level, inductor=log_level) # pylint: disable=protected-access torch._dynamo.config.verbose = shared.opts.cuda_compile_verbose # pylint: disable=protected-access torch._dynamo.config.suppress_errors = shared.opts.cuda_compile_errors # pylint: disable=protected-access - sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_type, backend=shared.opts.cuda_compile_mode, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init + sd_model.unet = torch.compile(sd_model.unet, mode=shared.opts.cuda_compile_mode, backend=shared.opts.cuda_compile_backend, fullgraph=shared.opts.cuda_compile_fullgraph) # pylint: disable=attribute-defined-outside-init sd_model("dummy prompt") - shared.log.info("Complilation done.") + shared.log.info("Complilation done.") except Exception as err: shared.log.warning(f"Model compile not supported: {err}") diff --git a/modules/shared.py b/modules/shared.py index 721dff3da..3a3ce09f3 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -385,8 +385,8 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cuda_allow_tf32": OptionInfo(True, "Allow TF32 math ops"), "cuda_allow_tf16_reduced": OptionInfo(True, "Allow TF16 reduced precision math ops"), "cuda_compile": OptionInfo(False, "Enable model compile (experimental)"), - "cuda_compile_mode": OptionInfo("none", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), - "cuda_compile_type": OptionInfo("default", "Model compile type (experimental)", gr.Radio, lambda: {"choices": ['default', 'reduce-overhead', 'max-autotune']}), + "cuda_compile_backend": OptionInfo("none", "Model compile backend (experimental)", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex']}), + "cuda_compile_mode": OptionInfo("default", "Model compile mode (experimental)", gr.Radio, lambda: {"choices": ['default', 'reduce-overhead', 'max-autotune']}), "cuda_compile_fullgraph": OptionInfo(False, "Model compile fullgraph"), "cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"), "cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"),