[fix] Fix flash_attn_3 import order conflict#1375
Open
georgkaleido wants to merge 1 commit intofacebookresearch:mainfrom
Open
[fix] Fix flash_attn_3 import order conflict#1375georgkaleido wants to merge 1 commit intofacebookresearch:mainfrom
georgkaleido wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
Fixes facebookresearch#1348 Swap import order to prioritize global flash_attn_3 package over vendored version. This prevents torch extension namespace conflicts when flash_attn_3 is already imported by other libraries (e.g., diffusers). The fix simply swaps the two import blocks so that: - Global flash_attn_3 is checked first (if) - Vendored version is only used if global is not available (elif) - Maintains the original behavior and error handling This allows xFormers to work alongside libraries that import flash_attn_3, such as diffusers.models.autoencoders, without RuntimeError about duplicate torch.ops registration. Amp-Thread-ID: https://ampcode.com/threads/T-353ac1bf-891c-41c9-96d3-0b1b4c2b5bbe Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #1348
Swap import order to prioritize global flash_attn_3 package over vendored version. This prevents torch extension namespace conflicts when flash_attn_3 is already imported by other libraries (e.g., diffusers).
The fix simply swaps the two import blocks so that:
This allows xFormers to work alongside libraries that import flash_attn_3, such as diffusers.models.autoencoders, without RuntimeError about duplicate torch.ops registration.
Before submitting