Edited attention.py for older xformers #1270
Merged
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.
Older versions of xformers require query, key, value to be contiguous, this calls .contiguous() on q/k/v before passing to xformers.
Tested with 0.14 version of xformers built by metrolobo, specifically, this release, on T4 GPU and torch==1.12.0+cu113. It seemed this problem isn't encountered on other versions.
Testing with the 'official' release on pip isn't possible, as the 0.13 version currently on pip cannot be installed, regardless of gpu/version.
Edit: I did not run test with the other versions of prebuilt wheels, or other GPU but T4. Let me know if it fails on other versions.