Skip to content

Commit

Permalink
Update peft_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetcocoa authored Oct 16, 2024
1 parent cef4f65 commit e587f8c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/diffusers/utils/peft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ def unscale_lora_layers(model, weight: Optional[float] = None):
"""
from peft.tuners.tuners_utils import BaseTunerLayer

if weight == 1.0:
if weight is None or weight == 1.0:
return

for module in model.modules():
if isinstance(module, BaseTunerLayer):
if weight is not None and weight != 0:
if weight != 0:
module.unscale_layer(weight)
elif weight is not None and weight == 0:
else:
for adapter_name in module.active_adapters:
# if weight == 0 unscale should re-set the scale to the original value.
module.set_scale(adapter_name, 1.0)
Expand Down

0 comments on commit e587f8c

Please sign in to comment.