Skip to content

Commit 457ff5d

Browse files
committed
[LoRA] fix adapter movement when using DoRA. (#9411)
fix adapter movement when using DoRA.
1 parent 4bc1d70 commit 457ff5d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: src/diffusers/loaders/lora_base.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,10 @@ def set_lora_device(self, adapter_names: List[str], device: Union[torch.device,
699699
module.lora_B[adapter_name].to(device)
700700
# this is a param, not a module, so device placement is not in-place -> re-assign
701701
if hasattr(module, "lora_magnitude_vector") and module.lora_magnitude_vector is not None:
702-
module.lora_magnitude_vector[adapter_name] = module.lora_magnitude_vector[
703-
adapter_name
704-
].to(device)
702+
if adapter_name in module.lora_magnitude_vector:
703+
module.lora_magnitude_vector[adapter_name] = module.lora_magnitude_vector[
704+
adapter_name
705+
].to(device)
705706

706707
@staticmethod
707708
def pack_weights(layers, prefix):

0 commit comments

Comments
 (0)