Skip to content
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

Add ControlNet Pipeline #585

Merged
merged 12 commits into from
Jan 30, 2024
Merged

Add ControlNet Pipeline #585

merged 12 commits into from
Jan 30, 2024

Conversation

nngokhale
Copy link
Contributor

@nngokhale nngokhale commented Dec 6, 2023

What does this PR do?

Adds ControlNet pipeline.
The port is based on GaudiStableDiffusionPipeline.

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@nngokhale nngokhale requested a review from regisss as a code owner December 6, 2023 13:44
Copy link
Collaborator

@libinta libinta left a comment

Choose a reason for hiding this comment

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

can you rebase to latest?

@nngokhale nngokhale force-pushed the controlnet branch 2 times, most recently from e22fb1d to 56da112 Compare December 16, 2023 06:06
@nngokhale
Copy link
Contributor Author

can you rebase to latest?

Done

@nngokhale nngokhale force-pushed the controlnet branch 6 times, most recently from cf5d5a4 to e87c4ed Compare December 20, 2023 07:22
@nngokhale nngokhale requested a review from libinta December 21, 2023 05:59
from diffusers.utils.torch_utils import is_compiled_module
from ....utils import speed_metrics, HabanaProfile
from ..pipeline_utils import GaudiDiffusionPipeline

Copy link
Collaborator

Choose a reason for hiding this comment

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

please use #611 as guideline to port this file. also move the pipeline_controlnet.py under pipelines

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, there should be things that are not necessary anymore. I'm going to try to point them out below.


# Workaround for Synapse 1.11 for full bf16
if bf16_full_eval:
unet.conv_in.float()
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove line141-142

Copy link
Collaborator

Choose a reason for hiding this comment

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

@libinta We don't need this anymore?

Copy link
Collaborator

@libinta libinta left a comment

Choose a reason for hiding this comment

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

also, please check https://github.com/huggingface/optimum-habana/blob/main/tests/test_diffusers.py to add test case for regression protection

@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.

Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

There are many comments related to #611 that should be quick to address.

Can you also run the following to make sure the code format is right please?

pip install --upgrade ruff
make style

from diffusers.utils.torch_utils import is_compiled_module
from ....utils import speed_metrics, HabanaProfile
from ..pipeline_utils import GaudiDiffusionPipeline

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, there should be things that are not necessary anymore. I'm going to try to point them out below.

@nngokhale nngokhale force-pushed the controlnet branch 2 times, most recently from 200c908 to e0dab26 Compare January 12, 2024 14:52
@regisss
Copy link
Collaborator

regisss commented Jan 15, 2024

@nngokhale Can you integrate the new ControlNet example into the existing Stable Diffusion example please? It will be much easier to maintain as there is a lot of duplicated code.

@nngokhale
Copy link
Contributor Author

@nngokhale Can you integrate the new ControlNet example into the existing Stable Diffusion example please? It will be much easier to maintain as there is a lot of duplicated code.
Yes, working on it and all other comments. Sorry for the delay, lost access to gaudi systems for couple of weeks.

@nngokhale
Copy link
Contributor Author

There are many comments related to #611 that should be quick to address.

Can you also run the following to make sure the code format is right please?

pip install --upgrade ruff
make style

Style fixed

@nngokhale
Copy link
Contributor Author

also, please check https://github.com/huggingface/optimum-habana/blob/main/tests/test_diffusers.py to add test case for regression protection

Added tests for ControlNet pipeline.

@nngokhale nngokhale requested a review from regisss January 19, 2024 18:51
@nngokhale
Copy link
Contributor Author

All comments / issues have been resolved, please review.

@vidyasiv vidyasiv mentioned this pull request Jan 19, 2024
3 tasks
Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

I left a few comments.

Can you also run make style please?

Do you have any throughput number to share?

@nngokhale
Copy link
Contributor Author

I left a few comments.

Can you also run make style please?

Do you have any throughput number to share?

Resolved latest comments, ran 'make style'.

Here are my throughput numbers:

For 512x512, 1 prompt, 50 inf steps, 20 generations per prompt, 4 samples per batch, BF16 + HPU Graphs,

on Gaudi2 HL-SMI: hl-1.13.0-rc-fw-47.0.0.0, Habana Driver: 1.13.0-ee32e42, Installed Habana Torch plug-in: 1.13.0.463, Installed Optimum-Habana: 1.10.0.dev0

GaudiStableDiffusionControlNetPipeline with lllyasviel/sd-controlnet-canny and runwayml/stable-diffusion-v1-5
Speed metrics: {'generation_runtime': 112.9972, 'generation_samples_per_second': 0.693, 'generation_steps_per_second': 0.289}

For comparison
GaudiStableDiffusionPipeline with runwayml/stable-diffusion-v1-5
Speed metrics: {'generation_runtime': 83.9506, 'generation_samples_per_second': 0.975, 'generation_steps_per_second': 0.406}

@nngokhale nngokhale requested a review from regisss January 25, 2024 10:53
@regisss regisss added the run-test Run CI for PRs from external contributors label Jan 30, 2024
Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

LGTM!

@regisss regisss merged commit 937a411 into huggingface:main Jan 30, 2024
11 of 12 checks passed
regisss pushed a commit that referenced this pull request Feb 12, 2024
jychen21 pushed a commit to jychen21/optimum-habana that referenced this pull request Feb 27, 2024
dudilester pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Feb 29, 2024
dudilester pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Feb 29, 2024
HolyFalafel pushed a commit to HabanaAI/optimum-habana-fork that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-test Run CI for PRs from external contributors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants