-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 the bug that joint_attention_kwargs
is not passed to the FLUX's transformer attention processors
#9517
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR! I left a question
@@ -161,6 +162,7 @@ def forward( | |||
encoder_hidden_states: torch.FloatTensor, | |||
temb: torch.FloatTensor, | |||
image_rotary_emb=None, | |||
joint_attention_kwargs={}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what additional argument you need to pass down to flux attention processor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your recognition!
In our work, I am trying to integrate box and mask into the FLUX model and implement layout control (similar to what has been done in many works on SD1.4). This requires modifying the attention processor. I believe that the architecture of FLUX and other transformers can also be used to develop better layout control algorithms, so I believe these modifications will contribute to future training-free experiments on FLUX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! let's support this :)
@@ -161,6 +162,7 @@ def forward( | |||
encoder_hidden_states: torch.FloatTensor, | |||
temb: torch.FloatTensor, | |||
image_rotary_emb=None, | |||
joint_attention_kwargs={}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
joint_attention_kwargs={}, | |
joint_attention_kwargs=None, |
): | ||
residual = hidden_states | ||
norm_hidden_states, gate = self.norm(hidden_states, emb=temb) | ||
mlp_hidden_states = self.act_mlp(self.proj_mlp(norm_hidden_states)) | ||
|
||
joint_attention_kwargs = joint_attention_kwargs if joint_attention_kwargs is not None else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we pass this to attn
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I think it will be useful for other trial!
fix a little bug
I fixed a bug and now it is okay XD. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, looks good! could you run make style
to fix the failing quality tests.
i have a question though: in this comment, you mention that your work uses this feature to modify something in, or pass additional arguments to, the attention processor. it is understandable why this would be useful, but we generally do not add features that are not testable or usable without a public implementation. is your work/method utilizing this change available for testing this? if it will be available in the near future, i think it might be best to postpone merging this PR after that
oh, i just saw yiyi's comment about being okay with supporting this. in that case, please disregard my question above. let's fix the quality tests and we should be okay to merge |
@a-r-r-o-w |
Yes, that's it! QWQ |
@a-r-r-o-w |
Hi @HorizonWind2004, looks good to me! Could you run |
Yes! Now it is okay. |
@a-r-r-o-w @yiyixuxu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
… transformer attention processors (huggingface#9517) * Update transformer_flux.py
… transformer attention processors (#9517) * Update transformer_flux.py
Issue link is below:
#9516