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

LMS sampler question #76

Closed
catboxanon opened this issue Aug 6, 2023 · 2 comments
Closed

LMS sampler question #76

catboxanon opened this issue Aug 6, 2023 · 2 comments

Comments

@catboxanon
Copy link

Hi Katherine,

Wondering if something is wrong with the LMS sampler. We've had several issues open for quite a long time in the stable-diffusion-webui repo but were never really investigated until recently. DPM2 was resolved a long while back but LMS was not.

DPM2: #43, AUTOMATIC1111/stable-diffusion-webui#5797
LMS: AUTOMATIC1111/stable-diffusion-webui#1973, AUTOMATIC1111/stable-diffusion-webui#7244

Below is an example of a result produced currently by LMS using the default scheduler in the webui. PNG info is embedded in the image to reference if needed.

lms1

I had attempted to make a PR in AUTOMATIC1111/stable-diffusion-webui#12349 to resolve this. The way I did this was by discarding the penultimate sigma and to also use the penultimate latent (what the last callback would return for the last step). A naive approach I'm sure, but this is that result:

lms2

@AUTOMATIC1111 reviewed this PR and had suggested the issue stems from the last step combining the previous 4 steps, and suggested a fix.

AUTOMATIC1111/stable-diffusion-webui#12349 (comment)

After going into that function with a debugger, it looks like it combines denoised image from 4 last sampling steps to produce the next denoised image. cur_order variable determines how many previous steps to combine - it starts at 1, and grows to 4, and stays at 4. The last step where it combines four last denoised images into the final result produces those artifacts. I found that making cur_order go back to 1 at the end of sampling instead of staying at 4 improves the result dramatically. The relevant change is from cur_order = min(i + 1, order) to cur_order = min(i + 1, order, len(sigmas) - i - 1).

When instead only applying that change, I get this result:

lms3

Both of these modifications are clearly better than how the current code behaves but neither of us are sure what is correct here. Hoping you could provide some explanation on whether this is expected or not and how it should be properly resolved.

@Olk14
Copy link

Olk14 commented Oct 27, 2023

I've had this issue since June and have tried everuthing to resolve it.

@catboxanon
Copy link
Author

Closing as stale.

@catboxanon catboxanon closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants