-
Notifications
You must be signed in to change notification settings - Fork 6.4k
add Sa-Solver #5975
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 Sa-Solver #5975
Conversation
Looping in @yiyixuxu here. |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
@lawrence-cj let's also add a testing suite here. You can refer to a test suite for schedulers here: |
awesome :) |
No problem, I will add a test for you. |
|
||
if isinstance(timestep, torch.Tensor): | ||
timestep = timestep.to(self.timesteps.device) | ||
step_index = (self.timesteps == timestep).nonzero() |
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.
Can we add a step_index counter instead of searching for the index at each step?
Like how it is done here for DPM
if self.step_index is None: |
Essentially we only need to search for the step_index once in the beginning, and then just increase the counter after each step
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.
We implemented sa-solver according to DPMSolverMultistep in diffusers==0.21.2. Could you please help us to change it to the newest implementation?
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.
sure :)
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.
As stated by @yiyixuxu, we need to change the logic to use a self.step_index
counter or else this scheduler won't function correctly when using karras sigmas or when doing img2img translation. Could you take a look at
if self.step_index is None: |
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.
Cc: @scxue
add sa solver test file
result_mean = torch.mean(torch.abs(sample)) | ||
|
||
if torch_device in ["mps"]: | ||
assert abs(result_sum.item() - 176.66974135742188) < 1e-2 |
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.
We have no idea how to get the specific value here.
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.
Think we can remove the mps check for now as well
assert abs(result_sum.item() - 167.47821044921875) < 1e-2 | ||
assert abs(result_mean.item() - 0.2178705964565277) < 1e-3 | ||
elif torch_device in ["cuda"]: | ||
assert abs(result_sum.item() - 171.59352111816406) < 1e-2 |
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.
What about this line? Wondering how to get the specific value 171.59352111816406, etc.
There are some tests failing here. Could we please fix them? |
I will let @yiyixuxu review this once the test failures are resolved. |
Gentle ping here @yiyixuxu |
* fix bugs in repository consistency
fix bugs in init file and sasolverscheduler file
update for code quality check
modify for step_index
We add |
make style
fix copy inconsistencies
Gentle ping here. @yiyixuxu |
Happy to merge whenever @yiyixuxu is happy here! |
Thx so much for your review. I'm wondering how you make this style automatically. : ) Any tools for it? @yiyixuxu |
@lawrence-cj if you installed our dev environment, you could run |
Oh, thank you so much for the information. @yiyixuxu |
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.
thanks!
@lawrence-cj |
* add Sa-Solver --------- Co-authored-by: Sayak Paul <[email protected]> Co-authored-by: scxue <[email protected]> Co-authored-by: jschen <[email protected]> Co-authored-by: Patrick von Platen <[email protected]> Co-authored-by: yiyixuxu <yixu310@gmail,com>
What does this PR do?
Add Sa-Solver into diffusers lib.
Cc: @patil-suraj. Really need your help to test it.