Enable FA4 Flex attention backend#834
Conversation
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesFA4 flex-attention backend support
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
|
|
||
|
|
||
| @lru_cache(maxsize=1) | ||
| def fa4_is_available() -> bool: |
There was a problem hiding this comment.
crashed on GB10 Blackwell (maybe it's an upstream bug)
fa4_is_available() returns True on GB10 (sm 12.1 ≥ 9.0 + package present), so --fa4 auto would enable FA4 and then crash at the first masked flex_attention, i.e., it breaks DFlash/Eagle-3 training on GB10 out of the box.
because:
| case | result on GB10 |
|---|---|
| FA4, dense (no mask) | runs fwd+bwd |
| FA4, causal mask | AssertionError: Block sparsity not supported on SM 12.0 |
| FA4, DFlash anchor mask | AssertionError: Block sparsity not supported on SM 12.0 |
WindChimeRan
left a comment
There was a problem hiding this comment.
Could you please run some quick e2e benchmark on, e.g., 100 step speedup on a/b?
speculatorsbot
left a comment
There was a problem hiding this comment.
Clean, well-scoped addition. The implementation is minimal — extends the existing flex_attention_forward with an optional kernel_options parameter, adds the CLI plumbing, CI setup, and hardware-gated tests. No design concerns.
Agree with @WindChimeRan's finding that fa4_is_available() would return True on Blackwell GPUs (e.g. GB10, SM 12.x >= 9.0) where FA4's block-sparsity support is incomplete, causing masked flex_attention (causal, anchor) to crash under --fa4 auto. Recommend resolving that before merge.
🤖 Generated with Claude Code using the /pr-review skill
Merge Protections🔴 1 of 1 protections blocking · waiting on 👀 reviews
🔴 Require approval from approved reviewers listWaiting for any of
This rule is failing.All pull requests must have at least one approving review from a member of the approved reviewers list before merging.
|
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
Pytorch added support for an Flash Attention 4 backend to Flex Attention which has much better performance on Hopper and Blackwell gpus: https://pytorch.org/blog/flexattention-flashattention-4-fast-and-flexible/
Requires manually installing fa4 first:
or
Note: this is experimental.
By default, if the flash attention package is available and we're using a Hopper or newer gpu, this backend will get used. You can also explicitly enable/disable it with
--fa4 onor--fa4 offTests
I've added some explicit tests for FA4 on the Hopper runners. I've also updated the buildkite pipeline to install FA4 so that the tests will run.
Checklist
I have filled in: