-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ControlNet LoRA #1936
Support ControlNet LoRA #1936
Conversation
scripts/hook.py
Outdated
@@ -763,7 +769,7 @@ def hacked_group_norm_forward(self, *args, **kwargs): | |||
gn_modules = [model.middle_block] | |||
model.middle_block.gn_weight = 0 | |||
|
|||
input_block_indices = [4, 5, 7, 8, 10, 11] | |||
input_block_indices = [4, 5, 7, 8, 10, 11] if not getattr(process.sd_model, 'is_sdxl', False) else [4, 5, 7, 8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDXL only has 9 input blocks.
scripts/hook.py
Outdated
@@ -600,8 +606,8 @@ def forward(self, x, timesteps=None, context=None, **kwargs): | |||
h = aligned_adding(h, total_controlnet_embedding.pop(), require_inpaint_hijack) | |||
|
|||
# U-Net Decoder | |||
for i, module in enumerate(self.output_blocks): | |||
h = th.cat([h, aligned_adding(hs.pop(), total_controlnet_embedding.pop(), require_inpaint_hijack)], dim=1) | |||
for module, (hs_item, controlnet_embedding_item) in zip(self.output_blocks, reversed(list(zip(hs, total_controlnet_embedding)))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hs
has 9 tensor elements, while total_controlnet_embedding
has 10 tensor elements and 2 0
padding at the end.
This change aligns the 2 arrays, but I am not sure it is the correct fix here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That impl does not handle a tailing 0 for middle block weights. Revised the impl to calculate array length based on model type.
Currently got blocked on transformer arch issue. See details in #1933 (comment) In comfy's implementation, transformer depth is different at each level.
|
Comfy UI has following line doing some extra adjustment on input if self.num_classes is not None:
assert y.shape[0] == x.shape[0]
emb = emb + self.label_emb(y) Where label_emb is a network that converts self.label_emb = nn.Sequential(
nn.Sequential(
linear(adm_in_channels, time_embed_dim, dtype=self.dtype),
nn.SiLU(),
linear(time_embed_dim, time_embed_dim, dtype=self.dtype),
)
) And I am pretty sure something similar must also exists in A1111 and we just need to perform some mapping to get it to a format that However, from the experiment commenting out the Both result follows the guidance map. So probably we can live without it for now. |
d6eb229
to
8f1874a
Compare
Some testings on rank128 size S models: Using multiple units seems to be fine, but produce result with generally worse qualify. (Kinda expected?) @lllyasviel PTAL |
thank you so much amazing work |
thank you so much amazing and fast work |
I need to take a look if there is something wrong in the impl before it is going to merge, the saturation seems a bit weird and I am not sure that some of those artifacts are limitations of the released models. Also, we should begin to merge those after webui 1.6.x since there are much differences between 1.5.x and 1.6.x |
🚧 handle lora statedict 🔧 Fix yaml config issue Workaround all obvious errors Correctly overwrite Linear/Conv2D wip 🐛 Fix transformer depth issue 🐛 Fix SDXL middle block missing issue rename config nits
7295c9c
to
07f3be2
Compare
where you find control-lora-sdxl.yaml? |
wait. it seems that they are using a lora to construct a controlnet to control xl ... |
i don't think so they are pro as you so many people right now expecting controlnet for auto1111 |
to be continued in #1952 |
I dumped the config out of Comfy and made that yaml. |
This PR ports following change in ComfyUI(comfyanonymous/ComfyUI@d6e4b34).
There are seveal things this PR is going to achieve:
state_dict
to acceptable formatlinear
,conv_nd
operations when a ControlNet LoRA is loadedQuestions to be answered: