Uh oh!
There was an error while loading. Please reload this page.
Fix a bug for SD35 control net training and improve control net block index - #10065
Conversation
linjiapro
commented
Dec 1, 2024
| interval_control = len(self.transformer_blocks) / len(block_controlnet_hidden_states) | ||
| interval_control = int(np.ceil(interval_control)) | ||
| hidden_states = hidden_states + block_controlnet_hidden_states[index_block // interval_control] | ||
| hidden_states = hidden_states + block_controlnet_hidden_states[int(index_block / interval_control)] |
There was a problem hiding this comment.
Please note that this is a change that is backward compatible.
When len(self.transformer_blocks) is divisible by len(block_controlnet_hidden_states), which is 100% cases for all shipped controlnets, the logic does not change anything.
sayakpaul
commented
Dec 1, 2024
Thanks for the PR. Could you also add some tests to the PR? |
yiyixuxu
commented
Dec 3, 2024
thanks! |
HuggingFaceDocBuilderDev
commented
Dec 3, 2024
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
linjiapro
commented
Dec 4, 2024
@yiyixuxu make style is done! |
@sayakpaul |
yiyixuxu
commented
Dec 5, 2024
thank you @linjiapro ! |
… index (#10065) * wip --------- Co-authored-by: YiYi Xu <yixu310@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
What does this PR do?
In SD3.5, ControlNet uses a single-layer transformer and does not rely on encoder_hidden_states. The code has been updated accordingly to prevent crashes.
For SD3.5 Large, which consists of 38 transformer layers, setting the ControlNet layers to 16 layers caused inefficiencies during inference. This was due to the old index logic calculating interval_control as an integer 3, which resulted in the 38-layer SD3.5 Large transformer using only up to layer 13 of the 16-layer ControlNet. To address this, the indexing logic has been revised to calculate interval_control as a floating-point number, ensuring all 16 layers of ControlNet are utilized. This update is backward-compatible, meaning no changes occur for a 19-layer ControlNet.
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.