nod-ai / SHARK

SHARK - High Performance Machine Learning Distribution
Apache License 2.0
1.41k stars 168 forks source link

Flat beige images with SD 2.1 for any scheduler but SharkEulerDiscrete #1337

Open one-lithe-rune opened 1 year ago

one-lithe-rune commented 1 year ago

If I use any scheduler other than SharkEulerDiscrete with the stablediffusion-2-1 model I get flat beige images (with some variation in shade of beige across the image).

I see this with both 648 and 693, and with both the default target triple for my card (Radeon VII) rdna2-unknown-windows and with the rgcn5-radeonvii-windows target triple (which might be more correct?).

This doesn't occur with stablediffusion-2-1-base in 693. I haven't tested this with that model in 648.

If I do use SharkEulerDiscrete I get normal looking images generated.

Drivers are Adrenalin 23.3.2, and I have AMD_ENABLE_LLPC=1 set in my envars.

nirvedhmeshram commented 1 year ago

I can reproduce this on my nvidia turing card as well so is most likely happening across all platforms

one-lithe-rune commented 1 year ago

I believe the immediate cause is that the pipeline code path sets up the schedulers for the selected model stablediffusion-2-1 before it gets to these lines which switch over to stablediffusion-2-1-base:

https://github.com/nod-ai/SHARK/blob/d63ce76dd88a8d487338a7826744857be9f01045/apps/stable_diffusion/src/models/model_wrappers.py#L111-L113

...the CPU schedulers therefore remain setup for 2.1 and therefore their config suddenly becomes incorrect.

When I tried just taking out those workaround lines a week or so back, that just left things in a different broken state, so presumably stablediffusion-2-1 is still not working with the code otherwise as is.

SharkEulerDiscrete working is a bit of mystery. Perhaps it would become broken if 2.1 was working and the workaround was removed. Dunno.