diff --git a/modules/control/run.py b/modules/control/run.py index f5dae8c2b..a64fabe60 100644 --- a/modules/control/run.py +++ b/modules/control/run.py @@ -403,7 +403,7 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg sequential_seed: bool | None = None, # prompt/attention overrides prompt_attention: str | None = None, prompt_mean_norm: bool | None = None, diffusers_zeros_prompt_pad: bool | None = None, - te_pooled_embeds: bool | None = None, lora_apply_te: bool | None = None, te_complex_human_instruction: str | None = None, te_use_mask: bool | None = None, + te_pooled_embeds: bool | None = None, te_complex_human_instruction: str | None = None, te_use_mask: bool | None = None, # generation modifier overrides (hijack) freeu_enabled: bool | None = None, freeu_b1: float | None = None, freeu_b2: float | None = None, freeu_s1: float | None = None, freeu_s2: float | None = None, hypertile_unet_enabled: bool | None = None, hypertile_hires_only: bool | None = None, hypertile_unet_tile: int | None = None, hypertile_unet_min_tile: int | None = None, @@ -586,7 +586,7 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg # prompt/attention overrides prompt_attention=prompt_attention, prompt_mean_norm=prompt_mean_norm, diffusers_zeros_prompt_pad=diffusers_zeros_prompt_pad, te_pooled_embeds=te_pooled_embeds, - lora_apply_te=lora_apply_te, te_complex_human_instruction=te_complex_human_instruction, te_use_mask=te_use_mask, + te_complex_human_instruction=te_complex_human_instruction, te_use_mask=te_use_mask, # generation modifier overrides (hijack) freeu_enabled=freeu_enabled, freeu_b1=freeu_b1, freeu_b2=freeu_b2, freeu_s1=freeu_s1, freeu_s2=freeu_s2, hypertile_unet_enabled=hypertile_unet_enabled, hypertile_hires_only=hypertile_hires_only, diff --git a/modules/detailer/detailer.py b/modules/detailer/detailer.py index 752e9fbdc..73bdd32f0 100644 --- a/modules/detailer/detailer.py +++ b/modules/detailer/detailer.py @@ -321,7 +321,7 @@ class Detailer(): pc.disable_extra_networks = True # disable processing_diffusers from handling network activation since its handled here network_same = len(p.network_data.values()) == len(pc.network_data.values()) and all(x == y for x, y in zip(p.network_data.values(), pc.network_data.values())) if not network_same: - extra_networks.activate_filtered(pc, pc.network_data) + extra_networks.activate(pc, pc.network_data) log.debug(f'Detail: model="{i+1}:{name}" item={j+1}/{len(items)} box={item.box} label="{item.label}" score={item.score:.2f} seg={detailer_opt(p, "detailer_segmentation")} network={network_same} prompt="{pc.prompt}"') pc.init_images = [image] pc.image_mask = [item.mask] diff --git a/modules/extra_networks.py b/modules/extra_networks.py index 0737f68f8..89acf5a4e 100644 --- a/modules/extra_networks.py +++ b/modules/extra_networks.py @@ -121,15 +121,6 @@ def activate(p: StableDiffusionProcessing, extra_network_data: defaultdict[str, p.network_data = extra_network_data -def activate_filtered(p: StableDiffusionProcessing, extra_network_data: defaultdict[str, list[ExtraNetworkParams]] | None = None, step=0): - """activate with text encoder components gated on lora_apply_te; must run before prompt encode so te networks affect embeds""" - apply_te = getattr(p, 'lora_apply_te', None) - if apply_te is None: - apply_te = shared.opts.lora_apply_te - exclude = [] if apply_te else ['text_encoder', 'text_encoder_2', 'text_encoder_3'] - activate(p, extra_network_data, step=step, exclude=exclude) - - def deactivate(p: StableDiffusionProcessing, extra_network_data: defaultdict[str, list[ExtraNetworkParams]] | None = None, force: bool | None = None): """call deactivate for extra networks in extra_network_data in specified order, then call deactivate for all remaining registered networks""" if p.disable_extra_networks: diff --git a/modules/face/faceid.py b/modules/face/faceid.py index 4c63bcd66..b2263d840 100644 --- a/modules/face/faceid.py +++ b/modules/face/faceid.py @@ -216,7 +216,7 @@ def face_id( p.subseeds = p.all_subseeds[n * p.batch_size:(n+1) * p.batch_size] p.prompts, p.network_data = extra_networks.parse_prompts(p.prompts, p.network_data) - extra_networks.activate_filtered(p, p.network_data) + extra_networks.activate(p, p.network_data) ip_model_dict.update({ "prompt": p.prompts[0], "negative_prompt": p.negative_prompts[0], diff --git a/modules/options_handler.py b/modules/options_handler.py index 2400a2069..8b7818994 100644 --- a/modules/options_handler.py +++ b/modules/options_handler.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: import builtins cmd_opts = cmd_args.parse_args() -compatibility_opts = ['clip_skip', 'uni_pc_lower_order_final', 'uni_pc_order', 'xformers_options'] +compatibility_opts = ['clip_skip', 'uni_pc_lower_order_final', 'uni_pc_order', 'xformers_options', 'lora_apply_te'] removed_values = { # a stored choice that no longer exists is kept by validate, so it has to be rewritten or it selects nothing 'cross_attention_optimization': (['Batch matrix-matrix', 'Dynamic Attention BMM'], 'Scaled-Dot-Product'), } diff --git a/modules/processing_class.py b/modules/processing_class.py index b5f567379..624e874b7 100644 --- a/modules/processing_class.py +++ b/modules/processing_class.py @@ -254,7 +254,6 @@ class StableDiffusionProcessing: prompt_mean_norm: bool | None = None, diffusers_zeros_prompt_pad: bool | None = None, te_pooled_embeds: bool | None = None, - lora_apply_te: bool | None = None, te_complex_human_instruction: str | None = None, te_use_mask: bool | None = None, # generation modifier overrides (hijack) @@ -543,7 +542,6 @@ class StableDiffusionProcessing: self.prompt_mean_norm = prompt_mean_norm self.diffusers_zeros_prompt_pad = diffusers_zeros_prompt_pad self.te_pooled_embeds = te_pooled_embeds - self.lora_apply_te = lora_apply_te self.te_complex_human_instruction = te_complex_human_instruction self.te_use_mask = te_use_mask # generation modifier overrides (hijack) diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 0f975ea72..a7cad820a 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -149,7 +149,7 @@ def process_base(p: processing.StableDiffusionProcessing): if 'detailer' in p.ops: desc = 'Detail' p.prompts, p.network_data = extra_networks.parse_prompts(p.prompts, p.network_data) - extra_networks.activate_filtered(p) # networks must patch weights before prompt encode so te loras affect embeds + extra_networks.activate(p) # networks must patch weights before prompt encode so te loras affect embeds base_args = set_pipeline_args( p=p, model=shared.sd_model, @@ -313,7 +313,7 @@ def process_hires(p: processing.StableDiffusionProcessing, output): prompts, p.network_data = extra_networks.parse_prompts(prompts) reset_prompts = True if reset_prompts or ('base' in p.skip): - extra_networks.activate_filtered(p) + extra_networks.activate(p) hires_args = set_pipeline_args( p=p, diff --git a/modules/prompt_parser_diffusers.py b/modules/prompt_parser_diffusers.py index 0b073baa8..d02817733 100644 --- a/modules/prompt_parser_diffusers.py +++ b/modules/prompt_parser_diffusers.py @@ -130,11 +130,8 @@ class PromptEmbedder: # unpack EN data in case of TE LoRA en_data = p.network_data en_data = [idx.items for item in en_data.values() for idx in item] - apply_te = getattr(p, 'lora_apply_te', None) - if apply_te is None: - apply_te = shared.opts.lora_apply_te effective_batch = 1 if self.allsame else self.batchsize - key = str([self.prompts, self.negative_prompts, effective_batch, self.clip_skip, self.steps, en_data, apply_te]) + key = str([self.prompts, self.negative_prompts, effective_batch, self.clip_skip, self.steps, en_data]) item = cache.get(key) if not item: if not any(flatten(emb) for emb in [self.prompt_embeds, diff --git a/modules/ui_definitions.py b/modules/ui_definitions.py index 93ebbb3aa..1808f62a7 100644 --- a/modules/ui_definitions.py +++ b/modules/ui_definitions.py @@ -699,7 +699,6 @@ def create_settings(cmd_opts): "lora_apply_tags": OptionInfo(0, "LoRA auto-apply tags", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}), "lora_apply_sep": OptionInfo("

Apply method

", "", gr.HTML), - "lora_apply_te": OptionInfo(False, "LoRA native apply to text encoder"), "lora_fuse_native": OptionInfo(True, "LoRA native fuse with model"), "lora_fuse_diffusers": OptionInfo(False, "LoRA diffusers fuse with model"), diff --git a/ui/locale/locale_en.json b/ui/locale/locale_en.json index 678dede3e..2dd87c144 100644 --- a/ui/locale/locale_en.json +++ b/ui/locale/locale_en.json @@ -861,7 +861,6 @@ {"id":"","label":"Load custom Diffusers pipeline","localized":"","hint":"","ui":"settings_huggingface"}, {"id":"","label":"LoRA force reload always","localized":"","hint":"Forces LoRA networks to reload from storage on every generation, even if already cached.
Useful for debugging or when LoRA files are being modified externally.
Disable for normal use to benefit from caching.","ui":"settings_lora"}, {"id":"","label":"LoRA load using Diffusers method","localized":"","hint":"Alternative method uses diffusers built-in LoRA capabilities instead of native SD.Next implementation (may reduce LoRA compatibility)","ui":"settings_lora"}, - {"id":"","label":"LoRA native apply to text encoder","localized":"","hint":"","ui":"settings_lora"}, {"id":"","label":"LoRA native fuse with model","localized":"","hint":"Merge LoRA into the model for lower memory usage.

Warning: After removing or switching a LoRA, you may still see its style in generated images. To get a clean model, reload it from the model selector.","ui":"settings_lora"}, {"id":"","label":"LoRA diffusers fuse with model","localized":"","hint":"Merge LoRA into the model for lower memory usage and torch.compile compatibility.

Warning: After removing or switching a LoRA, you may still see its style in generated images. To get a clean model, reload it from the model selector.","ui":"settings_lora"}, {"id":"","label":"LoRA quantized apply method","localized":"","hint":"How networks are applied to SDNQ-quantized model weights:
- exact: adapters are carried alongside the quantized weights at full precision; apply and removal are exact and the quantized weights are never modified. The carried factors take additional VRAM, growing with adapter rank, size and count
- requantize: adapters are merged into the quantized weights, matching the behavior of earlier releases. Uses no additional VRAM (a weight backup for network removal is held in system RAM); on models quantized below 8 bits rounding typically loses much of the adapter effect, with strong adapters retaining more

With requantize selected, the host rank, calibration and cache options below have no effect.

Default is exact.","ui":"settings_lora"},