Skip to content

Fix FA3 being selected on ROCm devices - #4778

Merged
tianyu-l merged 1 commit into
pytorch:mainfrom
Johnsonms:johnson/rocm-no-fa3
Sep 18, 2026
Merged

tianyu-l merged 1 commit into
pytorch:mainfrom
Johnsonms:johnson/rocm-no-fa3

Conversation

@Johnsonms

Copy link
Copy Markdown
Contributor

get_cuda_flash_attention_impl() gates on has_cuda_capability(), which is torch.cuda.get_device_capability() >= (major, minor) with no vendor check. AMD devices report a capability through that same API, and gfx950 (MI350X) reports (9, 5) -- so the (9, 0) test passes and FA3 is selected on hardware that has no FA3 to select. torch's flash_attn_interface is CUDA-only, so activate_flash_attention_impl("FA3") then fails.

Return None on a ROCm build, which is what the rest of the function already does for architectures with no supported implementation, leaving torch's default attention path in place.

Reproduced on 8x MI350X (gfx950) with the llama3 varlen attention backend.

get_cuda_flash_attention_impl() gates on has_cuda_capability(), which is
torch.cuda.get_device_capability() >= (major, minor) with no vendor check.
AMD devices report a capability through that same API, and gfx950 (MI350X)
reports (9, 5) -- so the (9, 0) test passes and FA3 is selected on hardware
that has no FA3 to select. torch's flash_attn_interface is CUDA-only, so
activate_flash_attention_impl("FA3") then fails.

Return None on a ROCm build, which is what the rest of the function already
does for architectures with no supported implementation, leaving torch's
default attention path in place.

Reproduced on 8x MI350X (gfx950) with the llama3 varlen attention backend.
@pytorch-bot pytorch-bot Bot added ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rocm module: rocm labels Sep 18, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 18, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pytorch-bot

pytorch-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/rocm
  • ciflow/fake-pg

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@tianyu-l
tianyu-l merged commit ca2e25a into pytorch:main Sep 18, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rocm CLA Signed This label is managed by the Meta Open Source bot. module: rocm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants