Skip to content

external_query argument mismatch between flux_kontext.py and MochiAttnProcessor2_0 in diffusers #2

@dyk-npu

Description

@dyk-npu

FluxAttnProcessor.call() got an unexpected keyword argument external_query

Hi, thanks for the great work!

I encountered an error when running the project. It seems that the FluxAttnProcessor in my installed version of diffusers does not support the external_query argument.


Error

The error occurs at the following call:

return self.processor(
    self,
    hidden_states,
    external_query=external_query,
    encoder_hidden_states=encoder_hidden_states,
    attention_mask=attention_mask,
    wtext=wtext,
    **cross_attention_kwargs,
)

Runtime error:

FluxAttnProcessor.__call__() got an unexpected keyword argument 'external_query'

My Investigation

I checked the implementation of FluxAttnProcessor in:

diffusers/models/transformers/transformer_flux.py

The definition in my environment is:

class FluxAttnProcessor:
    _attention_backend = None

    def __init__(self):
        if not hasattr(F, "scaled_dot_product_attention"):
            raise ImportError(
                f"{self.__class__.__name__} requires PyTorch 2.0. Please upgrade your pytorch version."
            )

    def __call__(
        self,
        attn: "FluxAttention",
        hidden_states: torch.Tensor,
        encoder_hidden_states: torch.Tensor = None,
        attention_mask: Optional[torch.Tensor] = None,
        image_rotary_emb: Optional[torch.Tensor] = None,
    ) -> torch.Tensor:

As shown above, external_query is not included in the function arguments, which leads to the error.


Environment

  • diffusers: 0.35.0
  • k-diffusion: 0.1.1.post1

Question

Has this issue been encountered before?

Is the project expecting a custom or modified version of diffusers, or a specific diffusers version/commit where FluxAttnProcessor supports external_query?

Any guidance would be appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions