Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling Flash Attention completely breaks prompt following ("Dog" and "Cat" generates identical image) #259

Open
JohnAlcatraz opened this issue May 11, 2024 · 0 comments

Comments

@JohnAlcatraz
Copy link

JohnAlcatraz commented May 11, 2024

Enabling Flash Attention completely breaks prompt following, there has to be a bug in the flash attention implementation.

I reproduced this with the simplest possible setup, two identical locally compiled versions of stablediffusion.cpp, once compiled with cmake .. -DSD_FLASH_ATTN=OFF and once compiled with cmake .. -DSD_FLASH_ATTN=ON.

The exact commands I use are

./sd.exe -m S:\Downloads\v1-5-pruned-emaonly.safetensors -p "cat" --steps 10
and
./sd.exe -m S:\Downloads\v1-5-pruned-emaonly.safetensors -p "cat" --steps 10

so it's always using the exact same seed.

These are the results for the prompt "cat" and "dog" with flash attention disabled:

cat reg
dog reg

And these are the results for the prompt "cat" and "dog" with flash attention enabled:

cat
dog

Enabling flash attention appears to lead to the prompt getting completely ignored and the model generating whatever it wants to generate when no prompt is supplied.

Apart from this issue, flash attention works well to successfully reduce the memory usage by ~400 MB and also increase the generation speed by ~1 second though, so it would be very useful if it would also generate correct images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant