MCPcopy Index your code
hub / github.com/huggingface/diffusers / delete_adapters

Method delete_adapters

src/diffusers/loaders/peft.py:763–799  ·  view source on GitHub ↗

Delete an adapter's LoRA layers from the underlying model. Args: adapter_names (`list[str, str]`): The names (single string or list of strings) of the adapter to delete. Example: ```py from diffusers import AutoPipelineForText2I

(self, adapter_names: list[str] | str)

Source from the content-addressed store, hash-verified

761 set_adapter_layers(self, enabled=True)
762
763 def delete_adapters(self, adapter_names: list[str] | str):
764 """
765 Delete an adapter's LoRA layers from the underlying model.
766
767 Args:
768 adapter_names (`list[str, str]`):
769 The names (single string or list of strings) of the adapter to delete.
770
771 Example:
772
773 ```py
774 from diffusers import AutoPipelineForText2Image
775 import torch
776
777 pipeline = AutoPipelineForText2Image.from_pretrained(
778 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
779 ).to("cuda")
780 pipeline.load_lora_weights(
781 "jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors", adapter_names="cinematic"
782 )
783 pipeline.unet.delete_adapters("cinematic")
784 ```
785 """
786 if not USE_PEFT_BACKEND:
787 raise ValueError("PEFT backend is required for this method.")
788
789 if isinstance(adapter_names, str):
790 adapter_names = [adapter_names]
791
792 for adapter_name in adapter_names:
793 delete_adapter_layers(self, adapter_name)
794
795 # Pop also the corresponding adapter from the config
796 if hasattr(self, "peft_config"):
797 self.peft_config.pop(adapter_name, None)
798
799 _maybe_remove_and_reapply_group_offloading(self)
800
801 def enable_lora_hotswap(
802 self, target_rank: int = 128, check_compiled: Literal["error", "warn", "ignore"] = "error"

Calls 3

delete_adapter_layersFunction · 0.85
popMethod · 0.45