nunchaku improvements

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2026-05-18 18:29:20 +02:00
parent 927994d47d
commit b2223c7f8c
4 changed files with 12 additions and 6 deletions
+6 -2
View File
@@ -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')
+2
View File
@@ -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
-2
View File
@@ -592,7 +592,6 @@ def create_settings(cmd_opts):
"postprocessing_sep_seedvr": OptionInfo("<h2>SeedVR</h2>", "", gr.HTML),
"seedvr_cfg_scale": OptionInfo(3.5, "SeedVR CFG Scale", gr.Slider, {"minimum": 1, "maximum": 15, "step": 1}),
"postprocessing_sep_upscalers": OptionInfo("<h2>Upscaling</h2>", "", 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("<h2>Huggingface</h2>", "", gr.HTML),
+4 -2
View File
@@ -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