-
Couldn't load subscription status.
- Fork 6.5k
Make flow match euler discrete scheduler thread-safe. #9848
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
Make flow match euler discrete scheduler thread-safe. #9848
Conversation
|
I guess this is to make our schedulers thread-safe so that image generation can be performed in multi-threaded environments? |
|
Yes, but just for the |
|
i'm guessing you're sharing a model instance between threads which then causes all threads to access same scheduler instance? |
Yes. They are sharing a model instance. I believe to have a diffusers backed service there is no other reasonable way to do this because you are probably going to overload your GPU with more than one instance of something like sd-3.5-large.
I'm not exactly sure that it is cleaner, but I was able to get this working without modifying the scheduler by using from_pipe. In the endpoint of my server: with the shared pipeline being defined globally to avoid loading the model multiple times into memory: I'm fine if y'all think that is cleaner ¯\_(ツ)_/¯ I kind of like making the pipeline/scheduler more fault resistant by making the schedulers thread-safe. That seems like it results in simpler code for people that are more casual users of the library. Another option would be making the use of |
you want to share the loaded components, not full instance. |
|
Can you link to an example of that or show what that would look like in code? I'm really not sure what you are referring to. Is it different than what I did above? |
|
ah, just saw you actually used
my worry is such approach can cause unnecessary gpu sync calls in cases where variable might be a tensor. |
|
hi @thealmightygrant @vladmandic |
Thanks for your help, it's very helpful to me! |
|
Closing in favor of #9918 |
What does this PR do?
This is a partial fix just for the euler discrete scheduler that is used by default for the Stable Diffusion 3 pipeline for #3672. I am unsure how to do this as a generic fix, nor do I think it would go along with the HF diffusers philosophy doc if it was possible.
I've tested this with my local
fastapiserver, and it has no issues with generating images concurrently using theStableDiffusion3Pipeline.Let me know if you like this change, and I can do some updates to some other schedulers to make them usable in servers that want to do concurrent generation of images.
Before submitting
Did you read the contributor guideline?
Did you read our philosophy doc (important for complex PRs)?
Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
Did you make sure to update the documentation with your changes? Here are the
documentation guidelines, and
here are tips on formatting docstrings.
Did you write any new necessary tests?
Schedulers: @yiyixuxu