diff --git a/invokeai/app/invocations/compel.py b/invokeai/app/invocations/compel.py index fffb09e6549..db7612eaa0c 100644 --- a/invokeai/app/invocations/compel.py +++ b/invokeai/app/invocations/compel.py @@ -85,7 +85,7 @@ def _lora_loader() -> Iterator[Tuple[LoRAModelRaw, float]]: ModelPatcher.apply_lora_text_encoder( text_encoder, loras=_lora_loader(), - model_state_dict=model_state_dict, + model_state_dict=None if context.config.get().disable_lora_patching_opt else model_state_dict, ), # Apply CLIP Skip after LoRA to prevent LoRA application from failing on skipped layers. ModelPatcher.apply_clip_skip(text_encoder, self.clip.skipped_layers), @@ -181,7 +181,7 @@ def _lora_loader() -> Iterator[Tuple[LoRAModelRaw, float]]: text_encoder, loras=_lora_loader(), prefix=lora_prefix, - model_state_dict=state_dict, + model_state_dict=None if context.config.get().disable_lora_patching_opt else state_dict, ), # Apply CLIP Skip after LoRA to prevent LoRA application from failing on skipped layers. ModelPatcher.apply_clip_skip(text_encoder, clip_field.skipped_layers), diff --git a/invokeai/app/invocations/denoise_latents.py b/invokeai/app/invocations/denoise_latents.py index 7ccf9068939..a0fb6722743 100644 --- a/invokeai/app/invocations/denoise_latents.py +++ b/invokeai/app/invocations/denoise_latents.py @@ -762,7 +762,7 @@ def _lora_loader() -> Iterator[Tuple[LoRAModelRaw, float]]: ModelPatcher.apply_lora_unet( unet, loras=_lora_loader(), - model_state_dict=model_state_dict, + model_state_dict=None if context.config.get().disable_lora_patching_opt else model_state_dict, ), ): assert isinstance(unet, UNet2DConditionModel) diff --git a/invokeai/app/services/config/config_default.py b/invokeai/app/services/config/config_default.py index 6c39760bdc8..82da4348c55 100644 --- a/invokeai/app/services/config/config_default.py +++ b/invokeai/app/services/config/config_default.py @@ -113,6 +113,7 @@ class InvokeAIAppConfig(BaseSettings): pil_compress_level: The compress_level setting of PIL.Image.save(), used for PNG encoding. All settings are lossless. 0 = no compression, 1 = fastest with slightly larger filesize, 9 = slowest with smallest filesize. 1 is typically the best setting. max_queue_size: Maximum number of items in the session queue. clear_queue_on_startup: Empties session queue on startup. + disable_lora_patching_opt: Disable LoRA patching optimization. allow_nodes: List of nodes to allow. Omit to allow all. deny_nodes: List of nodes to deny. Omit to deny none. node_cache_size: How many cached nodes to keep in memory. @@ -186,6 +187,7 @@ class InvokeAIAppConfig(BaseSettings): pil_compress_level: int = Field(default=1, description="The compress_level setting of PIL.Image.save(), used for PNG encoding. All settings are lossless. 0 = no compression, 1 = fastest with slightly larger filesize, 9 = slowest with smallest filesize. 1 is typically the best setting.") max_queue_size: int = Field(default=10000, gt=0, description="Maximum number of items in the session queue.") clear_queue_on_startup: bool = Field(default=False, description="Empties session queue on startup.") + disable_lora_patching_opt: bool = Field(default=False, description="Disable LoRA patching optimization.") # NODES allow_nodes: Optional[list[str]] = Field(default=None, description="List of nodes to allow. Omit to allow all.")