|
4 | 4 |
|
5 | 5 | from invokeai.backend.patches.layers.base_layer_patch import BaseLayerPatch
|
6 | 6 | from invokeai.backend.patches.layers.merged_layer_patch import MergedLayerPatch, Range
|
7 |
| -from invokeai.backend.patches.layers.utils import any_lora_layer_from_state_dict |
| 7 | +from invokeai.backend.patches.layers.utils import any_lora_layer_from_state_dict, diffusers_adaLN_lora_layer_from_state_dict |
8 | 8 | from invokeai.backend.patches.lora_conversions.flux_lora_constants import FLUX_LORA_TRANSFORMER_PREFIX
|
9 | 9 | from invokeai.backend.patches.model_patch_raw import ModelPatchRaw
|
10 | 10 |
|
@@ -86,15 +86,8 @@ def add_adaLN_lora_layer_if_present(src_key: str, dst_key: str) -> None:
|
86 | 86 | if src_key in grouped_state_dict:
|
87 | 87 | src_layer_dict = grouped_state_dict.pop(src_key)
|
88 | 88 | values = get_lora_layer_values(src_layer_dict)
|
89 |
| - |
90 |
| - for _key in values.keys(): |
91 |
| - # in SD3 original implementation of AdaLayerNormContinuous, it split linear projection output into shift, scale; |
92 |
| - # while in diffusers it split into scale, shift. Here we swap the linear projection weights in order to be able to use diffusers implementation |
93 |
| - scale, shift = values[_key].chunk(2, dim=0) |
94 |
| - values[_key] = torch.cat([shift, scale], dim=0) |
95 |
| - |
96 |
| - layers[dst_key] = any_lora_layer_from_state_dict(values) |
97 |
| - |
| 89 | + layers[dst_key] = diffusers_adaLN_lora_layer_from_state_dict(values) |
| 90 | + |
98 | 91 | def add_qkv_lora_layer_if_present(
|
99 | 92 | src_keys: list[str],
|
100 | 93 | src_weight_shapes: list[tuple[int, int]],
|
|
0 commit comments