Add 2nd order heun scheduler
This PR shows how we can integrate Heun's scheduler into our current framework without any changes to the pipelineis.
We simply stretch the timesteps and sigmas => I honestly don't it's bad/wrong & a better design than adding a second loop. We would have to interpret the timesteps as "flattened along all orders" timesteps the model has to run through" instead of "timesteps the model has to run through num_order times".
The documentation is not available anymore as the PR was closed or merged.
Thanks a lot for the corrections @pcuenca @patil-suraj @keturn.
The PR as is now is functional and gives 1-to-1 the same results as k-diffusion:
#!/usr/bin/env python3
from diffusers import DiffusionPipeline, StableDiffusionPipeline, HeunDiscreteScheduler
import torch
seed = 33
pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", custom_pipeline="sd_text2img_k_diffusion")
pipe = pipe.to("cuda")
prompt = "an astronaut riding a horse on mars"
pipe.set_sampler("sample_heun")
generator = torch.Generator(device="cuda").manual_seed(seed)
image = pipe(prompt, generator=generator, num_inference_steps=20).images[0]
image.save("./astronaut_heun_k_diffusion_comp.png")
pipe = StableDiffusionPipeline(**pipe.components)
pipe = pipe.to("cuda")
pipe.scheduler = HeunDiscreteScheduler.from_config(pipe.scheduler.config)
generator = torch.Generator(device="cuda").manual_seed(seed)
image = pipe(prompt, generator=generator, num_inference_steps=20).images[0]
image.save("./astronaut_heun_comp.png")
K Diffusion

This PR (Diffusers)
