"git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "e724785f1cf1708ce71b040b4b6db3cf71cdcd79"
Unverified Commit dc943eb9 authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

[Schedulers] Fix 2nd order other than heun (#5526)

* [Schedulers] Fix 2nd order other than heun

* Apply suggestions from code review
parent 0fc25715
......@@ -898,9 +898,9 @@ class StableDiffusionXLControlNetInpaintPipeline(
)
num_inference_steps = (timesteps < discrete_timestep_cutoff).sum().item()
if self.scheduler.order == 2:
# if the scheduler is a 2nd order scheduler we ALWAYS have to do +1
# because `num_inference_steps` will always be even given that every timestep
if self.scheduler.order == 2 and num_inference_steps % 2 == 0:
# if the scheduler is a 2nd order scheduler we might have to do +1
# because `num_inference_steps` might be even given that every timestep
# (except the highest one) is duplicated. If `num_inference_steps` is even it would
# mean that we cut the timesteps in the middle of the denoising step
# (between 1st and 2nd devirative) which leads to incorrect results. By adding 1
......
......@@ -555,9 +555,9 @@ class StableDiffusionXLImg2ImgPipeline(
)
num_inference_steps = (timesteps < discrete_timestep_cutoff).sum().item()
if self.scheduler.order == 2:
# if the scheduler is a 2nd order scheduler we ALWAYS have to do +1
# because `num_inference_steps` will always be even given that every timestep
if self.scheduler.order == 2 and num_inference_steps % 2 == 0:
# if the scheduler is a 2nd order scheduler we might have to do +1
# because `num_inference_steps` might be even given that every timestep
# (except the highest one) is duplicated. If `num_inference_steps` is even it would
# mean that we cut the timesteps in the middle of the denoising step
# (between 1st and 2nd devirative) which leads to incorrect results. By adding 1
......
......@@ -840,9 +840,9 @@ class StableDiffusionXLInpaintPipeline(
)
num_inference_steps = (timesteps < discrete_timestep_cutoff).sum().item()
if self.scheduler.order == 2:
# if the scheduler is a 2nd order scheduler we ALWAYS have to do +1
# because `num_inference_steps` will always be even given that every timestep
if self.scheduler.order == 2 and num_inference_steps % 2 == 0:
# if the scheduler is a 2nd order scheduler we might have to do +1
# because `num_inference_steps` might be even given that every timestep
# (except the highest one) is duplicated. If `num_inference_steps` is even it would
# mean that we cut the timesteps in the middle of the denoising step
# (between 1st and 2nd devirative) which leads to incorrect results. By adding 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment