Skip to content

Commit 5783286

Browse files
[peft] simple update when unscale (#9689)
Update peft_utils.py Co-authored-by: Sayak Paul <[email protected]>
1 parent ee4ab23 commit 5783286

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/diffusers/utils/peft_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ def unscale_lora_layers(model, weight: Optional[float] = None):
134134
"""
135135
from peft.tuners.tuners_utils import BaseTunerLayer
136136

137-
if weight == 1.0:
137+
if weight is None or weight == 1.0:
138138
return
139139

140140
for module in model.modules():
141141
if isinstance(module, BaseTunerLayer):
142-
if weight is not None and weight != 0:
142+
if weight != 0:
143143
module.unscale_layer(weight)
144-
elif weight is not None and weight == 0:
144+
else:
145145
for adapter_name in module.active_adapters:
146146
# if weight == 0 unscale should re-set the scale to the original value.
147147
module.set_scale(adapter_name, 1.0)

0 commit comments

Comments
 (0)