Skip to content

Commit 9159a58

Browse files
Fix mutable default args in lora_base.py (#14064)
Fix mutable default args in LoRA mixin Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
1 parent dbe1258 commit 9159a58

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/diffusers/loaders/lora_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def unload_lora_weights(self):
536536

537537
def fuse_lora(
538538
self,
539-
components: list[str] = [],
539+
components: list[str] | None = None,
540540
lora_scale: float = 1.0,
541541
safe_fusing: bool = False,
542542
adapter_names: list[str] | None = None,
@@ -569,6 +569,9 @@ def fuse_lora(
569569
pipeline.fuse_lora(lora_scale=0.7)
570570
```
571571
"""
572+
if components is None:
573+
components = []
574+
572575
if "fuse_unet" in kwargs:
573576
depr_message = "Passing `fuse_unet` to `fuse_lora()` is deprecated and will be ignored. Please use the `components` argument and provide a list of the components whose LoRAs are to be fused. `fuse_unet` will be removed in a future version."
574577
deprecate(
@@ -620,7 +623,7 @@ def fuse_lora(
620623

621624
self._merged_adapters = self._merged_adapters | merged_adapter_names
622625

623-
def unfuse_lora(self, components: list[str] = [], **kwargs):
626+
def unfuse_lora(self, components: list[str] | None = None, **kwargs):
624627
r"""
625628
Reverses the effect of
626629
[`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora).
@@ -634,6 +637,9 @@ def unfuse_lora(self, components: list[str] = [], **kwargs):
634637
Whether to unfuse the text encoder LoRA parameters. If the text encoder wasn't monkey-patched with the
635638
LoRA parameters then it won't have any effect.
636639
"""
640+
if components is None:
641+
components = []
642+
637643
if "unfuse_unet" in kwargs:
638644
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."
639645
deprecate(

0 commit comments

Comments
 (0)