diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2edffe8..a7b001187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,11 @@ - **HunyuanVideo** optimizations: full offload, quantization and tiling support - **LTXVideo** optimizations: full offload, quantization and tiling support - VAE tiling granular options in *settings -> variable auto encoder* -- UI: live preview add sigma calculation, thanks @Disty0 +- UI: live preview optimizations - UI: CSS optimizations when log view is disabled - Samplers: add flow shift options and separate dynamic thresholding from dynamic shifting - **Fixes** - do not show disabled networks - - live preview image sizes in modern and standard UI - image width/height calculation when doing img2img - flux pipeline switches: txt/img/inpaint - interrogate caption with T5 diff --git a/extensions-builtin/Lora/ui_extra_networks_lora.py b/extensions-builtin/Lora/ui_extra_networks_lora.py index c5adbb81f..cd7875377 100644 --- a/extensions-builtin/Lora/ui_extra_networks_lora.py +++ b/extensions-builtin/Lora/ui_extra_networks_lora.py @@ -80,7 +80,6 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage): def create_item(self, name): l = networks.available_networks.get(name) if l is None: - print('HERE1') shared.log.warning(f'Networks: type=lora registered={len(list(networks.available_networks))} file="{name}" not registered') return None try: diff --git a/javascript/progressBar.js b/javascript/progressBar.js index dfd895f8e..afb9259dc 100644 --- a/javascript/progressBar.js +++ b/javascript/progressBar.js @@ -118,7 +118,7 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres const elapsedFromStart = (new Date() - dateStart) / 1000; hasStarted |= res.active; if (res.completed || (!res.active && (hasStarted || once)) || (elapsedFromStart > 30 && !res.queued && res.progress === prevProgress)) { - debug('onProgressEnd', res); + // debug('onProgressEnd', res); done(); return; } diff --git a/modules/model_flux.py b/modules/model_flux.py index 4ba1bb556..7a3fa9e00 100644 --- a/modules/model_flux.py +++ b/modules/model_flux.py @@ -157,7 +157,7 @@ def load_quants(kwargs, repo_id, cache_dir): if 'transformer' not in kwargs and ('Model' in shared.opts.bnb_quantization or 'Model' in shared.opts.torchao_quantization): kwargs['transformer'] = diffusers.FluxTransformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=transformer type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') - if 'text_encoder_3' not in kwargs and ('Text Encoder' in shared.opts.bnb_quantization or 'Text Encoder' in shared.opts.torchao_quantization): + if 'text_encoder_2' not in kwargs and ('Text Encoder' in shared.opts.bnb_quantization or 'Text Encoder' in shared.opts.torchao_quantization): kwargs['text_encoder_2'] = transformers.T5EncoderModel.from_pretrained(repo_id, subfolder="text_encoder_2", cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=t5 type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') return kwargs diff --git a/modules/model_sana.py b/modules/model_sana.py index 7dc551a6f..79a13592d 100644 --- a/modules/model_sana.py +++ b/modules/model_sana.py @@ -18,12 +18,11 @@ def load_quants(kwargs, repo_id, cache_dir): if not quant_args: return kwargs load_args = kwargs.copy() - model_quant.load_bnb(f'Load model: type=SD3 quant={quant_args} args={load_args}') - if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs: + if 'transformer' not in kwargs and ('Model' in shared.opts.bnb_quantization or 'Model' in shared.opts.torchao_quantization): kwargs['transformer'] = diffusers.models.SanaTransformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, **load_args, **quant_args) shared.log.debug(f'Quantization: module=transformer type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') - if 'Text Encoder' in shared.opts.bnb_quantization and 'text_encoder_3' not in kwargs: - kwargs['text_encoder_3'] = transformers.AutoModelForCausalLM.from_pretrained(repo_id, subfolder="text_encoder", cache_dir=cache_dir, **load_args, **quant_args) + if 'text_encoder' not in kwargs and ('Text Encoder' in shared.opts.bnb_quantization or 'Text Encoder' in shared.opts.torchao_quantization): + kwargs['text_encoder'] = transformers.AutoModelForCausalLM.from_pretrained(repo_id, subfolder="text_encoder", cache_dir=cache_dir, **load_args, **quant_args) shared.log.debug(f'Quantization: module=t5 type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') return kwargs @@ -55,9 +54,9 @@ def load_sana(checkpoint_info, kwargs={}): kwargs['variant'] = 'fp16' if (fn is None) or (not os.path.exists(fn) or os.path.isdir(fn)): - kwargs = load_quants(kwargs, repo_id, cache_dir=shared.opts.diffusers_dir) - # kwargs = model_quant.create_bnb_config(kwargs) - # kwargs = model_quant.create_ao_config(kwargs) + # TODO sana: fails when quantized + # kwargs = load_quants(kwargs, repo_id, cache_dir=shared.opts.diffusers_dir) + pass shared.log.debug(f'Load model: type=Sana repo="{repo_id}" args={list(kwargs)}') t0 = time.time() pipe = diffusers.SanaPipeline.from_pretrained(repo_id, cache_dir=shared.opts.diffusers_dir, **kwargs) diff --git a/modules/model_sd3.py b/modules/model_sd3.py index d0e23026b..bf8644284 100644 --- a/modules/model_sd3.py +++ b/modules/model_sd3.py @@ -65,7 +65,7 @@ def load_quants(kwargs, repo_id, cache_dir): if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs: kwargs['transformer'] = diffusers.SD3Transformer2DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=transformer type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') - if 'Text Encoder' in shared.opts.bnb_quantization and 'text_encoder_3' not in kwargs: + if 'text_encoder_3' not in kwargs and ('Text Encoder' in shared.opts.bnb_quantization or 'Text Encoder' in shared.opts.torchao_quantization): kwargs['text_encoder_3'] = transformers.T5EncoderModel.from_pretrained(repo_id, subfolder="text_encoder_3", variant='fp16', cache_dir=cache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=t5 type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') return kwargs diff --git a/modules/sd_samplers_common.py b/modules/sd_samplers_common.py index a90ceec27..c4a2712f3 100644 --- a/modules/sd_samplers_common.py +++ b/modules/sd_samplers_common.py @@ -71,6 +71,8 @@ def single_sample_to_image(sample, approximation=None): warn_once(f"Unknown latent decode type: {approximation}") return Image.new(mode="RGB", size=(512, 512)) try: + if x_sample.shape[0] > 4: + return Image.new(mode="RGB", size=(512, 512)) if x_sample.dtype == torch.bfloat16: x_sample.to(torch.float16) transform = T.ToPILImage() diff --git a/modules/sd_vae_taesd.py b/modules/sd_vae_taesd.py index a1959817c..4507ee3c8 100644 --- a/modules/sd_vae_taesd.py +++ b/modules/sd_vae_taesd.py @@ -153,8 +153,9 @@ def decode(latents): if not previous_warnings: previous_warnings = True shared.log.warning(f'TAESD unsupported model type: {model_class}') - return Image.new('RGB', (8, 8), color = (0, 0, 0)) - vae = taesd_models[f'{model_class}-decoder'] + # return Image.new('RGB', (8, 8), color = (0, 0, 0)) + return latents + vae = taesd_models.get(f'{model_class}-decoder', None) if vae is None: model_path = os.path.join(paths.models_path, "TAESD", f"tae{model_class}_decoder.pth") download_model(model_path) diff --git a/modules/shared_state.py b/modules/shared_state.py index c773b36a9..024427f09 100644 --- a/modules/shared_state.py +++ b/modules/shared_state.py @@ -1,7 +1,7 @@ import os import time import datetime -from modules.errors import log +from modules.errors import log, display class State: @@ -164,17 +164,20 @@ class State: try: sample = self.current_latent self.current_image_sampling_step = self.sampling_step + """ if self.current_noise_pred is not None and self.current_sigma is not None and self.current_sigma_next is not None: original_sample = sample - (self.current_noise_pred * (self.current_sigma_next-self.current_sigma)) + # RuntimeError: The size of tensor a (128) must match the size of tensor b (64) at non-singleton dimension 3 if self.prediction_type in {"epsilon", "flow_prediction"}: sample = original_sample - (self.current_noise_pred * self.current_sigma) elif self.prediction_type == "v_prediction": sample = self.current_noise_pred * (-self.current_sigma / (self.current_sigma**2 + 1) ** 0.5) + (original_sample / (self.current_sigma**2 + 1)) # pylint: disable=invalid-unary-operand-type + """ image = sd_samplers.samples_to_image_grid(sample) if shared.opts.show_progress_grid else sd_samplers.sample_to_image(sample) self.assign_current_image(image) - except Exception: - # log.error(f'Error setting current image: step={self.sampling_step} {e}') - pass + except Exception as e: + log.error(f'State image: last={self.id_live_preview} step={self.sampling_step} {e}') + display(e, 'State image') self.preview_busy = False def assign_current_image(self, image): diff --git a/scripts/ltxvideo.py b/scripts/ltxvideo.py index d4f62bc2b..7b12a3a86 100644 --- a/scripts/ltxvideo.py +++ b/scripts/ltxvideo.py @@ -26,10 +26,10 @@ def load_quants(kwargs, repo_id): if not quant_args: return kwargs model_quant.load_bnb(f'Load model: type=LTX quant={quant_args}') - if 'Model' in shared.opts.bnb_quantization and 'transformer' not in kwargs: + if 'transformer' not in kwargs and ('Model' in shared.opts.bnb_quantization or 'Model' in shared.opts.torchao_quantization): kwargs['transformer'] = diffusers.LTXVideoTransformer3DModel.from_pretrained(repo_id, subfolder="transformer", cache_dir=shared.opts.hfcache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=transformer type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') - if 'Text Encoder' in shared.opts.bnb_quantization and 'text_encoder_3' not in kwargs: + if 'text_encoder' not in kwargs and ('Text Encoder' in shared.opts.bnb_quantization or 'Text Encoder' in shared.opts.torchao_quantization): kwargs['text_encoder'] = transformers.T5EncoderModel.from_pretrained(repo_id, subfolder="text_encoder", cache_dir=shared.opts.hfcache_dir, torch_dtype=devices.dtype, **quant_args) shared.log.debug(f'Quantization: module=t5 type=bnb dtype={shared.opts.bnb_quantization_type} storage={shared.opts.bnb_quantization_storage}') return kwargs