diff --git a/CHANGELOG.md b/CHANGELOG.md index 4583fd8d7..dc1d1fa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ comma-separate list of regex patterns to skip - ui display reference models with subdued color - xyz grid support bool + - do not force gc at end of processing - **Wiki** - new Nunchaku page - updated HiDream, Quantization, NNCF pages @@ -37,6 +38,7 @@ - SD35 InstantX IP-adapter - **HunyuanVideo-I2V** with latest transformers - trace logging + - xyz grid restore settings ## Update for 2025-04-12 diff --git a/modules/model_flux.py b/modules/model_flux.py index 37ab0d3f8..eabb248f7 100644 --- a/modules/model_flux.py +++ b/modules/model_flux.py @@ -122,8 +122,9 @@ def load_quants(kwargs, repo_id, cache_dir, allow_quant): else: shared.log.error(f'Load module: quant=Nunchaku module=transformer repo="{repo_id}" unsupported') if nunchaku_repo is not None: - shared.log.debug(f'Load module: quant=Nunchaku module=transformer repo="{nunchaku_repo}" precision={nunchaku_precision} attention={shared.opts.nunchaku_attention}') - kwargs['transformer'] = nunchaku.NunchakuFluxTransformer2dModel.from_pretrained(nunchaku_repo, torch_dtype=devices.dtype) + shared.log.debug(f'Load module: quant=Nunchaku module=transformer repo="{nunchaku_repo}" precision={nunchaku_precision} offload={shared.opts.nunchaku_offload} attention={shared.opts.nunchaku_attention}') + kwargs['transformer'] = nunchaku.NunchakuFluxTransformer2dModel.from_pretrained(nunchaku_repo, offload=shared.opts.nunchaku_offload, torch_dtype=devices.dtype) + kwargs['transformer'].quantization_method = 'SVDQuant' if shared.opts.nunchaku_attention: kwargs['transformer'].set_attention_impl("nunchaku-fp16") elif 'transformer' not in kwargs and model_quant.check_quant('Transformer'): diff --git a/modules/processing.py b/modules/processing.py index 7342ad373..0472a058c 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -502,5 +502,5 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: if not p.disable_extra_networks: shared.log.info(f'Processed: images={len(output_images)} its={(p.steps * len(output_images)) / (t1 - t0):.2f} time={t1-t0:.2f} timers={timer.process.dct()} memory={memstats.memory_stats()}') - devices.torch_gc(force=True, reason='final') + devices.torch_gc(force=False, reason='final') return processed diff --git a/modules/processing_args.py b/modules/processing_args.py index d2465bc6c..85be8e4a1 100644 --- a/modules/processing_args.py +++ b/modules/processing_args.py @@ -153,7 +153,7 @@ def set_pipeline_args(p, model, prompts:list, negative_prompts:list, prompts_2:t shared.log.error(f'Prompt parser encode: {e}') if os.environ.get('SD_PROMPT_DEBUG', None) is not None: errors.display(e, 'Prompt parser encode') - timer.process.record('encode', reset=False) + timer.process.record('prompt', reset=False) else: prompt_parser_diffusers.embedder = None diff --git a/modules/processing_vae.py b/modules/processing_vae.py index 00eecc092..fd84c9c09 100644 --- a/modules/processing_vae.py +++ b/modules/processing_vae.py @@ -2,7 +2,6 @@ import os import time import numpy as np import torch -import torchvision.transforms.functional as TF from modules import shared, devices, sd_models, sd_vae, sd_vae_taesd, errors @@ -316,6 +315,7 @@ def vae_decode(latents, model, output_type='np', vae_type='Full', width=None, he def vae_encode(image, model, vae_type='Full'): # pylint: disable=unused-variable + import torchvision.transforms.functional as f if shared.state.interrupted or shared.state.skipped: return [] if not hasattr(model, 'vae') and hasattr(model, 'pipe'): @@ -323,7 +323,7 @@ def vae_encode(image, model, vae_type='Full'): # pylint: disable=unused-variable if not hasattr(model, 'vae'): shared.log.error('VAE not found in model') return [] - tensor = TF.to_tensor(image.convert("RGB")).unsqueeze(0).to(devices.device, devices.dtype_vae) + tensor = f.to_tensor(image.convert("RGB")).unsqueeze(0).to(devices.device, devices.dtype_vae) if vae_type == 'Full': tensor = tensor * 2 - 1 latents = full_vae_encode(image=tensor, model=shared.sd_model) diff --git a/modules/shared.py b/modules/shared.py index 6283144ca..58e114d1a 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -552,6 +552,7 @@ options_templates.update(options_section(('quantization', "Quantization Settings "nunchaku_sep": OptionInfo("