Fix a bug for SD35 control net training and improve control net block index#10065
Merged
yiyixuxu merged 7 commits intohuggingface:mainfrom Dec 5, 2024
linjiapro:fix-controlnet-training-bug
Merged
Fix a bug for SD35 control net training and improve control net block index#10065yiyixuxu merged 7 commits intohuggingface:mainfrom linjiapro:fix-controlnet-training-bug
yiyixuxu merged 7 commits intohuggingface:mainfrom
linjiapro:fix-controlnet-training-bug
Conversation
Contributor
Author
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)] |
Contributor
Author
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.
Member
|
Thanks for the PR. Could you also add some tests to the PR? |
Collaborator
|
thanks! |
|
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. |
Contributor
Author
|
@yiyixuxu make style is done! |
Contributor
Author
@sayakpaul |
yiyixuxu
approved these changes
Dec 5, 2024
Collaborator
|
thank you @linjiapro ! |
sayakpaul
added a commit
that referenced
this pull request
Dec 23, 2024
… index (#10065) * wip --------- Co-authored-by: YiYi Xu <yixu310@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.