huggingface / huggingface/diffusers

Incompatibility between FlashAttention and ERNIE-Image

Open
#13,801 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug pipelines
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

Hello,

When I enable FlashAttention backend on an ErnieImagePipeline, it crashes with following error:

ValueError: attn_mask is not supported for flash-attn 2.

But same Python code (see below) doesn't crash with ZImagePipeline and Flux2KleinPipeline.

Reproduction
pipeline.transformer.set_attention_backend("flash")
System Info
  • OS: Windows
  • Python: 3.13.11
  • Diffusers: 9c4e201dd1cf7d16449c3f4e9affc556d7bc3404
  • FlashAttention: 2.8.3+cu130torch2.10
  • SDNQ: 0.1.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ErnieImagePipeline and its transformer attention setup, then compare attention-mask handling with ZImagePipeline and Flux2KleinPipeline. Reproduce the shown set_attention_backend("flash") failure in the stated environment; done means ERNIE-Image can use the flash backend without the attn_mask error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.