-
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
Fix the bug that joint_attention_kwargs
is not passed to the FLUX's transformer attention processors
#9517
Changes from 4 commits
8a1d136
b12ee92
9509764
a89fd51
5104098
8b0be8d
9ed5284
c9d624b
b6128a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -83,11 +83,12 @@ def forward( | |||||
hidden_states: torch.FloatTensor, | ||||||
temb: torch.FloatTensor, | ||||||
image_rotary_emb=None, | ||||||
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 {} | ||||||
attn_output = self.attn( | ||||||
hidden_states=norm_hidden_states, | ||||||
image_rotary_emb=image_rotary_emb, | ||||||
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
): | ||||||
norm_hidden_states, gate_msa, shift_mlp, scale_mlp, gate_mlp = self.norm1(hidden_states, emb=temb) | ||||||
|
||||||
|
@@ -173,6 +175,8 @@ def forward( | |||||
hidden_states=norm_hidden_states, | ||||||
encoder_hidden_states=norm_encoder_hidden_states, | ||||||
image_rotary_emb=image_rotary_emb, | ||||||
**joint_attention_kwargs, | ||||||
|
||||||
) | ||||||
|
||||||
# Process attention outputs for the `hidden_states`. | ||||||
|
@@ -497,6 +501,7 @@ def custom_forward(*inputs): | |||||
encoder_hidden_states=encoder_hidden_states, | ||||||
temb=temb, | ||||||
image_rotary_emb=image_rotary_emb, | ||||||
joint_attention_kwargs=joint_attention_kwargs, | ||||||
) | ||||||
|
||||||
# controlnet residual | ||||||
|
@@ -533,6 +538,7 @@ def custom_forward(*inputs): | |||||
hidden_states=hidden_states, | ||||||
temb=temb, | ||||||
image_rotary_emb=image_rotary_emb, | ||||||
joint_attention_kwargs=joint_attention_kwargs, | ||||||
) | ||||||
|
||||||
# controlnet residual | ||||||
|
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!