Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions diffsynth/utils/lora/flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def guess_alpha(state_dict):
dtype=state_dict_[name].dtype)
else:
state_dict_.pop(name.replace(".a_to_q.", ".proj_in_besides_attn."))

mlp = mlp.to(device=state_dict_[name].device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change introduces a small inefficiency. When mlp is created with torch.zeros (in the if mlp is None branch), it's created on the CPU and then moved to the target device here. This causes an unnecessary data copy. For better performance, it would be ideal to create the tensor directly on the target device by adding device=state_dict_[name].device to the torch.zeros call on line 147. This .to() call would then only be needed for the else branch.

if 'lora_A' in name:
param = torch.concat([
state_dict_.pop(name),
Expand Down