-
Notifications
You must be signed in to change notification settings - Fork 320
perf: Use 2WG pipeline design for MLA implementation on Hopper #952
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 tasks
This was referenced Mar 29, 2025
Closed
yzh119
added a commit
that referenced
this pull request
Mar 31, 2025
Followup of #952 cc @abcdabcd987 ## Before this PR ``` Config: batch_size=64, seq_len=1024, num_heads=64 Memory bandwidth: 1509.87 GB/s FLOPs: 163.25 TFLOPs Config: batch_size=64, seq_len=1024, num_heads=128 Memory bandwidth: 1766.19 GB/s FLOPs: 345.46 TFLOPs Config: batch_size=128, seq_len=1024, num_heads=64 Memory bandwidth: 2307.97 GB/s FLOPs: 249.55 TFLOPs Config: batch_size=128, seq_len=1024, num_heads=128 Memory bandwidth: 1975.24 GB/s FLOPs: 386.35 TFLOPs Config: batch_size=768, seq_len=1024, num_heads=64 Memory bandwidth: 2871.63 GB/s FLOPs: 310.49 TFLOPs Config: batch_size=768, seq_len=1024, num_heads=128 Memory bandwidth: 2225.07 GB/s FLOPs: 435.21 TFLOPs Config: batch_size=64, seq_len=2048, num_heads=64 Memory bandwidth: 1948.15 GB/s FLOPs: 222.38 TFLOPs Config: batch_size=64, seq_len=2048, num_heads=128 Memory bandwidth: 1973.36 GB/s FLOPs: 426.74 TFLOPs Config: batch_size=128, seq_len=2048, num_heads=64 Memory bandwidth: 2625.63 GB/s FLOPs: 299.72 TFLOPs Config: batch_size=128, seq_len=2048, num_heads=128 Memory bandwidth: 2121.92 GB/s FLOPs: 458.86 TFLOPs Config: batch_size=768, seq_len=2048, num_heads=64 Memory bandwidth: 2996.11 GB/s FLOPs: 342.01 TFLOPs Config: batch_size=768, seq_len=2048, num_heads=128 Memory bandwidth: 2146.40 GB/s FLOPs: 464.16 TFLOPs Config: batch_size=64, seq_len=8192, num_heads=64 Memory bandwidth: 2717.28 GB/s FLOPs: 323.71 TFLOPs Config: batch_size=64, seq_len=8192, num_heads=128 Memory bandwidth: 2129.24 GB/s FLOPs: 500.04 TFLOPs Config: batch_size=128, seq_len=8192, num_heads=64 Memory bandwidth: 3002.75 GB/s FLOPs: 357.72 TFLOPs Config: batch_size=128, seq_len=8192, num_heads=128 Memory bandwidth: 2101.93 GB/s FLOPs: 493.63 TFLOPs Config: batch_size=768, seq_len=8192, num_heads=64 Memory bandwidth: 3083.42 GB/s FLOPs: 367.33 TFLOPs Config: batch_size=768, seq_len=8192, num_heads=128 Memory bandwidth: 2064.96 GB/s FLOPs: 484.95 TFLOPs ``` ## After this PR ``` Config: batch_size=64, seq_len=1024, num_heads=64 Memory bandwidth: 1596.98 GB/s FLOPs: 172.67 TFLOPs Config: batch_size=64, seq_len=1024, num_heads=128 Memory bandwidth: 1685.22 GB/s FLOPs: 329.62 TFLOPs Config: batch_size=128, seq_len=1024, num_heads=64 Memory bandwidth: 2280.49 GB/s FLOPs: 246.58 TFLOPs Config: batch_size=128, seq_len=1024, num_heads=128 Memory bandwidth: 1917.53 GB/s FLOPs: 375.06 TFLOPs Config: batch_size=768, seq_len=1024, num_heads=64 Memory bandwidth: 2869.03 GB/s FLOPs: 310.21 TFLOPs Config: batch_size=768, seq_len=1024, num_heads=128 Memory bandwidth: 2208.35 GB/s FLOPs: 431.94 TFLOPs Config: batch_size=64, seq_len=2048, num_heads=64 Memory bandwidth: 2047.44 GB/s FLOPs: 233.72 TFLOPs Config: batch_size=64, seq_len=2048, num_heads=128 Memory bandwidth: 1936.08 GB/s FLOPs: 418.67 TFLOPs Config: batch_size=128, seq_len=2048, num_heads=64 Memory bandwidth: 2617.48 GB/s FLOPs: 298.79 TFLOPs Config: batch_size=128, seq_len=2048, num_heads=128 Memory bandwidth: 2105.97 GB/s FLOPs: 455.41 TFLOPs Config: batch_size=768, seq_len=2048, num_heads=64 Memory bandwidth: 2999.55 GB/s FLOPs: 342.40 TFLOPs Config: batch_size=768, seq_len=2048, num_heads=128 Memory bandwidth: 2181.54 GB/s FLOPs: 471.75 TFLOPs Config: batch_size=64, seq_len=8192, num_heads=64 Memory bandwidth: 2780.86 GB/s FLOPs: 331.29 TFLOPs Config: batch_size=64, seq_len=8192, num_heads=128 Memory bandwidth: 2176.12 GB/s FLOPs: 511.05 TFLOPs Config: batch_size=128, seq_len=8192, num_heads=64 Memory bandwidth: 3031.58 GB/s FLOPs: 361.15 TFLOPs Config: batch_size=128, seq_len=8192, num_heads=128 Memory bandwidth: 2165.73 GB/s FLOPs: 508.61 TFLOPs Config: batch_size=768, seq_len=8192, num_heads=64 Memory bandwidth: 3126.37 GB/s FLOPs: 372.45 TFLOPs Config: batch_size=768, seq_len=8192, num_heads=128 Memory bandwidth: 2142.42 GB/s FLOPs: 503.14 TFLOPs ```
This was referenced Apr 8, 2025
MasterJH5574
pushed a commit
that referenced
this pull request
Apr 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements #892 .
Per benchmark, 2WG pipeline (FlashMLA's implementation) is faster than our current 3WG pipeline design on Hopper. While it remains investigation where the gap comes from, we should implements the 2WG (and 4WG in the future) pipeline in FlashInfer to make sure our implementation not getting worse performance than flashmla.
Performance
Before this PR:
After this PR:
Note