-
Notifications
You must be signed in to change notification settings - Fork 269
[CK_Tile] Adding support for preshuffleQuant in AB quant Block Scale Gemm #3629
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
amd-khushbu
wants to merge
8
commits into
develop
Choose a base branch
from
AB_preshuffleQuant
base: develop
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.
+475
−363
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
68aef7b
initial commit
amd-khushbu e5568de
Merge branch 'develop' into AB_preshuffleQuant
amd-khushbu 934d04b
preshuffleQuant support for ABQuant
amd-khushbu bc13451
fix mxfp4 to use correct QuantGroupSize
amd-khushbu dd2cb29
resolving merge conflicts
amd-khushbu 30b0005
adding tests for preshuffleQuant
amd-khushbu 0fd4001
Merge branch 'develop' into AB_preshuffleQuant
amd-khushbu 56a9b17
fixing A/B preshuffle quant to enable only BpreshuffleQaunt in ABQuant
amd-khushbu 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
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 |
|---|---|---|
|
|
@@ -69,7 +69,8 @@ struct BlockGemmWeightPreshuffleABQuantARegBRegCReg | |
| static constexpr index_t NIterPerWarp = NPerBlock / (NWarp * WarpGemm::kN); | ||
| static constexpr index_t KIterPerWarp = KPerBlock / WarpGemm::kK; | ||
|
|
||
| static constexpr bool PreshuffleQuant = Problem::Traits::PreshuffleQuant; | ||
| static constexpr bool APreshuffleQuant = Problem::Traits::APreshuffleQuant; | ||
| static constexpr bool BPreshuffleQuant = Problem::Traits::BPreshuffleQuant; | ||
|
|
||
| static constexpr index_t QScalesPerBlockRow = | ||
| integer_divide_ceil(KPerBlock, BQuantGroupSize::kK); | ||
|
|
@@ -127,9 +128,9 @@ struct BlockGemmWeightPreshuffleABQuantARegBRegCReg | |
| using CDataType = remove_cvref_t<typename Problem::CDataType>; | ||
| using ComputeDataType = remove_cvref_t<typename Problem::ComputeDataType>; | ||
| using BlockGemmShape = remove_cvref_t<typename Problem::BlockGemmShape>; // TileFlatmmShape | ||
| using QuantGroupSize = remove_cvref_t<typename Problem::BQuantGroupSize>; | ||
| using BQuantGroupSize = remove_cvref_t<typename Problem::BQuantGroupSize>; | ||
|
|
||
| static_assert(QuantGroupSize::kM == 1, "only N/K blocks for BQuant preshuffle kernel!"); | ||
| static_assert(BQuantGroupSize::kM == 1, "only N/K blocks for BQuant preshuffle kernel!"); | ||
|
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. If it is named as the BQuantGroupSize, why it has kM in here? |
||
|
|
||
| static constexpr auto I0 = number<0>(); | ||
| static constexpr auto I1 = number<1>(); | ||
|
|
@@ -162,12 +163,12 @@ struct BlockGemmWeightPreshuffleABQuantARegBRegCReg | |
| static constexpr auto MIter_2nd_last = | ||
| (MIterPerWarp >= 2) ? MIterPerWarp - 2 : MIterPerWarp - 1; | ||
|
|
||
| static constexpr index_t KPerBlockBQ = KPerBlock / QuantGroupSize::kK; | ||
| static constexpr index_t KPerBlockBQ = KPerBlock / BQuantGroupSize::kK; | ||
|
|
||
| static constexpr index_t QScalesPerBlockRow = | ||
| integer_divide_ceil(KPerBlock, QuantGroupSize::kK); // 128 / 128 = 1 | ||
| integer_divide_ceil(KPerBlock, BQuantGroupSize::kK); // 128 / 128 = 1 | ||
| static constexpr index_t QScalesPerWarpGemmRow = | ||
| integer_divide_ceil(WG::kK, QuantGroupSize::kK); | ||
| integer_divide_ceil(WG::kK, BQuantGroupSize::kK); | ||
|
|
||
| static constexpr index_t KIterPerQScale = KIterPerWarp / QScalesPerBlockRow; // 8 / 1 = 8 | ||
| static constexpr index_t DsReadPreload = 2; // default 2, preload 2 ds read | ||
|
|
@@ -289,9 +290,9 @@ struct BlockGemmWeightPreshuffleABQuantARegBRegCReg | |
| CBlockTensor::PackedSize>{}; | ||
|
|
||
| index_t reg_offset = [&]() { | ||
| if constexpr(QuantGroupSize::kN >= (NWarp * WG::kN)) | ||
| if constexpr(BQuantGroupSize::kN >= (NWarp * WG::kN)) | ||
| { | ||
| return (nIter * NWarp * WG::kN) / QuantGroupSize::kN * KPerBlockBQ + | ||
| return (nIter * NWarp * WG::kN) / BQuantGroupSize::kN * KPerBlockBQ + | ||
| kQScale; | ||
| } | ||
| else | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -25,9 +25,9 @@ struct BlockGemmWeightPreshuffleBQuantARegBRegCReg | |
| using CDataType = remove_cvref_t<typename Problem::CDataType>; | ||
| using ComputeDataType = remove_cvref_t<typename Problem::ComputeDataType>; | ||
| using BlockGemmShape = remove_cvref_t<typename Problem::BlockGemmShape>; // TileFlatmmShape | ||
| using QuantGroupSize = remove_cvref_t<typename Problem::BQuantGroupSize>; | ||
| using BQuantGroupSize = remove_cvref_t<typename Problem::BQuantGroupSize>; | ||
|
|
||
| static_assert(QuantGroupSize::kM == 1, "only N/K blocks for BQuant preshuffle kernel!"); | ||
| static_assert(BQuantGroupSize::kM == 1, "only N/K blocks for BQuant preshuffle kernel!"); | ||
|
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. Same as the previous file comment |
||
|
|
||
| static constexpr auto I0 = number<0>(); | ||
| static constexpr auto I1 = number<1>(); | ||
|
|
@@ -53,7 +53,7 @@ struct BlockGemmWeightPreshuffleBQuantARegBRegCReg | |
|
|
||
| static constexpr index_t kBlockSize = Problem::kBlockSize; | ||
|
|
||
| static constexpr bool PreshuffleQuant = Problem::Traits::PreshuffleQuant; | ||
| static constexpr bool BPreshuffleQuant = Problem::Traits::BPreshuffleQuant; | ||
|
|
||
| static constexpr index_t MIterPerWarp = MPerBlock / (MWarp * WG::kM); | ||
| static constexpr index_t NIterPerWarp = | ||
|
|
@@ -63,12 +63,12 @@ struct BlockGemmWeightPreshuffleBQuantARegBRegCReg | |
| static constexpr auto MIter_2nd_last = | ||
| (MIterPerWarp >= 2) ? MIterPerWarp - 2 : MIterPerWarp - 1; | ||
|
|
||
| static constexpr index_t KPerBlockBQ = KPerBlock / QuantGroupSize::kK; | ||
| static constexpr index_t KPerBlockBQ = KPerBlock / BQuantGroupSize::kK; | ||
|
|
||
| static constexpr index_t QScalesPerBlockRow = | ||
| integer_divide_ceil(KPerBlock, QuantGroupSize::kK); | ||
| integer_divide_ceil(KPerBlock, BQuantGroupSize::kK); | ||
| static constexpr index_t QScalesPerWarpGemmRow = | ||
| integer_divide_ceil(WG::kK, QuantGroupSize::kK); | ||
| integer_divide_ceil(WG::kK, BQuantGroupSize::kK); | ||
|
|
||
| static constexpr index_t KIterPerQScale = KIterPerWarp / QScalesPerBlockRow; | ||
| static constexpr index_t DsReadPreload = 2; // default 2, preload 2 ds read | ||
|
|
@@ -173,7 +173,7 @@ struct BlockGemmWeightPreshuffleBQuantARegBRegCReg | |
| c_warp_y_index_zeros)) / | ||
| CBlockTensor::PackedSize>{}; | ||
|
|
||
| if constexpr(PreshuffleQuant) | ||
| if constexpr(BPreshuffleQuant) | ||
| { | ||
| constexpr index_t reg_offset = nIter; | ||
| auto pull_from_lane = (__lane_id() & (WG::kN - 1)) * KPerBlockBQ + kQScale; | ||
|
|
@@ -205,9 +205,10 @@ struct BlockGemmWeightPreshuffleBQuantARegBRegCReg | |
| else | ||
| { | ||
| index_t reg_offset = [&]() { | ||
| if constexpr(QuantGroupSize::kN >= (NWarp * WG::kN)) | ||
| if constexpr(BQuantGroupSize::kN >= (NWarp * WG::kN)) | ||
| { | ||
| return (nIter * NWarp * WG::kN) / QuantGroupSize::kN * KPerBlockBQ + | ||
| return (nIter * NWarp * WG::kN) / BQuantGroupSize::kN * | ||
| KPerBlockBQ + | ||
| kQScale; | ||
| } | ||
| else | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I know why we need to delete this part? TensorQuant still need a 1,1 quant tensor.