Skip to content
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

[CodePartition] Optimize the placement of consumer releases #11

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Conversation

htyu
Copy link
Contributor

@htyu htyu commented Dec 17, 2024

Fix the inefficient placement of consumer releases when producer and consumer are not in the same scope. For example, given

Q = tl.load
for (..) 
   K = tl.load
   QK = dot(Q, K)
   ...
tl.store

Previously the consumer release corresponding to Q was placed after the store. With the current fix the release would go right after the for loop.

TORCH_CUDA_ARCH_LIST=9.0a python run.py --op flash_attention --only triton_tutorial_flash_v2_tma_ws,triton_tutorial_flash_v2_tma_ws_persistent,triton_tutorial_flash_v2 --num-inputs 1 --seq-len 10 --metrics tflops --batch 1024 --n-heads 4 --d-head 128 --cudagraph

Before:

(Batch, Heads, SeqLen, Dhead)    triton_tutorial_flash_v2_tma_ws-tflops    triton_tutorial_flash_v2_tma_ws_persistent-tflops    triton_tutorial_flash_v2-tflops
-------------------------------  ----------------------------------------  ---------------------------------------------------  ---------------------------------
         (1024, 4, 1024, 128)                                   393.141                                              400.046                            366.498


After:
  (Batch, Heads, SeqLen, Dhead)    triton_tutorial_flash_v2_tma_ws-tflops    triton_tutorial_flash_v2_tma_ws_persistent-tflops    triton_tutorial_flash_v2-tflops
-------------------------------  ----------------------------------------  ---------------------------------------------------  ---------------------------------
           (1024, 4, 1024, 128)                                    396.43                                              422.847                            363.753

…en producer and consumer are not in the same scope.
@htyu htyu requested review from bertmaher and manman-ren December 17, 2024 06:04
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 17, 2024
@htyu htyu changed the title [CodePartition] Fix the inefficient placement of consumer releases [CodePartition] Optimize the placement of consumer releases Dec 17, 2024
Copy link
Contributor

@manman-ren manman-ren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great perf win!

@htyu htyu merged commit 8706035 into ws Dec 17, 2024
2 of 6 checks passed
@htyu htyu deleted the hoy/synop branch December 17, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants