-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
instruct pix2pix pipeline: remove sigma scaling when computing classifier free guidance #7006
instruct pix2pix pipeline: remove sigma scaling when computing classifier free guidance #7006
Conversation
@erliding do you have some results for us to verify things here? Cc: @patil-suraj here as well. |
can you maybe run the docstring example with fixed seed from main branch and this branch and see if they are identical? |
yeah, so i tested with |
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. |
i ran the example below on main branch and this branch, it use |
Alright, thanks. But I varely see any qualitative difference though. |
it shouldn't, it is to show sigma scaling can be removed without introducing difference |
Alright, yes, that makes sense! |
I am okay with the changes but @patil-suraj needs to approve this. |
gentle pin @patil-suraj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! This was done to mimic the original code but actually shouldn't make difference here. Thanks a lot for the PR.
Fixes (#6981)
instruct pix2pix pipeline scale model prediction to sigma space before computing classifier free guidance and scale back when done for schedulers operating in sigma space, which seems unnecessary, especially when
rescale_betas_zero_snr
is enabled for those schedulers, this scaling can result in fp16 overflow with high rates and generating black imagesfor example
(noise_pred - latents)
below can goes beyond -65504 and result in-inf
for fp16 (for this specific case reorganize rhs of the assignment tolatents / sigma - noise_pred / sigma
should also work)diffusers/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py
Line 439 in 3a7e481
@yiyixuxu @sayakpaul