Skip to content

Conversation

@suvadityamuk
Copy link
Contributor

What does this PR do?

Partially fixes #6503 concerning ControlNet's Training Script. Followed along with #6483 and #6511.

Before submitting

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.

@sayakpaul @patrickvonplaten

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thank you! Let's maybe wait for #6511 to get merged. Then we can ship this!

@suvadityamuk suvadityamuk changed the title Make ControlNet Training Script torch.compile compatible Make ControlNet SD Training Script torch.compile compatible Jan 11, 2024
@HuggingFaceDocBuilderDev

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.

logger.info("Initializing controlnet weights from unet")
controlnet = ControlNetModel.from_unet(unet)

# Taken from [Sayak Paul's Diffusers PR #6511](https://github.com/huggingface/diffusers/pull/6511/files)
Copy link
Member

Choose a reason for hiding this comment

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

Remove it. Not a problem. But I appreciate the thoughtfulness.


# Get the text embedding for conditioning
encoder_hidden_states = text_encoder(batch["input_ids"])[0]
encoder_hidden_states = text_encoder(batch["input_ids"], return_dict=False)[0]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: For ControlNet training on SD, it won't matter (same for SDXL) as we never train the text encoder during ControlNet training. But keeping it this way doesn't hurt things. So, I am okay with it.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thank you!

@sayakpaul sayakpaul merged commit f486d34 into huggingface:main Jan 12, 2024
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…gface#6525)

* update: make controlnet script torch compile compatible

Signed-off-by: Suvaditya Mukherjee <[email protected]>

* update: correct earlier mistakes for compilation

Signed-off-by: Suvaditya Mukherjee <[email protected]>

* update: fix code style issues

Signed-off-by: Suvaditya Mukherjee <[email protected]>

---------

Signed-off-by: Suvaditya Mukherjee <[email protected]>
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.

[Training] Make officially maintained training scripts compatible with torch.compile()

3 participants