diff --git a/modules/mit_nunchaku.py b/modules/mit_nunchaku.py index ea616fe5b..c15ccbd62 100644 --- a/modules/mit_nunchaku.py +++ b/modules/mit_nunchaku.py @@ -65,12 +65,16 @@ def install_nunchaku(force=False): log.error(f'Nunchaku: torch={torch.__version__} cuda="unknown"') return False if cuda_ver.startswith('cu13'): - nunchaku_versions = ['1.2.1', '1.2.0', '1.1.0', '1.0.2', '1.0.1'] + nunchaku_versions = ['1.3.0dev20260306', '1.2.1', '1.2.0', '1.1.0', '1.0.2', '1.0.1'] else: nunchaku_versions = ['1.2.1', '1.0.2', '1.0.1'] # 1.2.0 and 1.1.0 imply cu13 but do not specify it for v in nunchaku_versions: url = f'https://github.com/nunchaku-ai/nunchaku/releases/download/v{v}/' - fn = f'nunchaku-{v}+{cuda_ver}torch{torch_ver}-cp{python_ver}-cp{python_ver}-{suffix}.whl' + if 'dev' in v: + v = v.replace('dev', '.dev') + fn = f'nunchaku-{v}+{cuda_ver}torch{torch_ver}-cp{python_ver}-cp{python_ver}-{suffix}.whl' + else: + fn = f'nunchaku-{v}+{cuda_ver}torch{torch_ver}-cp{python_ver}-cp{python_ver}-{suffix}.whl' result, _output = pip(f'install --upgrade {url+fn}', uv=False, ignore=True, quiet=True) if (result is None) or (_output == 'offline'): log.error(f'Nunchaku: install url="{url+fn}" offline mode') diff --git a/modules/model_quant.py b/modules/model_quant.py index 0cb6c05b2..5b0dcfa81 100644 --- a/modules/model_quant.py +++ b/modules/model_quant.py @@ -206,6 +206,8 @@ def check_nunchaku(module: str = ''): if module in nunchaku_modules: from modules import mit_nunchaku mit_nunchaku.install_nunchaku() + import torch._dynamo + torch._dynamo.config.recompile_limit = 16 # Set a higher limit # pylint: disable=protected-access return mit_nunchaku.ok return False diff --git a/modules/ui_definitions.py b/modules/ui_definitions.py index 82e53e406..af990c0a3 100644 --- a/modules/ui_definitions.py +++ b/modules/ui_definitions.py @@ -592,7 +592,6 @@ def create_settings(cmd_opts): "postprocessing_sep_seedvr": OptionInfo("

SeedVR

", "", gr.HTML), "seedvr_cfg_scale": OptionInfo(3.5, "SeedVR CFG Scale", gr.Slider, {"minimum": 1, "maximum": 15, "step": 1}), - "postprocessing_sep_upscalers": OptionInfo("

Upscaling

", "", gr.HTML), "upscaler_unload": OptionInfo(False, "Unload upscaler after processing"), "upscaler_latent_steps": OptionInfo(20, "Upscaler latent steps", gr.Slider, {"minimum": 4, "maximum": 100, "step": 1}), @@ -604,7 +603,6 @@ def create_settings(cmd_opts): "resize_linearize_srgb": OptionInfo(True, "Apply sRGB linearization"), })) - # --- Huggingface --- options_templates.update(options_section(('huggingface', "Huggingface"), { "huggingface_sep": OptionInfo("

Huggingface

", "", gr.HTML), diff --git a/pipelines/model_z_image.py b/pipelines/model_z_image.py index e619de619..c75c2b9af 100644 --- a/pipelines/model_z_image.py +++ b/pipelines/model_z_image.py @@ -1,6 +1,7 @@ import torch import transformers import diffusers +from huggingface_hub import hf_hub_download from modules import shared, devices, sd_models, model_quant, sd_hijack_te from modules.logger import log from pipelines import generic @@ -13,11 +14,12 @@ def load_nunchaku(): nunchaku_precision = nunchaku.utils.get_precision() nunchaku_rank = 128 nunchaku_repo = f"nunchaku-ai/nunchaku-z-image-turbo/svdq-{nunchaku_precision}_r{nunchaku_rank}-z-image-turbo.safetensors" + repo_id, filename = nunchaku_repo.rsplit('/', 1) log.debug(f'Load module: quant=Nunchaku module=transformer repo="{nunchaku_repo}" attention={shared.opts.nunchaku_attention}') + local_path = hf_hub_download(repo_id=repo_id, filename=filename, cache_dir=shared.opts.hfcache_dir) transformer = nunchaku.NunchakuZImageTransformer2DModel.from_pretrained( # pylint: disable=no-member - nunchaku_repo, + local_path, torch_dtype=devices.dtype, - cache_dir=shared.opts.hfcache_dir, ) return transformer