Clarification on mutually exclusive use of self-attention and cross-attention in DiffusionModelUNetMaisi · Issue #1993 · Project-MONAI/tutorials · GitHub
Skip to content

Clarification on mutually exclusive use of self-attention and cross-attention in DiffusionModelUNetMaisi #1993

Open

Description

@danielemolino

Hi MONAI team,

while reading through the implementation of DiffusionModelUNetMaisi, I noticed the following logic for enabling attention at each level:

with_attn = attention_levels[i] and not with_conditioning
with_cross_attn = attention_levels[i] and with_conditioning

This effectively means that self-attention is never used when the model is in conditioning mode (with_conditioning=True), even if attention_levels[i] is True.

Is this behavior intentional?

In other diffusion-based architectures such as Stable Diffusion, it is common practice to enable both self-attention and cross-attention simultaneously within the same layers.

Would it be acceptable, or even recommended, to modify the logic as follows to allow both mechanisms in parallel?
Or is there a specific reason this mutual exclusivity was enforced?

Looking forward to your insights, and thank you for the great work on this model!

Best regards,
Daniele Molino

Activity

  1. danielemolino commented on Jun 26, 2025

    @danielemolino
    Author

    Any News?

  2. ericspod commented on Jul 10, 2025

    @ericspod
    Member

    Hi @dongyang0122 @guopengf I think this is code you've worked on recently, would you have any insights here? Thanks!

  3. dongyang0122 commented on Jul 22, 2025

    @dongyang0122
    Collaborator

    The DiffusionModelUNetMaisi implementation of MONAI is largely inspired by the following references. We did not explore this aspect in depth during development. We would appreciate it if you could let us know whether enabling both settings improves performance for your use case. Thank you.

    https://github.com/Project-MONAI/GenerativeModels/blob/main/generative/networks/nets/diffusion_model_unet.py#L1787-L1788
    https://github.com/Project-MONAI/MONAI/blob/dev/monai/networks/nets/diffusion_model_unet.py#L1643-L1644

  4. danielemolino commented on Oct 14, 2025

    @danielemolino
    Author

    Thank you for your clarification and for sharing the references.
    I manually implemented the option to enable both self- and cross-attention within the DiffusionModelUNetMaisi architecture and ran several experiments.
    In my case, I did not observe any clear performance improvement, especially considering the noticeable increase in computational cost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions