MCPcopy Create free account
hub / github.com/huggingface/diffusers / unload_lora_weights

Method unload_lora_weights

src/diffusers/loaders/lora_base.py:514–535  ·  view source on GitHub ↗

Unloads the LoRA parameters. Examples: ```python >>> # Assuming `pipeline` is already loaded with the LoRA parameters. >>> pipeline.unload_lora_weights() >>> ... ```

(self)

Source from the content-addressed store, hash-verified

512 raise NotImplementedError("`lora_state_dict()` is not implemented.")
513
514 def unload_lora_weights(self):
515 """
516 Unloads the LoRA parameters.
517
518 Examples:
519
520 ```python
521 >>> # Assuming `pipeline` is already loaded with the LoRA parameters.
522 >>> pipeline.unload_lora_weights()
523 >>> ...
524 ```
525 """
526 if not USE_PEFT_BACKEND:
527 raise ValueError("PEFT backend is required for this method.")
528
529 for component in self._lora_loadable_modules:
530 model = getattr(self, component, None)
531 if model is not None:
532 if issubclass(model.__class__, ModelMixin):
533 model.unload_lora()
534 elif issubclass(model.__class__, PreTrainedModel):
535 _remove_text_encoder_monkey_patch(model)
536
537 def fuse_lora(
538 self,

Calls 2

unload_loraMethod · 0.45