r""" Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. Args: components (`List[str]
(self, components: List[str] = [], **kwargs)
| 458 | self.num_fused_loras += 1 |
| 459 | |
| 460 | def unfuse_lora(self, components: List[str] = [], **kwargs): |
| 461 | r""" |
| 462 | Reverses the effect of |
| 463 | [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). |
| 464 | |
| 465 | <Tip warning={true}> |
| 466 | |
| 467 | This is an experimental API. |
| 468 | |
| 469 | </Tip> |
| 470 | |
| 471 | Args: |
| 472 | components (`List[str]`): List of LoRA-injectable components to unfuse LoRA from. |
| 473 | unfuse_unet (`bool`, defaults to `True`): Whether to unfuse the UNet LoRA parameters. |
| 474 | unfuse_text_encoder (`bool`, defaults to `True`): |
| 475 | Whether to unfuse the text encoder LoRA parameters. If the text encoder wasn't monkey-patched with the |
| 476 | LoRA parameters then it won't have any effect. |
| 477 | """ |
| 478 | if "unfuse_unet" in kwargs: |
| 479 | depr_message = "Passing `unfuse_unet` to `unfuse_lora()` is deprecated and will be ignored. Please use the `components` argument. `unfuse_unet` will be removed in a future version." |
| 480 | deprecate( |
| 481 | "unfuse_unet", |
| 482 | "1.0.0", |
| 483 | depr_message, |
| 484 | ) |
| 485 | if "unfuse_transformer" in kwargs: |
| 486 | depr_message = "Passing `unfuse_transformer` to `unfuse_lora()` is deprecated and will be ignored. Please use the `components` argument. `unfuse_transformer` will be removed in a future version." |
| 487 | deprecate( |
| 488 | "unfuse_transformer", |
| 489 | "1.0.0", |
| 490 | depr_message, |
| 491 | ) |
| 492 | if "unfuse_text_encoder" in kwargs: |
| 493 | depr_message = "Passing `unfuse_text_encoder` to `unfuse_lora()` is deprecated and will be ignored. Please use the `components` argument. `unfuse_text_encoder` will be removed in a future version." |
| 494 | deprecate( |
| 495 | "unfuse_text_encoder", |
| 496 | "1.0.0", |
| 497 | depr_message, |
| 498 | ) |
| 499 | |
| 500 | if len(components) == 0: |
| 501 | raise ValueError("`components` cannot be an empty list.") |
| 502 | |
| 503 | for fuse_component in components: |
| 504 | if fuse_component not in self._lora_loadable_modules: |
| 505 | raise ValueError(f"{fuse_component} is not found in {self._lora_loadable_modules=}.") |
| 506 | |
| 507 | model = getattr(self, fuse_component, None) |
| 508 | if model is not None: |
| 509 | if issubclass(model.__class__, (ModelMixin, PreTrainedModel)): |
| 510 | for module in model.modules(): |
| 511 | if isinstance(module, BaseTunerLayer): |
| 512 | module.unmerge() |
| 513 | |
| 514 | self.num_fused_loras -= 1 |
| 515 | |
| 516 | def set_adapters( |
| 517 | self, |
nothing calls this directly
no test coverage detected