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

add attention up/down blocks for VAE #161

Merged
merged 1 commit into from
Aug 10, 2022
Merged

Conversation

patil-suraj
Copy link
Contributor

@patil-suraj patil-suraj commented Aug 8, 2022

Our current VAE does not support having attention in encoder/decoder block as none of the pre-trained models had one. But looking at the stable-diffusion upscaling and RDM config

https://github.com/pesser/stable-diffusion/blob/693e713c3e72e72b8e2b97236eb21526217e83ad/configs/stable-diffusion/upscaling/upscale-v1-with-f16.yaml#L96

https://github.com/CompVis/latent-diffusion/blob/a506df5756472e2ebaf9078affdde2c4f1502cd4/configs/retrieval-augmented-diffusion/768x768.yaml#L62

It seems some new VAE are going to have attention in encoder/decoder. This PR adds AttnDownEncoderBlock2D and AttnUpDecoderBlock2D to suppor this.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 8, 2022

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

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Very nice!

One nit: Maybe let's either remove the Cross... prefix from the other attention blocks or add it here - whatever you think is best!

@patil-suraj
Copy link
Contributor Author

I didn't put the Cross... prefix here as the model doesn't do cross-attention, there is no context/condition here. This is just self attention. So I would leave it as it is.

@patil-suraj patil-suraj requested a review from anton-l August 10, 2022 10:38
Copy link
Member

@anton-l anton-l left a comment

Choose a reason for hiding this comment

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

Great use of existing modules, very clean :)

@patil-suraj patil-suraj merged commit b344c95 into main Aug 10, 2022
@patil-suraj patil-suraj deleted the add-attn-vae-enc-dec branch August 10, 2022 11:08
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
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.

4 participants