Skip to content

Conversation

@leisuzz
Copy link
Contributor

@leisuzz leisuzz commented Jan 6, 2025

What does this PR do?

Added Flash Attention for FLUX
Fixed issue in Flux Controlnet when using enable flash attention

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@leisuzz
Copy link
Contributor Author

leisuzz commented Jan 6, 2025

@sayakpaul Please take a look at this Flux adaption. Thank you!

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Changes to the training script look good to me. Off to @yiyixuxu for the other changes.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

self.norm1_context = AdaLayerNormZero(dim)

if hasattr(F, "scaled_dot_product_attention"):
processor = FluxAttnProcessor2_0()
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's keep the default logic simple i.e. remove the changes from this file
you can use NPU with set_attn_processor, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yiyixuxu In the attention processor, it has NPU FA, but only with AttnProcessorNPU. Or do you want me to add a function in attention_processor.py to change the processor there? I think right now the selection is only in the init, so it shouldn't be any logic changes. Please let me know what you think so that I can modify based on that. Thanks

In the attention processor, it has NPU FA, but only with AttnProcessorNPU. Or do you want me to add a function in attention_processor.py to change the processor there? I think right now the selection is only in the init, so it shouldn't be any logic changes. Please let me know what you think so that I can modify based on that. Thanks

@leisuzz
Copy link
Contributor Author

leisuzz commented Feb 19, 2025

@yiyixuxu Please take a look at this, thanks

@yiyixuxu
Copy link
Collaborator

hi @leisuzz

I think we are not going to change default attention processor for now, so we won't be able to accept this change at the moment. Sorry about the back and forth!

@yiyixuxu
Copy link
Collaborator

this means user just has to manually run this to use NPU for now

pipe.set_attn_processor(FusedFluxAttnProcessor2_0_NPU())

@leisuzz leisuzz closed this Feb 23, 2025
@leisuzz leisuzz deleted the flux branch June 3, 2025 11:13
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