[PyTorch] Fix FA4 selection when FA3 is unavailable.#2909
[PyTorch] Fix FA4 selection when FA3 is unavailable.#2909ptrendx merged 1 commit intoNVIDIA:mainfrom
Conversation
Signed-off-by: Björn Buschkämper <bjoern.buschkaemper@gmail.com>
Greptile SummaryThis PR fixes a bug where FA4 was incorrectly disabled on SM90 (Hopper) devices even when FA3 was not actually installed. The original condition only checked Confidence Score: 5/5Safe to merge — targeted one-line logic fix with no side effects on other code paths. The change is minimal, correct, and directly addresses the described bug. The new condition properly requires both FA3 to be requested and actually installed before suppressing FA4. No new edge cases are introduced and all other filter paths are unaffected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SM90 device detected] --> B{use_flash_attention_3?}
B -- No --> E[FA4 remains enabled]
B -- Yes --> C{v3_is_installed?}
C -- No --> E
C -- Yes --> D{use_flash_attention_4?}
D -- No --> F[FA4 already disabled]
D -- Yes --> G{v4_is_installed?}
G -- No --> F
G -- Yes --> H[Disable FA4, prefer FA3 on SM90]
style H fill:#f96,color:#000
style E fill:#6f6,color:#000
Reviews (1): Last reviewed commit: "Fix FA4 selection when FA3 is unavailabl..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR fixes backend selection on SM90 (Hopper) so FlashAttention 4 (FA4) is not disabled in favor of FlashAttention 3 (FA3) unless FA3 is actually installed, preventing FA4 from being inadvertently made unusable when FA3 isn’t present.
Changes:
- Gate the SM90 “prefer FA3 over FA4” rule on
FlashAttentionUtils.v3_is_installed(andv4_is_installed) so FA4 is only disabled when both backends are truly available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@vcherepanov-nv Could you review and add a |
|
/te-ci pytorch |
|
@ptrendx Is the failed build check sth I can fix or a runner-issue? Seems to me that the build was cancelled. |
|
@bbuschkaemper it was a runner issue. I reran the CI internally and it passed. Merging, thanks :-)! |
Description
Fixes FA3 being preferred over FA4 on SM90 before confirming that FA3 is actually installed, causing FA4 to be unusable on Hopper devices.
Type of change
Changes
utils.pyconfirms that FA3 is actually installed and available before discarding FA4 in favor of FA3Checklist: