[Qwen] avoid creating attention masks when there is no padding#12987
[Qwen] avoid creating attention masks when there is no padding#12987yiyixuxu merged 11 commits intohuggingface:mainfrom
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
will do! |
src/diffusers/pipelines/qwenimage/pipeline_qwenimage_img2img.py
Outdated
Show resolved
Hide resolved
| with torch.no_grad(): | ||
| output_no_mask = compiled_model(**inputs_no_mask) |
There was a problem hiding this comment.
Does it lead to graph breaks? If not, then we should add additional contexts:
diffusers/tests/models/test_modeling_common.py
Line 2145 in 3996788
|
does this PR lack a merge, or is the amount of code changes intentional and really part of this PR only? (+318 - 170) avoiding masks if they're not necessary has been one line before |
|
@dxqb i intially mis-calculated and was adding support for the pipeline to be compiled, i will revert and simplify |
thanks!
Therefore, I'd suggest to
|
Here is a benchmark of the impact of using a mask unnecessarily (second graph): #12870 (comment) |
|
thanks @dxqb please check now |
|
I tested this #12987 on L20, and there was an 11% performance improvement in my test. |
|
And do you find that to resolve your concerns? |
|
I think this has solved my problem. Based on this PR, the performance in my test cases has been working as expected. |
I don't have a simple test case, but code looks simple and good now |
|
thanks again @kashif !! |

What does this PR do?
This pull request sets all ones masks to None.
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.