8000 [pytorch][triton] Enabling TMA for flex-attention for supported device types by mandroid6 · Pull Request #153662 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[pytorch][triton] Enabling TMA for flex-attention for supported device types #153662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mandroid6
Copy link
Contributor
@mandroid6 mandroid6 commented May 15, 2025

Summary:
Currently flex-attention defaults to USE_TMA=False.

We can enable TMA on devices which support it based on has_triton_tma_device.

Test Plan:

Tritonbench results

buck2 run mode/opt //pytorch/tritonbench:run -- --op flex_attention --use-tma --mod-type all
.
.
.
(B, Hq, M, Hkv, N, D)     |       Mask Type    compiled-latency    compiled-tflops
- USE_TMA =  False
(8, 16, 128, 16, 128, 128) |            noop   0.027936 (±5.61%)            38.5859
(8, 16, 128, 16, 128, 128) |          causal   0.017760 (±3.42%)            60.6946
(8, 16, 128, 16, 128, 128) |             rel   0.028384 (±5.07%)            37.9769
(8, 16, 128, 16, 128, 128) |       head_bias   0.027712 (±4.27%)            38.8978
(8, 16, 128, 16, 128, 128) |           alibi   0.017920 (±3.21%)            60.1527
- USE_TMA = True
(8, 16, 128, 16, 128, 128) |            noop   0.025632 (±5.74%)            42.0543
(8, 16, 128, 16, 128, 128) |          causal   0.015328 (±3.97%)            70.3246
(8, 16, 128, 16, 128, 128) |             rel   0.025824 (±4.96%)            41.7416
(8, 16, 128, 16, 128, 128) |       head_bias   0.025472 (±4.90%)            42.3185
(8, 16, 128, 16, 128, 128) |           alibi   0.015392 (±3.74%)            70.0322

Differential Revision: D74841543

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov

…e types

Summary:
Currently flex-attention defaults to `USE_TMA=False`.

We can enable TMA on devices which support it based on `has_triton_tma_device`.

Test Plan:
# Tritonbench results

```
buck2 run mode/opt //pytorch/tritonbench:run -- --op flex_attention --use-tma --mod-type all
.
.
.
(B, Hq, M, Hkv, N, D)     |       Mask Type    compiled-latency    compiled-tflops
- USE_TMA =  False
(8, 16, 128, 16, 128, 128) |            noop   0.027936 (±5.61%)            38.5859
(8, 16, 128, 16, 128, 128) |          causal   0.017760 (±3.42%)            60.6946
(8, 16, 128, 16, 128, 128) |             rel   0.028384 (±5.07%)            37.9769
(8, 16, 128, 16, 128, 128) |       head_bias   0.027712 (±4.27%)            38.8978
(8, 16, 128, 16, 128, 128) |           alibi   0.017920 (±3.21%)            60.1527
- USE_TMA = True
(8, 16, 128, 16, 128, 128) |            noop   0.025632 (±5.74%)            42.0543
(8, 16, 128, 16, 128, 128) |          causal   0.015328 (±3.97%)            70.3246
(8, 16, 128, 16, 128, 128) |             rel   0.025824 (±4.96%)            41.7416
(8, 16, 128, 16, 128, 128) |       head_bias   0.025472 (±4.90%)            42.3185
(8, 16, 128, 16, 128, 128) |           alibi   0.015392 (±3.74%)            70.0322
```

Differential Revision: D74841543
Copy link
pytorch-bot bot commented May 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/153662

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 83d37fd with merge base ea17cd0 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74841543

@drisspg
Copy link
Contributor
drisspg commented May 16, 2025

Can you also do a perf bench w/ larger sequen lengths, I am curious

Copying over comments:
Looks good, the only thing is that we dont have CI testing for this, I am going to run the tests on the devvm

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 16, 2025
@drisspg
Copy link
Contributor
drisspg commented May 16, 2025

https://www.internalfb.com/intern/paste/P1813676625/

Some failing tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0