Skip to content

Fixing implementation of ControlNet-XS #6772

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

Merged
merged 92 commits into from
Apr 16, 2024
Merged

Conversation

UmerHA
Copy link
Contributor

@UmerHA UmerHA commented Jan 30, 2024

What does this PR do?

Implements ControlNet-XS with the feedback from PR #5827 incorporated.

See original PR for details.

Who can review?

Core library:

@DN6
Copy link
Collaborator

DN6 commented Apr 8, 2024

Looking good overall 👍🏽 Left some comments.

Regarding the naming, we could perhaps call the module ControlNetXSAdapter? Since its behaviour is similar to our other adapters? cc: @yiyixuxu

UmerHA added 4 commits April 8, 2024 10:19
- Importing ControlNetConditioningEmbedding now
- get_down/mid/up_block_addon now outside class
- renamed `do_control` to `apply_control`
For this, added `norm_num_groups` as parameter everywhere
@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Apr 8, 2024

Regarding the naming, we could perhaps call the module ControlNetXSAdapter? Since its behaviour is similar to our other adapters?

ok!

- `ControlNetXSAddon` -> `ControlNetXSAdapter`
- `ControlNetXSAddonDownBlockComponents` -> `DownBlockControlNetXSAdapter`, and similarly for mid/up
- `get_mid_block_addon` -> `get_mid_block_adapter`, and similarly for mid/up
@UmerHA
Copy link
Contributor Author

UmerHA commented Apr 9, 2024

Regarding the naming, we could perhaps call the module ControlNetXSAdapter? Since its behaviour is similar to our other adapters?

ok!

Sounds good. Have renamed

  • ControlNetXSAddon -> ControlNetXSAdapter
  • ControlNetXSAddonDownBlockComponents -> DownBlockControlNetXSAdapter, and similarly for mid/up blocks
  • get_down_block_addon -> get_down_block_adapter, and similarly for mid/up

@yiyixuxu
Copy link
Collaborator

@UmerHA the failing tests look relevant here - can you look into and fix?

@UmerHA
Copy link
Contributor Author

UmerHA commented Apr 11, 2024

@yiyixuxu you were right - should be fixed now. can you rerun the tests?

@UmerHA
Copy link
Contributor Author

UmerHA commented Apr 15, 2024

The only failing test seems very unrelated to this PR:

CleanShot 2024-04-15 at 08 43 29@2x

cc @yiyixuxu

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

thanks!

@UmerHA
Copy link
Contributor Author

UmerHA commented Apr 15, 2024

@DN6 some of your comments aren't marked as resolved. do you have any more questions/feedback, or is it fine as is?

@DN6 DN6 merged commit fda1531 into huggingface:main Apr 16, 2024
@UmerHA UmerHA deleted the controlnetxs-2 branch April 16, 2024 16:27
@DN6
Copy link
Collaborator

DN6 commented Apr 16, 2024

@UmerHA All good. We can break up the tests in a follow up PR.

@DN6
Copy link
Collaborator

DN6 commented Apr 17, 2024

@UmerHA We have failing slow tests because the checkpoint doesn't seem to be updated. Can you take care of this please
Raised an issue: #7694

@UmerHA
Copy link
Contributor Author

UmerHA commented Apr 17, 2024

Have updated the models & ran the slow test on a T4 - works now.

sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
* CheckIn - created DownSubBlocks

* Added extra channels, implemented subblock fwd

* Fixed connection sizes

* checkin

* Removed iter, next in forward

* Models for SD21 & SDXL run through

* Added back pipelines, cleared up connections

* Cleaned up connection creation

* added debug logs

* updated logs

* logs: added input loading

* Update umer_debug_logger.py

* log: Loading hint

* Update umer_debug_logger.py

* added logs

* Changed debug logging

* debug: added more logs

* Fixed num_norm_groups

* Debug: Logging all of SDXL input

* Update umer_debug_logger.py

* debug: updated logs

* checkim

* Readded tests

* Removed debug logs

* Fixed Slow Tests

* Added value ckecks | Updated model_cpu_offload_seq

* accelerate-offloading works ; fast tests work

* Made unet & addon explicit in controlnet

* Updated slow tests

* Added dtype/device to ControlNetXS

* Filled in test model paths

* Added image_encoder/feature_extractor to XL pipe

* Fixed fast tests

* Added comments and docstrings

* Fixed copies

* Added docs ; Updates slow tests

* Moved changes to UNetMidBlock2DCrossAttn

* tiny cleanups

* Removed stray prints

* Removed ip adapters + freeU

- Removed ip adapters + freeU as they don't make sense for ControlNet-XS
- Fixed imports of UNet components

* Fixed test_save_load_float16

* Make style, quality, fix-copies

* Changed loading/saving API for ControlNetXS

- Changed loading/saving API for ControlNetXS
- other small fixes

* Removed ControlNet-XS from research examples

* Make style, quality, fix-copies

* Small fixes

- deleted ControlNetXSModel.init_original
- added time_embedding_mix to StableDiffusionControlNetXSPipeline .from_pretrained / StableDiffusionXLControlNetXSPipeline.from_pretrained
- fixed copy hints

* checkin May 11 '23

* CheckIn Mar 12 '24

* Fixed tests for SD

* Added tests for UNetControlNetXSModel

* Fixed SDXL tests

* cleanup

* Delete Pipfile

* CheckIn Mar 20

Started replacing sub blocks  by `ControlNetXSCrossAttnDownBlock2D` and `ControlNetXSCrossAttnUplock2D`

* check-in Mar 23

* checkin 24 Mar

* Created init for UNetCnxs and CnxsAddon

* CheckIn

* Made from_modules, from_unet and no_control work

* make style,quality,fix-copies & small changes

* Fixed freezing

* Added gradient ckpt'ing; fixed tests

* Fix slow tests(+compile) ; clear naming confusion

* Don't create UNet in init ; removed class_emb

* Incorporated review feedback

- Deleted get_base_pipeline /  get_controlnet_addon for pipes
- Pipes inherit from StableDiffusionXLPipeline
- Made module dicts for cnxs-addon's down/mid/up classes
- Added support for qkv fusion and freeU

* Make style, quality, fix-copies

* Implemented review feedback

* Removed compatibility check for vae/ctrl embedding

* make style, quality, fix-copies

* Delete Pipfile

* Integrated review feedback

- Importing ControlNetConditioningEmbedding now
- get_down/mid/up_block_addon now outside class
- renamed `do_control` to `apply_control`

* Reduced size of test tensors

For this, added `norm_num_groups` as parameter everywhere

* Renamed cnxs-`Addon` to cnxs-`Adapter`

- `ControlNetXSAddon` -> `ControlNetXSAdapter`
- `ControlNetXSAddonDownBlockComponents` -> `DownBlockControlNetXSAdapter`, and similarly for mid/up
- `get_mid_block_addon` -> `get_mid_block_adapter`, and similarly for mid/up

* Fixed save_pretrained/from_pretrained bug

* Removed redundant code

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants