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

Fix stable diffusion ONNX export following diffusers breaking change #1116

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

fxmarty
Copy link
Collaborator

@fxmarty fxmarty commented Jun 16, 2023

As per title and discussed on slack, slightly more minimal than #1108 given that SDPA ONNX export will be supported from PyTorch 2.1 onwards.

@echarlaix is it OK to have the requirement diffusers>=0.17.0?

@fxmarty fxmarty requested a review from echarlaix June 16, 2023 08:36
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 16, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for the fix @fxmarty !!

models_for_export["unet"] = (pipeline.unet, unet_onnx_config)

# VAE Encoder https://github.com/huggingface/diffusers/blob/v0.11.1/src/diffusers/models/vae.py#L565
vae_encoder = copy.deepcopy(pipeline.vae)
if hasattr(vae_encoder.encoder.mid_block.attentions[0], "_use_2_0_attn"):
vae_encoder.encoder.mid_block.attentions[0]._use_2_0_attn = False
if not packaging.version.parse(torch.__version__) >= packaging.version.parse("2.1.0"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could make sense to add a is_torch_version in the future (or check_if_torch_greater)

@echarlaix echarlaix merged commit f34cdc5 into huggingface:main Jun 16, 2023
63 of 64 checks passed
echarlaix pushed a commit that referenced this pull request Jun 16, 2023
…1116)

fix stable diffusion export after breaking change in diffusers
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

Successfully merging this pull request may close these issues.

None yet

3 participants