ml-stable-diffusion: diffusers==0.16.0 not working with PyTorch default v2.0.0
Hi team,
I got an error when executing python -m python_coreml_stable_diffusion.torch2coreml, it seems diffusers==0.16.0 not working on PyTorch v2.0.0. Use diffusers==0.15.1 works. See following threads.
convert_nodes(self.context, self.graph)
File "/opt/homebrew/Caskroom/miniconda/base/envs/coreml_stable_diffusion/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 83, in convert_nodes
raise RuntimeError(
RuntimeError: PyTorch convert function for op 'scaled_dot_product_attention' not implemented.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
There is a PR that I think fixes this issue here: https://github.com/apple/coremltools/pull/2021
Another workaround is to add the following line after the pipeline has been loaded:
Oh, that’s probably because scaled dot-product attention is enabled by default if torch 2 is in use.
pipe.unet.set_default_attn_processor()should work. I can test and submit a PR in a few hours.Edit: The same behaviour (enabling SDPA by default) was already present in
0.15.1so we might indeed have a regression. I’ll take a closer look.If your job completes successfully, that seems to mean that
diffusers 0.16.0introduced a software regression that is causing the error for both of us. Perhaps revise the title of this thread and hopefully the issue can get fixed?