Skip to content

Commit

Permalink
Update save lora weights for diffusers with text_encoder_2 layers (hu…
Browse files Browse the repository at this point in the history
  • Loading branch information
skavulya authored Dec 19, 2024
1 parent eee2d91 commit a51475f
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions optimum/habana/diffusers/pipelines/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,26 @@ def save_lora_weights(
text_encoder_lora_layers = to_device_dtype(text_encoder_lora_layers, target_device=torch.device("cpu"))
if text_encoder_2_lora_layers:
text_encoder_2_lora_layers = to_device_dtype(text_encoder_2_lora_layers, target_device=torch.device("cpu"))
return super().save_lora_weights(
save_directory,
unet_lora_layers,
text_encoder_lora_layers,
text_encoder_2_lora_layers,
is_main_process,
weight_name,
save_function,
safe_serialization,
)

# text_encoder_2_lora_layers is only supported by some diffuser pipelines
if text_encoder_2_lora_layers:
return super().save_lora_weights(
save_directory,
unet_lora_layers,
text_encoder_lora_layers,
text_encoder_2_lora_layers,
is_main_process,
weight_name,
save_function,
safe_serialization,
)
else:
return super().save_lora_weights(
save_directory,
unet_lora_layers,
text_encoder_lora_layers,
is_main_process,
weight_name,
save_function,
safe_serialization,
)

0 comments on commit a51475f

Please sign in to comment.