-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Stable Diffusion and SDXL Callbacks are fundamentally broken for prompt_embeds #9906
Comments
I can and will create a monkeypatch in my code for the time being, but that is a lot of code duplication for something that should be handled inside the pipelines. (OK the monkeypatch isn't that bad, but the problem remains) |
can you provide the callback example that you're trying to implement? |
the point of the callback is to be two way so values can be changed. if some values are two way and some are one way only, it's bad. what we're trying to do is to alter emdeds per step. |
The problem comes when attempting to feed prompt embeddings back into the denoising loop, here's an attempt at non-optimized code:
This works if CFG is disabled, because the negatives are ignored If CFG is enabled:
works, but again fails if CFG is disabled, so the callback is required to determine |
Describe the bug
I'm working on implementing scheduled prompting in SDNext and realized that the callback in SDXL pipelines is fundamentally not functional. This also applies to Stable Diffusion Pipelines and likely others.
diffusers/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Lines 1245 to 1252 in dac623b
Of the preceding lines the following variables are completely useless as they are not referenced inside the denoising loop and thus adjusting them in the callback can do nothing:
negative_prompt_embeds
negative_pooled_prompt_embeds
negative_add_time_ids
If
self.do_classifier_free_guidance
is True, the other variable are concatenations of themselves and their negative counterparts, and not what their variables state.diffusers/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Line 1126 in dac623b
For the callback to operate intuitively, the code following
# 7
should be split out into a separate function, and following the variables NOT overwritten:prompt_embeds
add_text_embeds
(naming convention should be fixed)add_time_ids
That function should then be called post-callback to update all of the associated concat variables.
Reproduction
N/A
This is a code only issue.
Logs
No response
System Info
N/A
Who can help?
@yiyixuxu @sayakpaul
The text was updated successfully, but these errors were encountered: