dynamic workgroup reordering for MXFP4 #1001
Open
adedespirlet wants to merge 4 commits intoiree-org:mainfrom
Open
dynamic workgroup reordering for MXFP4 #1001adedespirlet wants to merge 4 commits intoiree-org:mainfrom
adedespirlet wants to merge 4 commits intoiree-org:mainfrom
Conversation
added 3 commits
February 27, 2026 19:07
Signed-off-by: Aurore De Spirlet <aurore.despirlet@gmail.com>
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
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 adds compute_best_group_size_n(), a function that dynamically determines the optimal N-dimension workgroup reordering based on the GEMM shape. The goal of this optimization is to minimize total DRAM fetches by maximizing data reuse within a "batch" of concurrent workgroups.
How it works: Score Model
On MI350 the hardware assigns flat workgroup indices round robin to 8 XCD.
Each XCD runs 32 CUs in parallel, forming a "batch" of 32 concurrent workgroups per XCD. Each batch of in flight workgroups covers an "area" of unique A tiles (U_A) and unique B tiles (U_B).
We model the cost of DRAM traffic as:
Cost_score = U_A + U_B
Subject to the constraint: U_A x U_B = 32 (batch size per XCD)
That sum is minimized when U_A and U_B are balanced ~= 5.65
To fit integer tile dimensions, we target the closest factors of 32: 4 and 8.
So an optimal balance of (4,8) or (8,4) gives a minimal score of 12. (this means for any XCD we have : 4 WGs mapped along either M/N and 8 WGs along either N/M)
Dynamic Selection:
compute_best_group_size_n compares the default hardware dispatch score (which can be as high as 18 or 33 for imbalanced shapes) against the reordered dispatch.