Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/diffusers/models/transformers/transformer_ltx.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def __init__(
self.dropout = dropout
self.out_dim = query_dim
self.heads = heads
self.is_cross_attention: Optional[bool] = None
Copy link
Member

Choose a reason for hiding this comment

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

I think we can set it to True / False based on the value of cross_attention_dim 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.

self.cross_attention_dim is always 4096 for attn1 and attn2 though.

self.cross_attention_dim either gets set to cross_attention_dim or query_dim which are both 4096 in my runs

Copy link
Member

Choose a reason for hiding this comment

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

if cross_attention_dim is None: self.is_cross_attention = False -- what's up with this?


norm_eps = 1e-5
norm_elementwise_affine = True
Expand All @@ -166,6 +167,7 @@ def forward(
image_rotary_emb: Optional[torch.Tensor] = None,
**kwargs,
) -> torch.Tensor:
self.is_cross_attention = encoder_hidden_states is not None
attn_parameters = set(inspect.signature(self.processor.__call__).parameters.keys())
unused_kwargs = [k for k, _ in kwargs.items() if k not in attn_parameters]
if len(unused_kwargs) > 0:
Expand Down Expand Up @@ -324,6 +326,7 @@ def __init__(
out_bias=attention_out_bias,
qk_norm=qk_norm,
)
self.attn1.is_cross_attention = False

self.norm2 = RMSNorm(dim, eps=eps, elementwise_affine=elementwise_affine)
self.attn2 = LTXAttention(
Expand All @@ -336,6 +339,7 @@ def __init__(
out_bias=attention_out_bias,
qk_norm=qk_norm,
)
self.attn2.is_cross_attention = True

self.ff = FeedForward(dim, activation_fn=activation_fn)

Expand Down