-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[BugFix]: Fixed add_noise in LMSDiscreteScheduler #253
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
Conversation
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.
Ah, good catch! Will let @anton-l take a final look, he knows the best 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.
Hi @nicolas-dufour! For this particular sampler, the model needs to be trained similarly to DDPM/DDIM (i.e. with the current add_noise
). That's what works for Stable Diffusion, as far as I know (let me know if I misunderstand something!).
But if you find a way to convert the beta schedule closer to the original k-lms, feel free to update the PR :)
Hi @anton-l, I have tried to use the current add_noise with stable diffusion doing some img2img but it did not work and the only way i managed to make it work was to change add_noise to the proposed change. From what i can see from k-diffusion they also use this noise technique at train time (https://github.com/crowsonkb/k-diffusion/blob/3f93c28088890e4d6bc593072739e1d6e759b392/k_diffusion/layers.py#L28). It's also what is proposed by the original Karras et al paper on which k-diffusion scheduler is based (https://arxiv.org/pdf/2206.00364.pdf Algo 2). |
Thanks for the links here @nicolas-dufour - from reading the code a bit, I think the sampler can work with both cases, e.g. it can work for inference on a model that was trained on classic DDPM, but as @nicolas-dufour pointed out one should also be able to train the model with the original formula. Could we maybe allow for both and add a config parameter? Something like: |
I'm in favor of this. As @nicolas-dufour said, the current |
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
The documentation is not available anymore as the PR was closed or merged. |
@anton-l let's merge this and then move onto your follow-up PR? |
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.
@nicolas-dufour thank you for the fix! Your investigation spawned another PR for img2img and K-LMS compatibility in general, so feel free to join the conversation, if you'd like: #270
Awesome addition @nicolas-dufour ❤️ |
* Fixed add_noise in LMSDiscreteScheduler * Linting * Update src/diffusers/schedulers/scheduling_lms_discrete.py Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
…ngface#253) * Disable passing of sm_arch to iree-compile CL args by default. * Fix formatting.
* Fixed add_noise in LMSDiscreteScheduler * Linting * Update src/diffusers/schedulers/scheduling_lms_discrete.py Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
The formulation of add noise is LMSDiscreteScheduler is wrong (see crowsonkb/k-diffusion#4). This PR fixes that