Repository navigation
Add check to disable xformers on newer GPUs - #4342
Conversation
Disable xformers for GPUs with compute capability >= 12 to ensure compatibility with newer hardware.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the stability and compatibility of the attention dispatch mechanism by introducing a safeguard for newer GPU architectures. It prevents potential issues with xformers on devices with compute capability 12 or greater, ensuring that the system gracefully defaults to SDPA for optimal performance and reliability on cutting-edge hardware. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a check to disable xformers on GPUs with a compute capability of 12.0 or higher, falling back to SDPA. This is a good forward-looking change to ensure compatibility with future hardware. My only feedback is to update the accompanying comment to more accurately reflect the code's logic and avoid confusion about supported hardware versions, as the current comment is inconsistent with the implementation.
| # xformers kernels (FA3, FA2, cutlass) only support compute capability <= 9.0. | ||
| # Disable xformers on newer GPUs (e.g. RTX 5070 Ti / sm_120) and fall back to SDPA. |
There was a problem hiding this comment.
The comment here is a bit confusing and seems to contradict the code. The first line states that xformers only supports compute capability <= 9.0, but the code only disables it for >= 12.0, leaving a gap for versions 10.x and 11.x where it would remain enabled. Additionally, the example RTX 5070 Ti refers to the Blackwell architecture, which has a compute capability of 10.0, so the check _cc[0] >= 12 would not trigger for it.
To avoid confusion, I suggest updating the comment to align with the code's logic and the PR's description, which is to disable xformers for compute capability >= 12.0.
| # xformers kernels (FA3, FA2, cutlass) only support compute capability <= 9.0. | |
| # Disable xformers on newer GPUs (e.g. RTX 5070 Ti / sm_120) and fall back to SDPA. | |
| # Xformers is not yet supported on compute capability >= 12.0. | |
| # Disable xformers on such GPUs and fall back to SDPA. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbf82583a7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # Disable xformers on newer GPUs (e.g. RTX 5070 Ti / sm_120) and fall back to SDPA. | ||
| if HAS_XFORMERS and torch.cuda.is_available(): | ||
| _cc = torch.cuda.get_device_capability() | ||
| if _cc[0] >= 12: |
There was a problem hiding this comment.
Disable xformers on all unsupported SM versions
The new guard only disables xformers when major >= 12, but the comment directly above says xformers kernels are only supported through compute capability 9.0; this leaves SM 10.x/11.x GPUs on the xformers path instead of the intended SDPA fallback. On those newer non-9.x devices, backend selection can still choose xformers and trigger runtime kernel-dispatch failures rather than the compatibility fallback this commit is trying to enforce.
Useful? React with 👍 / 👎.
|
This PR addresses a real problem -- RTX 50-series users (SM 12.0) hitting xformers crashes like 1. Already handled in
if (f"{major_version}.{minor_version}" in ("10.0", "11.0", "12.0")) and (
Version(xformers_version) <= Version("0.0.32.post2")
):
raise NotImplementedError(...)This runs at import time before 2. Blanket disable breaks working xformers >= 0.0.33 xformers 3. Comment/code mismatch The comment says 4. Minor issues
Suggestion Since |
Disable xformers for GPUs with compute capability >= 12 to ensure compatibility with newer hardware.
Disable xformers for GPUs with compute capability >= 12 to ensure compatibility with newer hardware.