-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Vulkan MMQ Integer Dot Refactor and K-Quant support #16536
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
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2d6efa4
vulkan: add mmq q2_k integer dot support
0cc4m c4711d8
Refactor mmq caching
0cc4m 0775df7
Reduce mmq register use
0cc4m ded8089
Load 4 quant blocks into shared memory in one step
0cc4m e978f66
Pack q2_k blocks into caches of 32
0cc4m 1309d7d
Use 32-bit accumulators for integer dot matmul
0cc4m 5148d4a
Add q4_k mmq
0cc4m 6d83a8d
Add q3_k mmq
0cc4m c9382df
Add q5_k mmq
0cc4m 84cb48c
Add q6_k mmq
0cc4m 40d75d9
Add mxfp4 mmq, enable MMQ MUL_MAT_ID
0cc4m 3b5a6f8
Fix mmv dm loads
0cc4m 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #ifdef MUL_MAT_ID | ||
| shared u16vec2 row_ids[BN]; | ||
| uint _ne1; | ||
|
|
||
| #ifdef MUL_MAT_ID_USE_SUBGROUPS | ||
| shared uvec4 ballots_sh[NUM_WARPS]; | ||
|
|
||
| void load_row_ids(uint expert_idx, bool nei0_is_pow2, uint ic) { | ||
| _ne1 = 0; | ||
| uint num_elements = p.nei1 * p.nei0; | ||
| uint nei0shift = findLSB(p.nei0); | ||
|
|
||
| uint ids[16]; | ||
| uint iter = 0; | ||
|
|
||
| for (uint j = 0; j < num_elements; j += BLOCK_SIZE) { | ||
| // prefetch up to 16 elements | ||
| if (iter == 0) { | ||
| [[unroll]] for (uint k = 0; k < 16; ++k) { | ||
| uint i = j + gl_LocalInvocationIndex + k*BLOCK_SIZE; | ||
| bool in_range = i < num_elements; | ||
| uint ii1; | ||
| if (nei0_is_pow2) { | ||
| ii1 = i >> nei0shift; | ||
| } else { | ||
| ii1 = i / p.nei0; | ||
| } | ||
| uint ii0 = i - ii1 * p.nei0; | ||
| ids[k] = in_range ? data_ids[ii1*p.nbi1 + ii0] : 0; | ||
| } | ||
| } | ||
| uint i = j + gl_LocalInvocationIndex; | ||
| bool in_range = i < num_elements; | ||
| uint ii1; | ||
| if (nei0_is_pow2) { | ||
| ii1 = i >> nei0shift; | ||
| } else { | ||
| ii1 = i / p.nei0; | ||
| } | ||
| uint ii0 = i - ii1 * p.nei0; | ||
| uint id = ids[iter++]; | ||
| uvec4 ballot = subgroupBallot(in_range && id == expert_idx); | ||
|
|
||
| ballots_sh[gl_SubgroupID] = ballot; | ||
| barrier(); | ||
|
|
||
| uint subgroup_base = 0; | ||
| uint total = 0; | ||
| for (uint k = 0; k < gl_NumSubgroups; ++k) { | ||
| if (k == gl_SubgroupID) { | ||
| subgroup_base = total; | ||
| } | ||
| total += subgroupBallotBitCount(ballots_sh[k]); | ||
| } | ||
| barrier(); | ||
|
|
||
| uint idx = subgroup_base + subgroupBallotExclusiveBitCount(ballot); | ||
| if (in_range && id == expert_idx && _ne1 + idx >= ic * BN && _ne1 + idx < (ic + 1) * BN) { | ||
| row_ids[_ne1 + idx - ic * BN] = u16vec2(ii0, ii1); | ||
| } | ||
| _ne1 += total; | ||
| iter &= 15; | ||
| if (_ne1 >= (ic + 1) * BN) { | ||
| break; | ||
| } | ||
| } | ||
| barrier(); | ||
| } | ||
| #endif // MUL_MAT_ID_USE_SUBGROUPS | ||
| #endif // MUL_MAT_ID |
Oops, something went wrong.
Oops, something went wrong.
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.