From e89062c04fda15ec0537392f72e11ec4f278260d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 10 Aug 2026 12:06:33 +0200 Subject: [PATCH] register submodule as package Signed-off-by: Vladimir Mandic --- .gitmodules | 4 ++-- installer.py | 29 +++++++++-------------------- launch.py | 1 - modules/extensions.py | 1 + modules/loader.py | 11 +++++++++-- modules/processing.py | 5 +++-- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/.gitmodules b/.gitmodules index b6dd8b80a..39637a7b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,5 +13,5 @@ path = extensions-builtin/sdnext-kanvas url = https://github.com/vladmandic/sdnext-kanvas [submodule "extensions-builtin/sdnq"] - path = extensions-builtin/sdnq - url = https://github.com/Disty0/sdnq + path = extensions-builtin/sdnq + url = https://github.com/Disty0/sdnq diff --git a/installer.py b/installer.py index d6755a336..ac2c92411 100644 --- a/installer.py +++ b/installer.py @@ -550,27 +550,16 @@ def check_python(supported_minors=None, experimental_minors=None, reason=None): ts('python', t_start) -# check sdnq version -def check_sdnq(): +# register sdnq package from github submodule +def register_sdnq(): t_start = time.time() - if args.skip_all: - return - target_commit = "27a54aed657ec583620b76b42c65d907d13290ad" - pkg = package_spec('sdnq') - parts = pkg.version.split('.') if pkg is not None else [] - minor = int(parts[1]) if len(parts) > 1 else -1 - current = package_commit(pkg) if minor > -1 else '' - if (minor == -1) or ((current != target_commit) and (not args.experimental)): - if minor == -1: - log.info(f'Install: package="sdnq" commit={target_commit}') - else: - log.info(f'Update: package="sdnq" current={pkg.version} commit={current} target={target_commit}') - pip('uninstall --yes sdnq', ignore=True, quiet=True, uv=False) - if args.skip_git: - log.warning('Git: marked as not available but required for sdnq installation') - pip(f'install git+https://github.com/Disty0/sdnq@{target_commit}', ignore=False, quiet=True, uv=False) - global sdnq_commit # pylint: disable=global-statement - sdnq_commit = target_commit + fn = os.path.join('extensions-builtin', 'sdnq', 'src', 'sdnq', '__init__.py') + name = "sdnq" + spec = importlib.util.spec_from_file_location(name, fn) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) # this is where actual import happens + import sdnq # pylint: disable=unused-import # test import ts('sdnq', t_start) diff --git a/launch.py b/launch.py index 418bfdc3b..e3b0b995e 100755 --- a/launch.py +++ b/launch.py @@ -261,7 +261,6 @@ def main(): installer.install_gradio() installer.check_torch() installer.check_onnx() - installer.check_sdnq() installer.check_transformers() installer.check_diffusers() installer.check_modified_files() diff --git a/modules/extensions.py b/modules/extensions.py index 56ab00faa..b93fe7f81 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -64,6 +64,7 @@ def temp_disable_extensions(): 'multidiffusion-upscaler-for-automatic1111', 'a1111-sd-webui-lycoris', 'sd-webui-animatediff', + 'sdnq', ] disable_obsolete = [ 'Lora', diff --git a/modules/loader.py b/modules/loader.py index 027ad65b1..4184840e7 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -222,12 +222,19 @@ try: import diffusers # pylint: disable=W0611,C0411 import diffusers.loaders.single_file # pylint: disable=W0611,C0411 diffusers.loaders.single_file.logging.tqdm = partial(tqdm, unit='C') - timer.startup.record("diffusers") except Exception as e: log.error(f'Loader: diffusers=={diffusers.__version__ if "diffusers" in sys.modules else None} {e}') log.error('Please restart re-run the installer') errors.display(e, 'diffusers') sys.exit(1) +timer.startup.record("diffusers") + +from installer import register_sdnq +register_sdnq() +import sdnq # pylint: disable=W0611,C0411 +diffusers.utils.import_utils._sdnq_available = True # pylint: disable=protected-access +diffusers.utils.import_utils._sdnq_version = sdnq.__version__ # pylint: disable=protected-access +timer.startup.record("sdnq") try: import pillow_jxl # pylint: disable=W0611,C0411 @@ -236,7 +243,6 @@ except Exception: from PIL import Image # pylint: disable=W0611,C0411 timer.startup.record("pillow") - import cv2 # pylint: disable=W0611,C0411 timer.startup.record("cv2") @@ -265,6 +271,7 @@ def get_packages(): "torchvision": torchvision.__version__, "diffusers": diffusers.__version__, "transformers": transformers.__version__, + "sdnq": sdnq.__version__, "tokenizers": tokenizers.__version__, "accelerate": accelerate.__version__, "hub": huggingface_hub.__version__, diff --git a/modules/processing.py b/modules/processing.py index 98cf0a566..6c75d0b5f 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -429,8 +429,9 @@ def print_stats(): if devices.triton_ok: from modules.sd_models_compile import update_compile_times update_compile_times() - if timer.dynamo.get_total() > 0.1: - log.debug(f'Processed: dynamo={timer.dynamo.dct(min_time=2.0, no_total=True)}') + dynamo_dct = timer.dynamo.dct(min_time=2.0, no_total=True) + if dynamo_dct: + log.debug(f'Processed: dynamo={dynamo_dct}') def process_images_inner(p: StableDiffusionProcessing) -> Processed: