EulerDiscreteScheduler is not complete and sign of c_out is wrong
Describe the bug
Hi, the implementation of EDM method here https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_discrete.py misses the second-order correction step implemented here in the original paper https://arxiv.org/pdf/2206.00364.pdf: please see https://github.com/NVlabs/edm/blob/b2a26c921c5776cb52f7498248761d60649007a8/example.py#L65
# Apply 2nd order correction.
if i < num_steps - 1:
denoised = net(x_next, t_next, class_labels).to(torch.float64)
d_prime = (x_next - denoised) / t_next
x_next = x_hat + (t_next - t_hat) * (0.5 * d_cur + 0.5 * d_prime)
without this step algorithm 2 in the paper is not complete. Also on this line: https://github.com/huggingface/diffusers/blob/0b7225e91852df668ce85a7f7a670c00272c9ed0/src/diffusers/schedulers/scheduling_euler_discrete.py#L238 the sign for c_out ((sigma / (sigma**2 + 1) ** 0.5) ) is not correct, from:
pred_original_sample = model_output * (-sigma / (sigma**2 + 1) ** 0.5) + (sample / (sigma**2 + 1))
this should be converted to:
pred_original_sample = model_output * (sigma / (sigma**2 + 1) ** 0.5) + (sample / (sigma**2 + 1))
It would be great if this could be corrected. Thank you.
Reproduction
-
Logs
-
System Info
Last version of diffusers in the github.
Hey @cameronalonso2,
I think we should add a new scheduler "Euler2" for this. We should have finished this by the end of this week
Hi @patrickvonplaten thank you. It would be awesome. May I ask which method is the one implemented? and in which paper this is proposed? When I was testing it, I was not able to get the generation to work with this sampler, and I wanted to check the details in your know the original paper. thanks.
Sure the current method comes from: https://github.com/crowsonkb/k-diffusion/blob/5b3af030dd83e0297272d861c19477735d0317ec/k_diffusion/sampling.py#L118
Thank you
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.