Repository navigation
[ROCm][Perf][MiniMax-M3.1] Tune MXFP8 linear tiles for 16 < M <= 256 #62509
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
jiacao-amd
wants to merge
3
commits into
vllm-project:main
Choose a base branch
from
jiacao-amd:minimax-m3-rocm-fp8-attn-proj
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−15
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,6 +266,98 @@ def _mxfp8_dot_scaled_gemm( | |
| _BK256_STAGES = 2 | ||
|
|
||
|
|
||
| # gfx950 tiles for 16 < M <= 256 (decode batches carrying draft tokens, small | ||
| # prefill chunks) with local N > 1280: (BLOCK_M, BLOCK_N, preferred BLOCK_K, | ||
| # num_warps, num_stages) per M bucket and local-N bucket (<= 1536, <= 2560, | ||
| # <= 3072, <= 6144, wider), for K >= 1024. Tuned for MiniMax-M3.1-Flash | ||
| # TP2/TP4 linears on MI355X. | ||
| _GFX950_MID_M_BUCKETS = (32, 48, 64, 96, 128, 192, 256) | ||
| _GFX950_MID_N_BUCKETS = (1536, 2560, 3072, 6144) | ||
| _GFX950_MID_M_TILES = { | ||
| 32: ( | ||
| (16, 16, 1024, 2, 3), | ||
| (32, 16, 1024, 2, 3), | ||
| (32, 16, 1024, 2, 3), | ||
| (32, 32, 512, 2, 3), | ||
| (32, 16, 512, 2, 2), | ||
| ), | ||
| 48: ( | ||
| (32, 16, 1024, 2, 3), | ||
| # M3.1 TP4 qkv (N=2560, K=6144) retains the narrow tile at M=48. | ||
| (16, 16, 1024, 2, 2), | ||
| (32, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| ), | ||
| 64: ( | ||
| (32, 16, 1024, 2, 3), | ||
| (32, 32, 512, 2, 3), | ||
| (32, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| ), | ||
| 96: ( | ||
| (32, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 256, 4, 2), | ||
| ), | ||
| 128: ( | ||
| (32, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 256, 4, 2), | ||
| ), | ||
| 192: ( | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 256, 4, 2), | ||
| (64, 64, 256, 4, 2), | ||
| ), | ||
| 256: ( | ||
| (64, 32, 512, 2, 3), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 512, 4, 2), | ||
| (64, 64, 256, 4, 2), | ||
| (64, 64, 512, 4, 2), | ||
| ), | ||
| } | ||
| # The same for short K (< 1024, e.g. a shared-expert down projection). | ||
| _GFX950_MID_M_SHORT_K_TILES = { | ||
| 32: (32, 16, 256, 2, 3), | ||
| 48: (64, 32, 256, 4, 3), | ||
| 64: (64, 32, 256, 4, 3), | ||
| 96: (64, 64, 256, 4, 3), | ||
| 128: (64, 64, 256, 4, 3), | ||
| 192: (64, 32, 256, 2, 2), | ||
| 256: (64, 32, 256, 2, 2), | ||
| } | ||
|
|
||
|
|
||
| def _gfx950_mid_m_cfg(M, N, K): | ||
| m_bucket = next(b for b in _GFX950_MID_M_BUCKETS if b >= M) | ||
| if K < 1024: | ||
| block_m, block_n, block_k, num_warps, num_stages = _GFX950_MID_M_SHORT_K_TILES[ | ||
| m_bucket | ||
| ] | ||
| else: | ||
| n_idx = next( | ||
| (i for i, b in enumerate(_GFX950_MID_N_BUCKETS) if b >= N), | ||
| len(_GFX950_MID_N_BUCKETS), | ||
| ) | ||
| block_m, block_n, block_k, num_warps, num_stages = _GFX950_MID_M_TILES[ | ||
| m_bucket | ||
| ][n_idx] | ||
| # The K-loop is unmasked: shrink BLOCK_K until it divides K (the entry | ||
| # requires K % 128 == 0). | ||
| while block_k > 128 and K % block_k: | ||
| block_k //= 2 | ||
| return block_m, block_n, block_k, num_warps, num_stages | ||
|
|
||
|
|
||
| def _select_cfg(M, N, K): | ||
| """(BLOCK_M, BLOCK_N, BLOCK_K, num_warps, num_stages) — graph-tuned on gfx950. | ||
|
|
||
|
|
@@ -282,6 +374,14 @@ def _select_cfg(M, N, K): | |
| return 16, 16, 1024, 2, 3 | ||
| if K == 768 and N == 6144: | ||
| return 16, 16, 256, 2, 3 | ||
| # M3.1 TP2 qkv regresses with the M192 tile; use the fallback below. | ||
| if ( | ||
| _ON_GFX950 | ||
| and 16 < M <= 256 | ||
| and N > 1280 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Will this affect other models as well? Ideally we'd only add this for M31 shapes |
||
| and not (128 < M <= 192 and N == 4992 and K == 6144) | ||
| ): | ||
| return _gfx950_mid_m_cfg(M, N, K) | ||
| if M <= 64: | ||
| # decode (M in {1,32,64}): tiny-M GEMV is weight-BW + GPU-OCCUPANCY bound. The | ||
| # lever is NARROW BLOCK_N=16 (maximize N-tiles so more CUs stream the weight in | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.