Skip to content

fix: make qkv compatible with torch.compile in next diffusers release#302

Merged
llcnt merged 2 commits intomainfrom
fix/qkv_not_compilable_new_diffusers
Aug 20, 2025
Merged

fix: make qkv compatible with torch.compile in next diffusers release#302
llcnt merged 2 commits intomainfrom
fix/qkv_not_compilable_new_diffusers

Conversation

@llcnt
Copy link
Copy Markdown
Collaborator

@llcnt llcnt commented Aug 13, 2025

Description

The current main branch in diffusers is undergoing a large refactorization for attention computation.
The attention processors still exist but Flux and Wan have now a local version of their own processor. Also qkv fusing was changed: it is now taking place in the AttentionMixin class (not anymore in the transformer class itself).
Sister PR in pruna_pro is here.

Related Issue

The combination qkv_diffusers+torch_compile is taking forever to compute on the latest diffusers codebase

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tested on Flux-dev with diffusers==0.34.0 and diffusers==0.35.0dev0
On Flux-dev, the generation time goes from 10.44s (original) to 5.12s (with qkv_diffusers+fp8+torch_compile).
The warm-up time (first inference) takes 56.16s.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

@llcnt llcnt marked this pull request as ready for review August 14, 2025 08:03
Copy link
Copy Markdown
Member

@johnrachwan123 johnrachwan123 left a comment

Choose a reason for hiding this comment

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

LGTM thanks a lot!

Copy link
Copy Markdown
Collaborator

@nifleisch nifleisch left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@llcnt llcnt merged commit 4ca2f1c into main Aug 20, 2025
6 of 7 checks passed
@llcnt llcnt mentioned this pull request Dec 5, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants