Skip to content

fix: handle undefined ip_hidden_states in self-attention path#299

Open
Mr-Neutr0n wants to merge 1 commit intoinstantX-research:mainfrom
Mr-Neutr0n:fix/ip-hidden-states-undefined
Open

fix: handle undefined ip_hidden_states in self-attention path#299
Mr-Neutr0n wants to merge 1 commit intoinstantX-research:mainfrom
Mr-Neutr0n:fix/ip-hidden-states-undefined

Conversation

@Mr-Neutr0n
Copy link

Summary

  • In IPAttnProcessor.forward() and IPAttnProcessor2_0.forward(), the variable ip_hidden_states is only assigned in the else branch (cross-attention path), but is referenced unconditionally in the ip-adapter computation block that follows. When encoder_hidden_states is None (self-attention), this causes a NameError.
  • This fix initializes ip_hidden_states = None in the self-attention branch and guards the ip-adapter computation with if ip_hidden_states is not None:, so the processor gracefully skips ip-adapter blending during self-attention.

Test plan

  • Verify that the processor no longer raises NameError when encoder_hidden_states is None
  • Verify that cross-attention with ip-adapter embeddings still works as before
  • Verify region control behavior is unchanged when ip_hidden_states is present

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.

1 participant