[bug]: KDPM 2 / KDPM 2 Ancestral schedulers don't produce expected output on M1
Is there an existing issue for this?
- [X] I have searched the existing issues
OS
macOS
GPU
mps
VRAM
15
What version did you experience this issue on?
3.3.0
What happened?
KDPM 2 / KDPM 2 Ancestral schedulers output visual noise on M1, (see example) from the below specs:
Generation Mode: txt2img Positive Prompt: an astronaught riding a unicorn in space Seed: 1 Model: stable-diffusion-v1-5 Width: 512 Height: 512 Scheduler: kdpm_2_a Steps: 10 CFG scale: 7
Changing these specs doesn't improve the output however.
Screenshots
Additional context
Predates 3.3.0
Contact Details
petecats
There is a behavioral difference between KDPM2 and KDPM2 Ancestral. Base KDPM2 produces a black image, while Ancestral produces color noise. In any case, I can confirm that these schedulers do not work on Apple Silicon.
M2 Max, Sonoma, Torch(Vision) nightlies October 14
just ran a quick test in Diffusers. Everything looks good until the last step, then the latents are all nan
[-0.8965, 2.5312, 1.4717, ..., -0.5049, -1.0488, 0.4048]]]],
device='mps:0', dtype=torch.float16)
100%|████| 10/10 [09:24<00:00, 47.57s/it]
18
tensor(1., device='mps:0')
tensor([[[[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
[nan, nan, nan, ..., nan, nan, nan],
...,
As you can see the latents from the step before where fine.
The issue seems to be that the sigma_interpol values are derived by a lerp of the log values of sigmas.
Digging further down its an MPS Pytorch with torch.lerp. lerping between -Inf and another value is -Inf on the CPU (and I guess CUDA) and NaN on MPS. That value is then used by exp, exp(-iInf) is 0 exp(NaN) is NaN
The NaN gets used to calculate the latent on the final step, leading to an all NaN latent.
https://github.com/pytorch/pytorch/issues/111374
Just looping back in to say that this has been resolved.
This appears to be reintroduced/regressed in 5.0 at least when doing upscale operations.