Merged
Optimize QBMM MX tiling #6498
panzhijaAdd on Jun 25
Optimize QBMM MX tiling #6498
Merged
Merged fromsmdbha/ops-nnmasterintocann/ops-nnmaster
Total: 21 files changed+807-527
| @@ -28,7 +28,6 @@ public: | |||
| 28 | explicit FusedQuantMatMulASWTiling(gert::TilingContext *context) : AdaptiveSlidingWindowCubeTiling(context) | 28 | explicit FusedQuantMatMulASWTiling(gert::TilingContext *context) : AdaptiveSlidingWindowCubeTiling(context) |
| 29 | { | 29 | { |
| 30 | inputParams_.Reset(); | 30 | inputParams_.Reset(); |
| 31 | - ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 32 | } | 31 | } |
| 33 | ~FusedQuantMatMulASWTiling() override = default; | 32 | ~FusedQuantMatMulASWTiling() override = default; |
| 34 | 33 | ||
Mmatmul/quant_batch_matmul_inplace_add/op_host/op_tiling/quant_batch_matmul_inplace_add_tiling.cpp+0-2
| @@ -22,7 +22,6 @@ | |||
| 22 | #include "register/op_impl_registry.h" | 22 | #include "register/op_impl_registry.h" |
| 23 | #include "op_host/tiling_templates_registry.h" | 23 | #include "op_host/tiling_templates_registry.h" |
| 24 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/platform_util.h" | 24 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/platform_util.h" |
| 25 | -#include "../../../quant_batch_matmul_v3/op_host/op_tiling/arch35/adaptive_sliding_window_tiling.h" | ||
| 26 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/quant_batch_matmul_v3_compile_info.h" | 25 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/quant_batch_matmul_v3_compile_info.h" |
| 27 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/quant_batch_matmul_v3_tiling_base.h" | 26 | #include "../../../quant_batch_matmul_v3/op_host/op_tiling/quant_batch_matmul_v3_tiling_base.h" |
| 28 | 27 | ||
| @@ -67,7 +66,6 @@ static ge::graphStatus QuantBatchMatmulInplaceAddTilingFunc(gert::TilingContext* | |||
| 67 | 66 | ||
| 68 | OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Using the basic api tiling strategy."); | 67 | OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Using the basic api tiling strategy."); |
| 69 | ResetQuantBatchMatmulV3InputParams(); | 68 | ResetQuantBatchMatmulV3InputParams(); |
| 70 | - ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 71 | return TilingRegistryArch::GetInstance().DoTilingImpl( | 69 | return TilingRegistryArch::GetInstance().DoTilingImpl( |
| 72 | context, INPLACE_ADD_TILING_PRIORITIES, static_cast<int32_t>(compileInfoPtr->npuArch)); | 70 | context, INPLACE_ADD_TILING_PRIORITIES, static_cast<int32_t>(compileInfoPtr->npuArch)); |
| 73 | } | 71 | } |
| @@ -23,17 +23,6 @@ | |||
| 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" | 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" |
| 24 | 24 | ||
| 25 | namespace { | 25 | namespace { |
| 26 | -constexpr uint64_t AFULLLOAD_SINGLE_CORE_A_SCALER = 2UL; | ||
| 27 | -constexpr uint64_t AFULLLOAD_SINGLE_CORE_B_SCALER = 2UL; | ||
| 28 | -constexpr uint64_t WINDOW_LEN = 4UL; | ||
| 29 | -constexpr uint32_t DB_SIZE = 2; | ||
| 30 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 31 | -constexpr uint8_t L1_TWO_BUFFER = 2; | ||
| 32 | -constexpr uint8_t L1_FOUR_BUFFER = 4; | ||
| 33 | -constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 34 | -constexpr uint64_t CUBE_BLOCK = 16UL; | ||
| 35 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32UL; | ||
| 36 | - | ||
| 37 | const std::vector<int32_t> supportedNpuArch = { | 26 | const std::vector<int32_t> supportedNpuArch = { |
| 38 | static_cast<int32_t>(NpuArch::DAV_3510), static_cast<int32_t>(NpuArch::DAV_RESV)}; | 27 | static_cast<int32_t>(NpuArch::DAV_3510), static_cast<int32_t>(NpuArch::DAV_RESV)}; |
| 39 | constexpr int32_t TILING_PRIORITY = optiling::strategy::CUBE_BASIC_API_ASW; | 28 | constexpr int32_t TILING_PRIORITY = optiling::strategy::CUBE_BASIC_API_ASW; |
| @@ -99,8 +88,8 @@ ge::graphStatus AdaptiveSlidingWindowCubeBasicAPITiling::GetWorkspaceSize() | |||
| 99 | if (isSupportS4S4_) { | 88 | if (isSupportS4S4_) { |
| 100 | uint64_t aInt8Size = inputParams_.batchC * inputParams_.mSize * inputParams_.kSize; | 89 | uint64_t aInt8Size = inputParams_.batchC * inputParams_.mSize * inputParams_.kSize; |
| 101 | uint64_t bInt8Size = inputParams_.kSize * inputParams_.nSize; | 90 | uint64_t bInt8Size = inputParams_.kSize * inputParams_.nSize; |
| 102 | - workspaceSize_ += ops::CeilAlign(aInt8Size, BASIC_BLOCK_SIZE_128) + | 91 | + workspaceSize_ += ops::CeilAlign(aInt8Size, qmmv3_tiling_const::BASIC_BLOCK_SIZE_128) + |
| 103 | - ops::CeilAlign(bInt8Size, BASIC_BLOCK_SIZE_128); | 92 | + ops::CeilAlign(bInt8Size, qmmv3_tiling_const::BASIC_BLOCK_SIZE_128); |
| 104 | } | 93 | } |
| 105 | return ge::GRAPH_SUCCESS; | 94 | return ge::GRAPH_SUCCESS; |
| 106 | } | 95 | } |
| @@ -152,9 +141,9 @@ bool AdaptiveSlidingWindowCubeBasicAPITiling::CalL1Tiling() | |||
| 152 | 141 | ||
| 153 | basicTiling_.iterateOrder = 0U; | 142 | basicTiling_.iterateOrder = 0U; |
| 154 | basicTiling_.dbL0c = | 143 | basicTiling_.dbL0c = |
| 155 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize) && | 144 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize) && |
| 156 | - CheckBiasAndScale(basicTiling_.baseN, DB_SIZE)) ? | 145 | + CheckBiasAndScale(basicTiling_.baseN, qmmv3_tiling_const::DOUBLE_BUFFER_NUM)) ? |
| 157 | - DB_SIZE : | 146 | + qmmv3_tiling_const::DOUBLE_BUFFER_NUM : |
| 158 | 1U; | 147 | 1U; |
| 159 | 148 | ||
| 160 | L1TilingMode mode = L1TilingMode::DEFAULT; | 149 | L1TilingMode mode = L1TilingMode::DEFAULT; |
| @@ -206,25 +195,25 @@ void AdaptiveSlidingWindowCubeBasicAPITiling::CalculateNBufferNum4Cube() | |||
| 206 | } | 195 | } |
| 207 | uint64_t usedL1Size = 0UL; | 196 | uint64_t usedL1Size = 0UL; |
| 208 | if (isBFullLoad_) { | 197 | if (isBFullLoad_) { |
| 209 | - uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, inputParams_.transB ? CUBE_REDUCE_BLOCK : CUBE_BLOCK); | 198 | + uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, inputParams_.transB ? qmmv3_tiling_const::CUBE_REDUCE_BLOCK : qmmv3_tiling_const::CUBE_BLOCK); |
| 210 | usedL1Size = GetSizeWithDataType(basicTiling_.baseN * kAligned, inputParams_.bDtype); | 199 | usedL1Size = GetSizeWithDataType(basicTiling_.baseN * kAligned, inputParams_.bDtype); |
| 211 | } else { | 200 | } else { |
| 212 | - usedL1Size = GetSizeWithDataType(basicTiling_.baseN * kL1, inputParams_.bDtype) * L1_FOUR_BUFFER; | 201 | + usedL1Size = GetSizeWithDataType(basicTiling_.baseN * kL1, inputParams_.bDtype) * qmmv3_tiling_const::L1_FOUR_BUFFER; |
| 213 | } | 202 | } |
| 214 | if (inputParams_.isPerChannel) { | 203 | if (inputParams_.isPerChannel) { |
| 215 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseN, inputParams_.scaleDtype) * L1_TWO_BUFFER; | 204 | + usedL1Size += GetSizeWithDataType(basicTiling_.baseN, inputParams_.scaleDtype) * qmmv3_tiling_const::L1_TWO_BUFFER; |
| 216 | } | 205 | } |
| 217 | if (inputParams_.hasBias) { | 206 | if (inputParams_.hasBias) { |
| 218 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseN, inputParams_.biasDtype) * L1_TWO_BUFFER; | 207 | + usedL1Size += GetSizeWithDataType(basicTiling_.baseN, inputParams_.biasDtype) * qmmv3_tiling_const::L1_TWO_BUFFER; |
| 219 | } | 208 | } |
| 220 | if (isAFullLoad_) { | 209 | if (isAFullLoad_) { |
| 221 | - uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, !inputParams_.transA ? CUBE_REDUCE_BLOCK : CUBE_BLOCK); | 210 | + uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, !inputParams_.transA ? qmmv3_tiling_const::CUBE_REDUCE_BLOCK : qmmv3_tiling_const::CUBE_BLOCK); |
| 222 | usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kAligned, inputParams_.aDtype); | 211 | usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kAligned, inputParams_.aDtype); |
| 223 | } else { | 212 | } else { |
| 224 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kL1, inputParams_.aDtype) * L1_FOUR_BUFFER; | 213 | + usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kL1, inputParams_.aDtype) * qmmv3_tiling_const::L1_FOUR_BUFFER; |
| 225 | } | 214 | } |
| 226 | - tilingData_.matmulTiling.nBufferNum = usedL1Size < aicoreParams_.l1Size ? L1_FOUR_BUFFER : L1_TWO_BUFFER; | 215 | + tilingData_.matmulTiling.nBufferNum = usedL1Size <= aicoreParams_.l1Size ? qmmv3_tiling_const::L1_FOUR_BUFFER : qmmv3_tiling_const::L1_TWO_BUFFER; |
| 227 | - if (tilingData_.matmulTiling.nBufferNum == L1_FOUR_BUFFER) { | 216 | + if (tilingData_.matmulTiling.nBufferNum == qmmv3_tiling_const::L1_FOUR_BUFFER) { |
| 228 | tilingData_.matmulTiling.stepKa = std::min(basicTiling_.stepKa, basicTiling_.stepKb); | 217 | tilingData_.matmulTiling.stepKa = std::min(basicTiling_.stepKa, basicTiling_.stepKb); |
| 229 | tilingData_.matmulTiling.stepKb = tilingData_.matmulTiling.stepKa; | 218 | tilingData_.matmulTiling.stepKb = tilingData_.matmulTiling.stepKa; |
| 230 | } | 219 | } |
| @@ -235,13 +224,13 @@ void AdaptiveSlidingWindowCubeBasicAPITiling::UpdateAFullLoadStatus() | |||
| 235 | uint64_t realBaseMSize = adaptiveWin_.mBaseTailSplitCnt == 1UL ? adaptiveWin_.baseM : adaptiveWin_.mTailMain; | 224 | uint64_t realBaseMSize = adaptiveWin_.mBaseTailSplitCnt == 1UL ? adaptiveWin_.baseM : adaptiveWin_.mTailMain; |
| 236 | uint64_t singleCoreASize = realBaseMSize * | 225 | uint64_t singleCoreASize = realBaseMSize * |
| 237 | (inputParams_.transA ? | 226 | (inputParams_.transA ? |
| 238 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), | 227 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), |
| 239 | inputParams_.aDtype) : | 228 | inputParams_.aDtype) : |
| 240 | ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), | 229 | ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), |
| 241 | - CUBE_REDUCE_BLOCK)); | 230 | + qmmv3_tiling_const::CUBE_REDUCE_BLOCK)); |
| 242 | 231 | ||
| 243 | - isAFullLoad_ = singleCoreASize <= aicoreParams_.l1Size / AFULLLOAD_SINGLE_CORE_A_SCALER && | 232 | + isAFullLoad_ = singleCoreASize <= aicoreParams_.l1Size / qmmv3_tiling_const::AFULLLOAD_SINGLE_CORE_A_SCALER && |
| 244 | - adaptiveWin_.mBlockCnt < WINDOW_LEN && aicoreParams_.aicNum % adaptiveWin_.mBlockCnt == 0 && | 233 | + adaptiveWin_.mBlockCnt < qmmv3_tiling_const::WINDOW_LEN && aicoreParams_.aicNum % adaptiveWin_.mBlockCnt == 0 && |
| 245 | adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; | 234 | adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; |
| 246 | if (isAFullLoad_ && adaptiveWin_.baseM != realBaseMSize) { | 235 | if (isAFullLoad_ && adaptiveWin_.baseM != realBaseMSize) { |
| 247 | adaptiveWin_.baseM = realBaseMSize; | 236 | adaptiveWin_.baseM = realBaseMSize; |
| @@ -260,13 +249,15 @@ void AdaptiveSlidingWindowCubeBasicAPITiling::UpdateBFullLoadStatus() | |||
| 260 | uint64_t singleCoreBSize = realBaseNSize * | 249 | uint64_t singleCoreBSize = realBaseNSize * |
| 261 | (inputParams_.transB ? | 250 | (inputParams_.transB ? |
| 262 | ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), | 251 | ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), |
| 263 | - CUBE_REDUCE_BLOCK) : | 252 | + qmmv3_tiling_const::CUBE_REDUCE_BLOCK) : |
| 264 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), | 253 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), |
| 265 | inputParams_.bDtype)); | 254 | inputParams_.bDtype)); |
| 266 | 255 | ||
| 267 | - isBFullLoad_ = singleCoreBSize <= aicoreParams_.l1Size / AFULLLOAD_SINGLE_CORE_B_SCALER && | 256 | + isBFullLoad_ = |
| 268 | - adaptiveWin_.nBlockCnt < WINDOW_LEN && aicoreParams_.aicNum % adaptiveWin_.nBlockCnt == 0 && | 257 | + singleCoreBSize <= aicoreParams_.l1Size / qmmv3_tiling_const::AFULLLOAD_SINGLE_CORE_B_SCALER && |
| 269 | - adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; | 258 | + adaptiveWin_.nBlockCnt < qmmv3_tiling_const::WINDOW_LEN && |
| 259 | + aicoreParams_.aicNum % adaptiveWin_.nBlockCnt == 0 && | ||
| 260 | + adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; | ||
| 270 | if (isBFullLoad_ && adaptiveWin_.baseN != realBaseNSize) { | 261 | if (isBFullLoad_ && adaptiveWin_.baseN != realBaseNSize) { |
| 271 | adaptiveWin_.baseN = realBaseNSize; | 262 | adaptiveWin_.baseN = realBaseNSize; |
| 272 | adaptiveWin_.nBaseTailSplitCnt = 1UL; | 263 | adaptiveWin_.nBaseTailSplitCnt = 1UL; |
Mmatmul/quant_batch_matmul_v3/op_host/op_tiling/arch35/adaptive_sliding_window_cube_tiling.cpp+14-22
| @@ -24,16 +24,6 @@ | |||
| 24 | #include "quant_batch_matmul_v3_tiling_strategy.h" | 24 | #include "quant_batch_matmul_v3_tiling_strategy.h" |
| 25 | 25 | ||
| 26 | namespace { | 26 | namespace { |
| 27 | -constexpr uint64_t CUBE_BLOCK = 16; | ||
| 28 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32; | ||
| 29 | -constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 30 | -constexpr uint32_t DB_SIZE = 2; | ||
| 31 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 32 | -constexpr uint32_t NUM_HALF = 2; | ||
| 33 | -constexpr uint64_t MIN_CARRY_DATA_SIZE_32K = 32 * 1024UL; | ||
| 34 | -constexpr uint64_t FULL_LOAD_DATA_SIZE_64K = 64 * 1024UL; | ||
| 35 | -constexpr uint64_t CACHE_LINE_512B = 512UL; | ||
| 36 | -constexpr uint32_t MAX_STEPK_With_BL1_FULL = 8U; | ||
| 37 | 27 | ||
| 38 | const std::vector<int32_t> supportedNpuArch = { | 28 | const std::vector<int32_t> supportedNpuArch = { |
| 39 | static_cast<int32_t>(NpuArch::DAV_3510), static_cast<int32_t>(NpuArch::DAV_RESV)}; | 29 | static_cast<int32_t>(NpuArch::DAV_3510), static_cast<int32_t>(NpuArch::DAV_RESV)}; |
| @@ -93,9 +83,9 @@ bool AdaptiveSlidingWindowCubeTiling::CalL1Tiling() | |||
| 93 | 83 | ||
| 94 | basicTiling_.iterateOrder = 0U; | 84 | basicTiling_.iterateOrder = 0U; |
| 95 | basicTiling_.dbL0c = | 85 | basicTiling_.dbL0c = |
| 96 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize) && | 86 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize) && |
| 97 | - CheckBiasAndScale(basicTiling_.baseN, DB_SIZE)) ? | 87 | + CheckBiasAndScale(basicTiling_.baseN, qmmv3_tiling_const::DOUBLE_BUFFER_NUM)) ? |
| 98 | - DB_SIZE : | 88 | + qmmv3_tiling_const::DOUBLE_BUFFER_NUM : |
| 99 | 1U; | 89 | 1U; |
| 100 | L1TilingMode mode = L1TilingMode::DEFAULT; | 90 | L1TilingMode mode = L1TilingMode::DEFAULT; |
| 101 | if (compileInfo_.npuArch == NpuArch::DAV_RESV) { | 91 | if (compileInfo_.npuArch == NpuArch::DAV_RESV) { |
| @@ -138,8 +128,9 @@ void AdaptiveSlidingWindowCubeTiling::UpdateAFullLoadStatus() | |||
| 138 | uint64_t singleCoreASizeWithFullLoad = | 128 | uint64_t singleCoreASizeWithFullLoad = |
| 139 | realBaseMSize * | 129 | realBaseMSize * |
| 140 | (inputParams_.transA ? | 130 | (inputParams_.transA ? |
| 141 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.aDtype) : | 131 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.aDtype) : |
| 142 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), CUBE_REDUCE_BLOCK)); | 132 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK)); |
| 133 | + // Empirical A full-load cap: keep A under 256KB so L1 still has room for B-side data and auxiliary buffers. | ||
| 143 | constexpr uint64_t A_L1_LOAD_THRESHOLD = 256 * 1024UL; | 134 | constexpr uint64_t A_L1_LOAD_THRESHOLD = 256 * 1024UL; |
| 144 | bool blockCntCmp = (adaptiveWin_.mBlockCnt <= adaptiveWin_.nBlockCnt); | 135 | bool blockCntCmp = (adaptiveWin_.mBlockCnt <= adaptiveWin_.nBlockCnt); |
| 145 | if (compileInfo_.supportMmadS8S4) { | 136 | if (compileInfo_.supportMmadS8S4) { |
| @@ -170,11 +161,11 @@ void AdaptiveSlidingWindowCubeTiling::UpdateBFullLoadStatus() | |||
| 170 | uint64_t singleCoreBSizeWithFullLoad = | 161 | uint64_t singleCoreBSizeWithFullLoad = |
| 171 | adaptiveWin_.baseN * | 162 | adaptiveWin_.baseN * |
| 172 | (inputParams_.transB ? | 163 | (inputParams_.transB ? |
| 173 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), CUBE_REDUCE_BLOCK) : | 164 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK) : |
| 174 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.bDtype)); | 165 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.bDtype)); |
| 175 | 166 | ||
| 176 | isBFullLoad_ = | 167 | isBFullLoad_ = |
| 177 | - singleCoreBSizeWithFullLoad <= aicoreParams_.l1Size / NUM_HALF && | 168 | + singleCoreBSizeWithFullLoad <= aicoreParams_.l1Size / qmmv3_tiling_const::NUM_HALF && |
| 178 | adaptiveWin_.mBlockCnt > adaptiveWin_.nBlockCnt && | 169 | adaptiveWin_.mBlockCnt > adaptiveWin_.nBlockCnt && |
| 179 | (((adaptiveWin_.nBlockCnt == 1UL || adaptiveWin_.nBlockCnt == 2UL || adaptiveWin_.nBlockCnt == 4UL) && | 170 | (((adaptiveWin_.nBlockCnt == 1UL || adaptiveWin_.nBlockCnt == 2UL || adaptiveWin_.nBlockCnt == 4UL) && |
| 180 | aicoreParams_.aicNum >= adaptiveWin_.nBlockCnt && aicoreParams_.aicNum % adaptiveWin_.nBlockCnt == 0) || | 171 | aicoreParams_.aicNum >= adaptiveWin_.nBlockCnt && aicoreParams_.aicNum % adaptiveWin_.nBlockCnt == 0) || |
| @@ -192,18 +183,19 @@ void AdaptiveSlidingWindowCubeTiling::UpdateABFullLoadStatus() | |||
| 192 | uint64_t singleCoreASizeWithFullLoad = | 183 | uint64_t singleCoreASizeWithFullLoad = |
| 193 | adaptiveWin_.baseM * | 184 | adaptiveWin_.baseM * |
| 194 | (inputParams_.transA ? | 185 | (inputParams_.transA ? |
| 195 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.aDtype) : | 186 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.aDtype) : |
| 196 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), CUBE_REDUCE_BLOCK)); | 187 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK)); |
| 197 | uint64_t singleCoreBSizeWithFullLoad = | 188 | uint64_t singleCoreBSizeWithFullLoad = |
| 198 | adaptiveWin_.baseN * | 189 | adaptiveWin_.baseN * |
| 199 | (inputParams_.transB ? | 190 | (inputParams_.transB ? |
| 200 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), CUBE_REDUCE_BLOCK) : | 191 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK) : |
| 201 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.bDtype)); | 192 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.bDtype)); |
| 202 | 193 | ||
| 203 | uint64_t biasDtypeSize = ge::GetSizeByDataType(inputParams_.biasDtype); | 194 | uint64_t biasDtypeSize = ge::GetSizeByDataType(inputParams_.biasDtype); |
| 204 | uint64_t scaleDtypeSize = ge::GetSizeByDataType(inputParams_.scaleDtype); | 195 | uint64_t scaleDtypeSize = ge::GetSizeByDataType(inputParams_.scaleDtype); |
| 205 | uint64_t singleCoreBiasSize = inputParams_.hasBias ? adaptiveWin_.baseN * biasDtypeSize : 0UL; | 196 | uint64_t singleCoreBiasSize = inputParams_.hasBias ? adaptiveWin_.baseN * biasDtypeSize : 0UL; |
| 206 | uint64_t singleCoreScaleSize = inputParams_.isPerChannel ? adaptiveWin_.baseN * scaleDtypeSize : 0UL; | 197 | uint64_t singleCoreScaleSize = inputParams_.isPerChannel ? adaptiveWin_.baseN * scaleDtypeSize : 0UL; |
| 198 | + // AB full-load needs one operand small and combined A+B below this tuned cap to leave room for bias/scale. | ||
| 207 | constexpr uint64_t AB_L1_SINGLE_LOAD_THRESHOLD = 64 * 1024UL; | 199 | constexpr uint64_t AB_L1_SINGLE_LOAD_THRESHOLD = 64 * 1024UL; |
| 208 | constexpr uint64_t AB_L1_BOTH_LOAD_THRESHOLD = 272 * 1024UL; | 200 | constexpr uint64_t AB_L1_BOTH_LOAD_THRESHOLD = 272 * 1024UL; |
| 209 | bool hasEnoughL1 = | 201 | bool hasEnoughL1 = |
| @@ -24,12 +24,6 @@ | |||
| 24 | #include "quant_batch_matmul_v3_tiling_strategy.h" | 24 | #include "quant_batch_matmul_v3_tiling_strategy.h" |
| 25 | 25 | ||
| 26 | namespace { | 26 | namespace { |
| 27 | -constexpr uint64_t CUBE_BLOCK = 16; | ||
| 28 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32; | ||
| 29 | -constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 30 | -constexpr uint32_t DB_SIZE = 2; | ||
| 31 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 32 | -constexpr uint32_t CORE_RATIO = 2U; | ||
| 33 | 27 | ||
| 34 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; | 28 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; |
| 35 | constexpr int32_t TILING_PRIORITY = optiling::strategy::MIX_ASW; | 29 | constexpr int32_t TILING_PRIORITY = optiling::strategy::MIX_ASW; |
| @@ -81,7 +75,7 @@ bool AdaptiveSlidingWindowMixTiling::IsCapable() | |||
| 81 | 75 | ||
| 82 | bool AdaptiveSlidingWindowMixTiling::CheckCoreNum() const | 76 | bool AdaptiveSlidingWindowMixTiling::CheckCoreNum() const |
| 83 | { | 77 | { |
| 84 | - if (compileInfo_.aivNum != CORE_RATIO * compileInfo_.aicNum) { | 78 | + if (compileInfo_.aivNum != qmmv3_tiling_const::CORE_RATIO * compileInfo_.aicNum) { |
| 85 | OP_LOGE( | 79 | OP_LOGE( |
| 86 | inputParams_.opName, "For mix template, aicNum:aivNum should be 1:2, actual aicNum: %u, aivNum: %u.", | 80 | inputParams_.opName, "For mix template, aicNum:aivNum should be 1:2, actual aicNum: %u, aivNum: %u.", |
| 87 | compileInfo_.aicNum, compileInfo_.aivNum); | 81 | compileInfo_.aicNum, compileInfo_.aivNum); |
| @@ -96,8 +90,8 @@ ge::graphStatus AdaptiveSlidingWindowMixTiling::GetWorkspaceSize() | |||
| 96 | if (isSupportS4S4_) { | 90 | if (isSupportS4S4_) { |
| 97 | uint64_t aInt8Size = inputParams_.batchC * inputParams_.mSize * inputParams_.kSize; | 91 | uint64_t aInt8Size = inputParams_.batchC * inputParams_.mSize * inputParams_.kSize; |
| 98 | uint64_t bInt8Size = inputParams_.kSize * inputParams_.nSize; | 92 | uint64_t bInt8Size = inputParams_.kSize * inputParams_.nSize; |
| 99 | - workspaceSize_ += ops::CeilAlign(aInt8Size, BASIC_BLOCK_SIZE_128) + | 93 | + workspaceSize_ += ops::CeilAlign(aInt8Size, qmmv3_tiling_const::BASIC_BLOCK_SIZE_128) + |
| 100 | - ops::CeilAlign(bInt8Size, BASIC_BLOCK_SIZE_128); | 94 | + ops::CeilAlign(bInt8Size, qmmv3_tiling_const::BASIC_BLOCK_SIZE_128); |
| 101 | } | 95 | } |
| 102 | return ge::GRAPH_SUCCESS; | 96 | return ge::GRAPH_SUCCESS; |
| 103 | } | 97 | } |
| @@ -127,8 +121,9 @@ void AdaptiveSlidingWindowMixTiling::UpdateAFullLoadStatus() | |||
| 127 | uint64_t singleCoreASizeWithFullLoad = | 121 | uint64_t singleCoreASizeWithFullLoad = |
| 128 | realBaseMSize * | 122 | realBaseMSize * |
| 129 | (inputParams_.transA ? | 123 | (inputParams_.transA ? |
| 130 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.aDtype) : | 124 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.aDtype) : |
| 131 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), CUBE_REDUCE_BLOCK)); | 125 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK)); |
| 126 | + // Empirical A full-load cap: keep A under 256KB so L1 still has room for B-side data and auxiliary buffers. | ||
| 132 | constexpr uint64_t A_L1_LOAD_THRESHOLD = 256 * 1024UL; | 127 | constexpr uint64_t A_L1_LOAD_THRESHOLD = 256 * 1024UL; |
| 133 | bool blockCntCmp = (adaptiveWin_.mBlockCnt <= adaptiveWin_.nBlockCnt); | 128 | bool blockCntCmp = (adaptiveWin_.mBlockCnt <= adaptiveWin_.nBlockCnt); |
| 134 | isAFullLoad_ = | 129 | isAFullLoad_ = |
| @@ -177,9 +172,9 @@ bool AdaptiveSlidingWindowMixTiling::CalL1Tiling() | |||
| 177 | 172 | ||
| 178 | basicTiling_.iterateOrder = 0U; | 173 | basicTiling_.iterateOrder = 0U; |
| 179 | basicTiling_.dbL0c = | 174 | basicTiling_.dbL0c = |
| 180 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize) && | 175 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize) && |
| 181 | - CheckBiasAndScale(basicTiling_.baseN, DB_SIZE)) ? | 176 | + CheckBiasAndScale(basicTiling_.baseN, qmmv3_tiling_const::DOUBLE_BUFFER_NUM)) ? |
| 182 | - DB_SIZE : | 177 | + qmmv3_tiling_const::DOUBLE_BUFFER_NUM : |
| 183 | 1U; | 178 | 1U; |
| 184 | 179 | ||
| 185 | L1TilingMode mode = isAFullLoad_ ? L1TilingMode::A_L1_FULL_LOAD : L1TilingMode::DEFAULT; | 180 | L1TilingMode mode = isAFullLoad_ ? L1TilingMode::A_L1_FULL_LOAD : L1TilingMode::DEFAULT; |
| @@ -23,25 +23,23 @@ | |||
| 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" | 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" |
| 24 | 24 | ||
| 25 | namespace { | 25 | namespace { |
| 26 | -constexpr uint64_t AFULLLOAD_SINGLE_CORE_A_SCALER = 2UL; | 26 | +constexpr uint32_t STEP_K_TWO = 2U; |
| 27 | -constexpr uint64_t WINDOW_LEN = 4UL; | 27 | +// Keep A full-load if repeated A reads exceed this share of non-full-load GM traffic. |
| 28 | - | 28 | +constexpr double REPEAT_A_LOAD_RATIO_THRESHOLD = 0.20; |
| 29 | -constexpr uint32_t DB_SIZE = 2; | ||
| 30 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 31 | - | ||
| 32 | -constexpr uint32_t SCALER_FACTOR_MAX = 127; | ||
| 33 | -constexpr uint32_t SCALER_FACTOR_MIN = 1; | ||
| 34 | -constexpr uint32_t SCALER_FACTOR_DEFAULT = 1; | ||
| 35 | - | ||
| 36 | -constexpr uint8_t L1_TWO_BUFFER = 2; | ||
| 37 | -constexpr uint8_t L1_FOUR_BUFFER = 4; | ||
| 38 | - | ||
| 39 | -constexpr uint64_t MX_GROUP_SIZE = 32UL; | ||
| 40 | -constexpr uint64_t MXFP_DIVISOR_SIZE = 64UL; | ||
| 41 | -constexpr uint64_t MXFP_MULTI_BASE_SIZE = 2UL; | ||
| 42 | 29 | ||
| 43 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; | 30 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; |
| 44 | constexpr int32_t TILING_PRIORITY = optiling::strategy::MX_BASIC_API_ASW; | 31 | constexpr int32_t TILING_PRIORITY = optiling::strategy::MX_BASIC_API_ASW; |
| 32 | + | ||
| 33 | +uint64_t GetSingleRoundTailSplitBase(uint64_t axisSize, uint64_t baseSize, uint64_t tailTile, uint64_t alignSize) | ||
| 34 | +{ | ||
| 35 | + if (tailTile <= 1UL) { | ||
| 36 | + return baseSize; | ||
| 37 | + } | ||
| 38 | + // A single-window tail split can be represented as a smaller aligned base block. | ||
| 39 | + uint64_t splitBase = ops::CeilDiv(std::min(axisSize, baseSize), tailTile); | ||
| 40 | + return ops::CeilAlign(splitBase, alignSize); | ||
| 41 | +} | ||
| 42 | + | ||
| 45 | } // namespace | 43 | } // namespace |
| 46 | 44 | ||
| 47 | namespace optiling { | 45 | namespace optiling { |
| @@ -129,14 +127,14 @@ bool AdaptiveSlidingWindowMXBasicAPITiling::CalL1Tiling() | |||
| 129 | 127 | ||
| 130 | basicTiling_.iterateOrder = 0U; | 128 | basicTiling_.iterateOrder = 0U; |
| 131 | basicTiling_.dbL0c = | 129 | basicTiling_.dbL0c = |
| 132 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize) && | 130 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize) && |
| 133 | - CheckBiasAndScale(basicTiling_.baseN, DB_SIZE)) ? | 131 | + CheckBiasAndScale(basicTiling_.baseN, qmmv3_tiling_const::DOUBLE_BUFFER_NUM)) ? |
| 134 | - DB_SIZE : | 132 | + qmmv3_tiling_const::DOUBLE_BUFFER_NUM : |
| 135 | 1U; | 133 | 1U; |
| 136 | 134 | ||
| 137 | L1TilingMode mode = isAFullLoad_ ? L1TilingMode::A_L1_FULL_LOAD : L1TilingMode::DEFAULT; | 135 | L1TilingMode mode = isAFullLoad_ ? L1TilingMode::A_L1_FULL_LOAD : L1TilingMode::DEFAULT; |
| 138 | - L1TilingDataCalculator l1Calculator( | 136 | + L1TilingDataCalculator l1Calculator(inputParams_, compileInfo_, basicTiling_.baseM, basicTiling_.baseN, |
| 139 | - inputParams_, compileInfo_, basicTiling_.baseM, basicTiling_.baseN, basicTiling_.baseK); | 137 | + basicTiling_.baseK); |
| 140 | if (!l1Calculator.Compute(mode)) { | 138 | if (!l1Calculator.Compute(mode)) { |
| 141 | return false; | 139 | return false; |
| 142 | } | 140 | } |
| @@ -162,18 +160,11 @@ ge::graphStatus AdaptiveSlidingWindowMXBasicAPITiling::DoLibApiTiling() | |||
| 162 | tilingData_.matmulTiling.isBias = inputParams_.hasBias ? 1UL : 0UL; | 160 | tilingData_.matmulTiling.isBias = inputParams_.hasBias ? 1UL : 0UL; |
| 163 | tilingData_.matmulTiling.dbL0C = static_cast<uint8_t>(basicTiling_.dbL0c); | 161 | tilingData_.matmulTiling.dbL0C = static_cast<uint8_t>(basicTiling_.dbL0c); |
| 164 | 162 | ||
| 165 | - tilingData_.matmulTiling.scaleKL1 = std::min( | 163 | + tilingData_.matmulTiling.scaleKL1 = std::min(basicTiling_.scaleFactorA * basicTiling_.stepKa * basicTiling_.baseK, |
| 166 | - basicTiling_.scaleFactorA * basicTiling_.stepKa * basicTiling_.baseK, | 164 | + basicTiling_.scaleFactorB * basicTiling_.stepKb * basicTiling_.baseK); |
| 167 | - basicTiling_.scaleFactorB * basicTiling_.stepKb * basicTiling_.baseK); | ||
| 168 | CalculateNBufferNum4MX(); | 165 | CalculateNBufferNum4MX(); |
| 169 | - if (basicTiling_.scaleFactorA >= SCALER_FACTOR_MIN && basicTiling_.scaleFactorA <= SCALER_FACTOR_MAX && | 166 | + tilingData_.matmulTiling.scaleFactorA = basicTiling_.scaleFactorA; |
| 170 | - basicTiling_.scaleFactorB >= SCALER_FACTOR_MIN && basicTiling_.scaleFactorB <= SCALER_FACTOR_MAX) { | 167 | + tilingData_.matmulTiling.scaleFactorB = basicTiling_.scaleFactorB; |
| 171 | - tilingData_.matmulTiling.scaleFactorA = basicTiling_.scaleFactorA; | ||
| 172 | - tilingData_.matmulTiling.scaleFactorB = basicTiling_.scaleFactorB; | ||
| 173 | - } else { | ||
| 174 | - tilingData_.matmulTiling.scaleFactorA = SCALER_FACTOR_DEFAULT; | ||
| 175 | - tilingData_.matmulTiling.scaleFactorB = SCALER_FACTOR_DEFAULT; | ||
| 176 | - } | ||
| 177 | if (useWithoutBatchTilingData_) { | 168 | if (useWithoutBatchTilingData_) { |
| 178 | SetWithoutBatchTilingData(); | 169 | SetWithoutBatchTilingData(); |
| 179 | } | 170 | } |
| @@ -182,41 +173,199 @@ ge::graphStatus AdaptiveSlidingWindowMXBasicAPITiling::DoLibApiTiling() | |||
| 182 | 173 | ||
| 183 | void AdaptiveSlidingWindowMXBasicAPITiling::CalculateNBufferNum4MX() | 174 | void AdaptiveSlidingWindowMXBasicAPITiling::CalculateNBufferNum4MX() |
| 184 | { | 175 | { |
| 185 | - tilingData_.matmulTiling.stepKa = std::min(basicTiling_.stepKa, basicTiling_.stepKb); | 176 | + uint32_t stepK = std::min(basicTiling_.stepKa, basicTiling_.stepKb); |
| 186 | - tilingData_.matmulTiling.stepKb = tilingData_.matmulTiling.stepKa; | 177 | + uint64_t kL1 = static_cast<uint64_t>(stepK) * tilingData_.matmulTiling.baseK; |
| 187 | - uint64_t kL1 = tilingData_.matmulTiling.stepKa * tilingData_.matmulTiling.baseK; | 178 | + tilingData_.matmulTiling.stepKa = stepK; |
| 188 | - uint64_t usedL1Size = GetSizeWithDataType(basicTiling_.baseN * kL1, inputParams_.bDtype) * L1_FOUR_BUFFER; | 179 | + tilingData_.matmulTiling.stepKb = stepK; |
| 180 | + uint64_t scaleKL1 = GetHalfKFallbackScaleKL1(kL1); | ||
| 181 | + uint64_t usedL1Size = CalcFourBufferUsedL1Size4MX( | ||
| 182 | + kL1, scaleKL1, tilingData_.matmulTiling.baseM, tilingData_.matmulTiling.baseN, isAFullLoad_); | ||
| 183 | + if (usedL1Size <= aicoreParams_.l1Size) { | ||
| 184 | + // Once four-buffer fits, expand scaleKL1 to cover full K if the extra scale buffer still fits L1. | ||
| 185 | + scaleKL1 = GetFullCoverScaleKL1IfPossible(kL1, scaleKL1); | ||
| 186 | + tilingData_.matmulTiling.scaleKL1 = static_cast<uint32_t>(scaleKL1); | ||
| 187 | + tilingData_.matmulTiling.nBufferNum = qmmv3_tiling_const::L1_FOUR_BUFFER; | ||
| 188 | + return; | ||
| 189 | + } | ||
| 190 | + const uint64_t stepKTwoKL1 = static_cast<uint64_t>(STEP_K_TWO) * tilingData_.matmulTiling.baseK; | ||
| 191 | + // If stepK 3/4 blocks four-buffer from fitting L1 while two-buffer still cannot cover K, | ||
| 192 | + // try stepK 2 to reduce per-round L1 usage and leave room for four-buffer. | ||
| 193 | + if ((stepK == 3U || stepK == 4U) && CanReduceStepKToTwo(stepK, stepKTwoKL1)) { | ||
| 194 | + kL1 = stepKTwoKL1; | ||
| 195 | + tilingData_.matmulTiling.stepKa = STEP_K_TWO; | ||
| 196 | + tilingData_.matmulTiling.stepKb = STEP_K_TWO; | ||
| 197 | + uint64_t candidateScaleKL1 = GetHalfKFallbackScaleKL1(kL1); | ||
| 198 | + usedL1Size = CalcFourBufferUsedL1Size4MX( | ||
| 199 | + kL1, candidateScaleKL1, tilingData_.matmulTiling.baseM, tilingData_.matmulTiling.baseN, isAFullLoad_); | ||
| 200 | + if (usedL1Size <= aicoreParams_.l1Size) { | ||
| 201 | + candidateScaleKL1 = GetFullCoverScaleKL1IfPossible(kL1, candidateScaleKL1); | ||
| 202 | + tilingData_.matmulTiling.scaleKL1 = static_cast<uint32_t>(candidateScaleKL1); | ||
| 203 | + tilingData_.matmulTiling.nBufferNum = qmmv3_tiling_const::L1_FOUR_BUFFER; | ||
| 204 | + return; | ||
| 205 | + } | ||
| 206 | + kL1 = static_cast<uint64_t>(stepK) * tilingData_.matmulTiling.baseK; | ||
| 207 | + tilingData_.matmulTiling.stepKa = stepK; | ||
| 208 | + tilingData_.matmulTiling.stepKb = stepK; | ||
| 209 | + } | ||
| 210 | + tilingData_.matmulTiling.scaleKL1 = static_cast<uint32_t>(scaleKL1); | ||
| 211 | + tilingData_.matmulTiling.nBufferNum = qmmv3_tiling_const::L1_TWO_BUFFER; | ||
| 212 | +} | ||
| 213 | + | ||
| 214 | +bool AdaptiveSlidingWindowMXBasicAPITiling::CanReduceStepKToTwo(uint32_t stepK, uint64_t stepKTwoKL1) const | ||
| 215 | +{ | ||
| 216 | + const uint64_t currentTwoBufferKL1 = | ||
| 217 | + static_cast<uint64_t>(stepK) * tilingData_.matmulTiling.baseK * qmmv3_tiling_const::L1_TWO_BUFFER; | ||
| 218 | + const bool isCurrentTwoBufferNotOverK = currentTwoBufferKL1 < inputParams_.kSize; | ||
| 219 | + | ||
| 220 | + const bool isAInnerKAligned = inputParams_.transA || | ||
| 221 | + GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype) % | ||
| 222 | + qmmv3_tiling_const::MTE2_ADDRESS_ALIGN_SIZE == 0UL; | ||
| 223 | + const bool isBInnerKAligned = !inputParams_.transB || | ||
| 224 | + GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype) % | ||
| 225 | + qmmv3_tiling_const::MTE2_ADDRESS_ALIGN_SIZE == 0UL; | ||
| 226 | + | ||
| 227 | + const bool isStepKTwoAInnerKAligned = inputParams_.transA || | ||
| 228 | + GetSizeWithDataType(stepKTwoKL1, inputParams_.aDtype) % | ||
| 229 | + qmmv3_tiling_const::BASIC_BLOCK_SIZE_256 == 0UL; | ||
| 230 | + const bool isStepKTwoBInnerKAligned = !inputParams_.transB || | ||
| 231 | + GetSizeWithDataType(stepKTwoKL1, inputParams_.bDtype) % | ||
| 232 | + qmmv3_tiling_const::BASIC_BLOCK_SIZE_256 == 0UL; | ||
| 233 | + | ||
| 234 | + return isCurrentTwoBufferNotOverK && isAInnerKAligned && isBInnerKAligned && | ||
| 235 | + isStepKTwoAInnerKAligned && isStepKTwoBInnerKAligned; | ||
| 236 | +} | ||
| 237 | + | ||
| 238 | +uint64_t AdaptiveSlidingWindowMXBasicAPITiling::GetHalfKFallbackScaleKL1(uint64_t kL1) const | ||
| 239 | +{ | ||
| 240 | + uint64_t scaleKL1 = tilingData_.matmulTiling.scaleKL1; | ||
| 241 | + if (scaleKL1 % qmmv3_tiling_const::ESTIMATED_SCALE_K == 0UL) { | ||
| 242 | + return scaleKL1; | ||
| 243 | + } | ||
| 244 | + // If scaleKL1 is between half-K and full-K, shrink it toward half-K to free L1 for four-buffer, | ||
| 245 | + // while keeping scaleFactor an integer multiple of kL1. | ||
| 246 | + uint64_t halfK = ops::CeilDiv(inputParams_.kSize, 2UL); | ||
本策略太过定制,有无更泛化的策略? ![]() ![]() | |||
| 247 | + if (scaleKL1 > halfK && scaleKL1 < inputParams_.kSize) { | ||
| 248 | + uint64_t adjustedScaleKL1 = ops::CeilAlign(halfK, kL1); | ||
| 249 | + scaleKL1 = adjustedScaleKL1 < scaleKL1 ? adjustedScaleKL1 : scaleKL1; | ||
| 250 | + } | ||
| 251 | + return scaleKL1; | ||
| 252 | +} | ||
| 253 | + | ||
| 254 | +uint64_t AdaptiveSlidingWindowMXBasicAPITiling::GetFullCoverScaleKL1IfPossible( | ||
| 255 | + uint64_t kL1, uint64_t scaleKL1) const | ||
| 256 | +{ | ||
| 257 | + uint64_t fullCoverScaleKL1 = ops::CeilAlign(inputParams_.kSize, kL1); | ||
| 258 | + if (fullCoverScaleKL1 <= scaleKL1) { | ||
| 259 | + return scaleKL1; | ||
| 260 | + } | ||
| 261 | + uint64_t usedL1Size = CalcFourBufferUsedL1Size4MX( | ||
| 262 | + kL1, fullCoverScaleKL1, tilingData_.matmulTiling.baseM, tilingData_.matmulTiling.baseN, isAFullLoad_); | ||
| 263 | + return usedL1Size <= aicoreParams_.l1Size ? fullCoverScaleKL1 : scaleKL1; | ||
| 264 | +} | ||
| 265 | + | ||
| 266 | +uint64_t AdaptiveSlidingWindowMXBasicAPITiling::CalcMxFullKLoadSize( | ||
| 267 | + uint64_t outerSize, ge::DataType dataDtype, ge::DataType scaleDtype) const | ||
| 268 | +{ | ||
| 269 | + uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE); | ||
| 270 | + uint64_t scaleK = ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE) * | ||
| 271 | + qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE; | ||
| 272 | + return GetSizeWithDataType(outerSize * kAligned, dataDtype) + | ||
| 273 | + GetSizeWithDataType(outerSize * scaleK, scaleDtype); | ||
| 274 | +} | ||
| 275 | + | ||
| 276 | +uint64_t AdaptiveSlidingWindowMXBasicAPITiling::CalcFourBufferUsedL1Size4MX( | ||
| 277 | + uint64_t kL1, uint64_t scaleKL1, uint64_t baseM, uint64_t baseN, bool isAFullLoad) const | ||
| 278 | +{ | ||
| 279 | + uint64_t usedL1Size = GetSizeWithDataType(baseN * kL1, inputParams_.bDtype) * qmmv3_tiling_const::L1_FOUR_BUFFER; | ||
| 280 | + // B-side MX scale follows the scaleKL1 window and is double-buffered separately from B data. | ||
| 189 | usedL1Size += | 281 | usedL1Size += |
| 190 | - GetSizeWithDataType( | 282 | + GetSizeWithDataType(baseN * ops::CeilDiv(scaleKL1, qmmv3_tiling_const::MX_GROUP_SIZE), inputParams_.scaleDtype) * |
| 191 | - basicTiling_.baseN * ops::CeilDiv(static_cast<uint64_t>(tilingData_.matmulTiling.scaleKL1), MX_GROUP_SIZE), | 283 | + qmmv3_tiling_const::L1_TWO_BUFFER; |
| 192 | - inputParams_.scaleDtype) * | ||
| 193 | - L1_TWO_BUFFER; | ||
| 194 | if (inputParams_.hasBias) { | 284 | if (inputParams_.hasBias) { |
| 195 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseN, inputParams_.biasDtype) * L1_TWO_BUFFER; | 285 | + usedL1Size += GetSizeWithDataType(baseN, inputParams_.biasDtype) * qmmv3_tiling_const::L1_TWO_BUFFER; |
| 196 | } | 286 | } |
| 197 | - if (isAFullLoad_) { | 287 | + if (isAFullLoad) { |
| 198 | - uint64_t scaleK = ops::CeilDiv(inputParams_.kSize, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; | 288 | + usedL1Size += CalcMxFullKLoadSize(baseM, inputParams_.aDtype, inputParams_.perTokenScaleDtype); |
| 199 | - uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, MXFP_DIVISOR_SIZE); | ||
| 200 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kAligned, inputParams_.aDtype) + | ||
| 201 | - GetSizeWithDataType(basicTiling_.baseM * scaleK, inputParams_.perTokenScaleDtype); | ||
| 202 | } else { | 289 | } else { |
| 203 | - usedL1Size += GetSizeWithDataType(basicTiling_.baseM * kL1, inputParams_.aDtype) * L1_FOUR_BUFFER; | 290 | + usedL1Size += GetSizeWithDataType(baseM * kL1, inputParams_.aDtype) * qmmv3_tiling_const::L1_FOUR_BUFFER; |
| 204 | usedL1Size += GetSizeWithDataType( | 291 | usedL1Size += GetSizeWithDataType( |
| 205 | - basicTiling_.baseM * | 292 | + baseM * ops::CeilDiv(scaleKL1, qmmv3_tiling_const::MX_GROUP_SIZE), inputParams_.perTokenScaleDtype) * |
| 206 | - ops::CeilDiv(static_cast<uint64_t>(tilingData_.matmulTiling.scaleKL1), MX_GROUP_SIZE), | 293 | + qmmv3_tiling_const::L1_TWO_BUFFER; |
| 207 | - inputParams_.perTokenScaleDtype) * | ||
| 208 | - L1_TWO_BUFFER; | ||
| 209 | } | 294 | } |
| 210 | - tilingData_.matmulTiling.nBufferNum = usedL1Size < aicoreParams_.l1Size ? L1_FOUR_BUFFER : L1_TWO_BUFFER; | 295 | + return usedL1Size; |
| 296 | +} | ||
| 297 | + | ||
| 298 | +bool AdaptiveSlidingWindowMXBasicAPITiling::CanOpenFourBufferByL1Estimate( | ||
| 299 | + bool isAFullLoad, uint64_t baseM, uint64_t baseN) const | ||
| 300 | +{ | ||
| 301 | + if (!isAFullLoad) { | ||
| 302 | + const bool isAInnerKAligned = inputParams_.transA || | ||
| 303 | + GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype) % | ||
| 304 | + qmmv3_tiling_const::MTE2_ADDRESS_ALIGN_SIZE == 0UL; | ||
| 305 | + const bool isBInnerKAligned = !inputParams_.transB || | ||
| 306 | + GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype) % | ||
| 307 | + qmmv3_tiling_const::MTE2_ADDRESS_ALIGN_SIZE == 0UL; | ||
| 308 | + // Use max stepK=4 for a conservative two-buffer K-coverage estimate. | ||
| 309 | + const bool isEstimatedTwoBufferNotOverK = | ||
| 310 | + 4UL * adaptiveWin_.baseK * qmmv3_tiling_const::L1_TWO_BUFFER < | ||
| 311 | + inputParams_.kSize; | ||
| 312 | + if (!isEstimatedTwoBufferNotOverK || !isAInnerKAligned || !isBInnerKAligned) { | ||
| 313 | + return false; | ||
| 314 | + } | ||
| 315 | + } | ||
| 316 | + // This runs before final L1 tiling. Estimate with stepK=2 and capped scaleKL1 to decide whether | ||
| 317 | + // isAFullLoad_ still leaves room for four-buffer. | ||
| 318 | + uint64_t estimatedKL1 = static_cast<uint64_t>(STEP_K_TWO) * adaptiveWin_.baseK; | ||
| 319 | + uint64_t estimatedScaleKL1 = | ||
| 320 | + ops::CeilAlign(std::min(inputParams_.kSize, qmmv3_tiling_const::ESTIMATED_SCALE_K), estimatedKL1); | ||
| 321 | + uint64_t usedL1Size = | ||
| 322 | + CalcFourBufferUsedL1Size4MX(estimatedKL1, estimatedScaleKL1, baseM, baseN, isAFullLoad); | ||
| 323 | + return usedL1Size <= aicoreParams_.l1Size; | ||
| 324 | +} | ||
| 325 | + | ||
| 326 | +bool AdaptiveSlidingWindowMXBasicAPITiling::ShouldKeepAFullLoadByRepeatLoadRatio() const | ||
| 327 | +{ | ||
| 328 | + if (adaptiveWin_.nBlockCnt <= 1UL || adaptiveWin_.mBlockCnt == 0UL) { | ||
| 329 | + return false; | ||
| 330 | + } | ||
| 331 | + double singleRoundABytes = static_cast<double>( | ||
| 332 | + CalcMxFullKLoadSize(inputParams_.mSize, inputParams_.aDtype, inputParams_.perTokenScaleDtype)); | ||
| 333 | + double repeatABytes = singleRoundABytes * static_cast<double>(adaptiveWin_.nBlockCnt - 1UL); | ||
| 334 | + double nonFullLoadABytes = singleRoundABytes * static_cast<double>(adaptiveWin_.nBlockCnt); | ||
| 335 | + double nonFullLoadBBytes = | ||
| 336 | + static_cast<double>(CalcMxFullKLoadSize( | ||
| 337 | + inputParams_.nSize, inputParams_.bDtype, inputParams_.scaleDtype)) * | ||
| 338 | + static_cast<double>(adaptiveWin_.mBlockCnt); | ||
| 339 | + double totalLoadBytes = nonFullLoadABytes + nonFullLoadBBytes; | ||
| 340 | + if (totalLoadBytes <= 0.0) { | ||
| 341 | + return false; | ||
| 342 | + } | ||
| 343 | + return repeatABytes / totalLoadBytes > REPEAT_A_LOAD_RATIO_THRESHOLD; | ||
| 211 | } | 344 | } |
| 212 | 345 | ||
| 213 | void AdaptiveSlidingWindowMXBasicAPITiling::UpdateAFullLoadStatus() | 346 | void AdaptiveSlidingWindowMXBasicAPITiling::UpdateAFullLoadStatus() |
| 214 | { | 347 | { |
| 215 | uint64_t realBaseMSize = adaptiveWin_.mBaseTailSplitCnt == 1UL ? adaptiveWin_.baseM : adaptiveWin_.mTailMain; | 348 | uint64_t realBaseMSize = adaptiveWin_.mBaseTailSplitCnt == 1UL ? adaptiveWin_.baseM : adaptiveWin_.mTailMain; |
| 216 | - uint64_t singleCoreASize = GetSizeWithDataType(realBaseMSize * inputParams_.kSize, inputParams_.aDtype); | 349 | + uint64_t kAligned = ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE); |
| 217 | - isAFullLoad_ = singleCoreASize <= aicoreParams_.l1Size / AFULLLOAD_SINGLE_CORE_A_SCALER && | 350 | + uint64_t singleCoreASize = GetSizeWithDataType(realBaseMSize * kAligned, inputParams_.aDtype); |
| 218 | - adaptiveWin_.mBlockCnt < WINDOW_LEN && aicoreParams_.aicNum % adaptiveWin_.mBlockCnt == 0 && | 351 | + bool isAFullLoadCandidate = singleCoreASize <= aicoreParams_.l1Size / qmmv3_tiling_const::AFULLLOAD_SINGLE_CORE_A_SCALER && |
| 219 | - adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; | 352 | + adaptiveWin_.mBlockCnt < qmmv3_tiling_const::WINDOW_LEN && |
| 353 | + aicoreParams_.aicNum % adaptiveWin_.mBlockCnt == 0 && | ||
| 354 | + adaptiveWin_.totalBlockCnt > aicoreParams_.aicNum && inputParams_.batchC == 1; | ||
| 355 | + isAFullLoad_ = false; | ||
| 356 | + if (!isAFullLoadCandidate) { | ||
| 357 | + return; | ||
| 358 | + } | ||
| 359 | + // Prefer A full-load when it still leaves enough L1 to enable four-buffer. | ||
| 360 | + if (CanOpenFourBufferByL1Estimate(true, realBaseMSize, adaptiveWin_.baseN)) { | ||
| 361 | + isAFullLoad_ = true; | ||
| 362 | + } else if (CanOpenFourBufferByL1Estimate(false, adaptiveWin_.baseM, adaptiveWin_.baseN) && | ||
| 363 | + !ShouldKeepAFullLoadByRepeatLoadRatio()) { | ||
| 364 | + // Keep A full-load disabled only when repeated A load is a small part of non-full-load GM traffic. | ||
| 365 | + return; | ||
| 366 | + } else { | ||
| 367 | + isAFullLoad_ = true; | ||
| 368 | + } | ||
| 220 | if (isAFullLoad_ && adaptiveWin_.baseM != realBaseMSize) { | 369 | if (isAFullLoad_ && adaptiveWin_.baseM != realBaseMSize) { |
| 221 | adaptiveWin_.baseM = realBaseMSize; | 370 | adaptiveWin_.baseM = realBaseMSize; |
| 222 | adaptiveWin_.mBaseTailSplitCnt = 1UL; | 371 | adaptiveWin_.mBaseTailSplitCnt = 1UL; |
| @@ -241,6 +390,41 @@ void AdaptiveSlidingWindowMXBasicAPITiling::CalcTailRoundBasicBlockSplit() | |||
| 241 | } else { | 390 | } else { |
| 242 | CalcTailBasicBlock(); | 391 | CalcTailBasicBlock(); |
| 243 | } | 392 | } |
| 393 | + NormalizeSingleRoundTailSplitBasicBlock(); | ||
| 394 | +} | ||
| 395 | + | ||
| 396 | +void AdaptiveSlidingWindowMXBasicAPITiling::NormalizeSingleRoundTailSplitBasicBlock() | ||
| 397 | +{ | ||
| 398 | + // Only single-window tail-split cases are normalized here; MX A-L1 full-load has totalWinCnt > 1. | ||
| 399 | + if (adaptiveWin_.totalWinCnt != 1UL || adaptiveWin_.tailWinBlockCnt == 0UL || | ||
| 400 | + (adaptiveWin_.mTailTile == 1UL && adaptiveWin_.nTailTile == 1UL)) { | ||
| 401 | + return; | ||
| 402 | + } | ||
| 403 | + | ||
| 404 | + const uint64_t baseMAlignSize = | ||
| 405 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; | ||
| 406 | + const uint64_t baseNAlignSize = | ||
| 407 | + inputParams_.transB ? qmmv3_tiling_const::CUBE_BLOCK : GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.bDtype); | ||
| 408 | + const uint64_t newBaseM = | ||
| 409 | + GetSingleRoundTailSplitBase(inputParams_.mSize, adaptiveWin_.baseM, adaptiveWin_.mTailTile, baseMAlignSize); | ||
| 410 | + const uint64_t newBaseN = | ||
| 411 | + GetSingleRoundTailSplitBase(inputParams_.nSize, adaptiveWin_.baseN, adaptiveWin_.nTailTile, baseNAlignSize); | ||
| 412 | + if (newBaseM == 0UL || newBaseN == 0UL || newBaseM > adaptiveWin_.baseM || newBaseN > adaptiveWin_.baseN) { | ||
| 413 | + return; | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + const bool isBaseUpdated = newBaseM != adaptiveWin_.baseM || newBaseN != adaptiveWin_.baseN; | ||
| 417 | + if (!isBaseUpdated) { | ||
| 418 | + return; | ||
| 419 | + } | ||
| 420 | + adaptiveWin_.baseM = newBaseM; | ||
| 421 | + adaptiveWin_.baseN = newBaseN; | ||
| 422 | + adaptiveWin_.mTailTile = 1UL; | ||
| 423 | + adaptiveWin_.nTailTile = 1UL; | ||
| 424 | + LoadBalanceDataReset(); | ||
| 425 | + // baseM/baseN changed from a split tile into a real base block; recompute window counters before edge tuning. | ||
| 426 | + CalcBlockWindowInfo(); | ||
| 427 | + OptimizeEdgeBasicBlock(); | ||
| 244 | } | 428 | } |
| 245 | 429 | ||
| 246 | void AdaptiveSlidingWindowMXBasicAPITiling::SetTilingData() | 430 | void AdaptiveSlidingWindowMXBasicAPITiling::SetTilingData() |
Mmatmul/quant_batch_matmul_v3/op_host/op_tiling/arch35/adaptive_sliding_window_mx_basic_api_tiling.h+9-0
| @@ -31,9 +31,18 @@ public: | |||
| 31 | private: | 31 | private: |
| 32 | void Reset(); | 32 | void Reset(); |
| 33 | void CalculateNBufferNum4MX(); | 33 | void CalculateNBufferNum4MX(); |
| 34 | + uint64_t GetHalfKFallbackScaleKL1(uint64_t kL1) const; | ||
| 35 | + uint64_t GetFullCoverScaleKL1IfPossible(uint64_t kL1, uint64_t scaleKL1) const; | ||
| 36 | + bool CanReduceStepKToTwo(uint32_t stepK, uint64_t stepKTwoKL1) const; | ||
| 37 | + uint64_t CalcFourBufferUsedL1Size4MX( | ||
| 38 | + uint64_t kL1, uint64_t scaleKL1, uint64_t baseM, uint64_t baseN, bool isAFullLoad) const; | ||
| 39 | + uint64_t CalcMxFullKLoadSize(uint64_t outerSize, ge::DataType dataDtype, ge::DataType scaleDtype) const; | ||
| 40 | + bool ShouldKeepAFullLoadByRepeatLoadRatio() const; | ||
| 34 | void UpdateAFullLoadStatus(); | 41 | void UpdateAFullLoadStatus(); |
| 42 | + bool CanOpenFourBufferByL1Estimate(bool isAFullLoad, uint64_t baseM, uint64_t baseN) const; | ||
| 35 | bool IsWithoutBatchTilingData() const; | 43 | bool IsWithoutBatchTilingData() const; |
| 36 | void SetWithoutBatchTilingData(); | 44 | void SetWithoutBatchTilingData(); |
| 45 | + void NormalizeSingleRoundTailSplitBasicBlock(); | ||
| 37 | 46 | ||
| 38 | protected: | 47 | protected: |
| 39 | bool IsCapable() override; | 48 | bool IsCapable() override; |
| @@ -23,12 +23,6 @@ | |||
| 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" | 23 | #include "quant_batch_matmul_v3_tiling_strategy.h" |
| 24 | 24 | ||
| 25 | namespace { | 25 | namespace { |
| 26 | -constexpr uint32_t DB_SIZE = 2; | ||
| 27 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 28 | -constexpr uint32_t CORE_RATIO = 2U; | ||
| 29 | - | ||
| 30 | -constexpr uint8_t L1_TWO_BUFFER = 2; | ||
| 31 | -constexpr uint8_t L1_FOUR_BUFFER = 4; | ||
| 32 | 26 | ||
| 33 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; | 27 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_3510)}; |
| 34 | constexpr int32_t TILING_PRIORITY = optiling::strategy::PERBLOCK_BASIC_API_ASW; | 28 | constexpr int32_t TILING_PRIORITY = optiling::strategy::PERBLOCK_BASIC_API_ASW; |
| @@ -67,7 +61,7 @@ bool AdaptiveSlidingWindowPerblockBasicAPITiling::IsCapable() | |||
| 67 | 61 | ||
| 68 | bool AdaptiveSlidingWindowPerblockBasicAPITiling::CheckCoreNum() const | 62 | bool AdaptiveSlidingWindowPerblockBasicAPITiling::CheckCoreNum() const |
| 69 | { | 63 | { |
| 70 | - if (compileInfo_.aivNum != CORE_RATIO * compileInfo_.aicNum) { | 64 | + if (compileInfo_.aivNum != qmmv3_tiling_const::CORE_RATIO * compileInfo_.aicNum) { |
| 71 | OP_LOGE( | 65 | OP_LOGE( |
| 72 | inputParams_.opName, "For perblock template, aicNum:aivNum should be 1:2, actual aicNum: %u, aivNum: %u.", | 66 | inputParams_.opName, "For perblock template, aicNum:aivNum should be 1:2, actual aicNum: %u, aivNum: %u.", |
| 73 | compileInfo_.aicNum, compileInfo_.aivNum); | 67 | compileInfo_.aicNum, compileInfo_.aivNum); |
| @@ -120,9 +114,9 @@ bool AdaptiveSlidingWindowPerblockBasicAPITiling::CalL1Tiling() | |||
| 120 | 114 | ||
| 121 | basicTiling_.iterateOrder = 0U; | 115 | basicTiling_.iterateOrder = 0U; |
| 122 | basicTiling_.dbL0c = | 116 | basicTiling_.dbL0c = |
| 123 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize) && | 117 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize) && |
| 124 | - CheckBiasAndScale(basicTiling_.baseN, DB_SIZE)) ? | 118 | + CheckBiasAndScale(basicTiling_.baseN, qmmv3_tiling_const::DOUBLE_BUFFER_NUM)) ? |
| 125 | - DB_SIZE : | 119 | + qmmv3_tiling_const::DOUBLE_BUFFER_NUM : |
| 126 | 1U; | 120 | 1U; |
| 127 | 121 | ||
| 128 | L1TilingDataCalculator l1Calculator( | 122 | L1TilingDataCalculator l1Calculator( |
| @@ -171,12 +165,12 @@ void AdaptiveSlidingWindowPerblockBasicAPITiling::CalculateNBufferNum4Perblock() | |||
| 171 | tilingData_.matmulTiling.stepKb = basicTiling_.stepKb; | 165 | tilingData_.matmulTiling.stepKb = basicTiling_.stepKb; |
| 172 | uint64_t kAL1 = tilingData_.matmulTiling.stepKa * tilingData_.matmulTiling.baseK; | 166 | uint64_t kAL1 = tilingData_.matmulTiling.stepKa * tilingData_.matmulTiling.baseK; |
| 173 | uint64_t fourBufUsedL1Size = | 167 | uint64_t fourBufUsedL1Size = |
| 174 | - GetSizeWithDataType((basicTiling_.baseM + basicTiling_.baseN) * kAL1, inputParams_.aDtype) * L1_FOUR_BUFFER; | 168 | + GetSizeWithDataType((basicTiling_.baseM + basicTiling_.baseN) * kAL1, inputParams_.aDtype) * qmmv3_tiling_const::L1_FOUR_BUFFER; |
| 175 | if (tilingData_.matmulTiling.stepKa == tilingData_.matmulTiling.stepKb && | 169 | if (tilingData_.matmulTiling.stepKa == tilingData_.matmulTiling.stepKb && |
| 176 | - fourBufUsedL1Size <= aicoreParams_.l1Size && kAL1 * L1_TWO_BUFFER < inputParams_.kSize) { | 170 | + fourBufUsedL1Size <= aicoreParams_.l1Size && kAL1 * qmmv3_tiling_const::L1_TWO_BUFFER < inputParams_.kSize) { |
| 177 | - tilingData_.matmulTiling.nBufferNum = L1_FOUR_BUFFER; | 171 | + tilingData_.matmulTiling.nBufferNum = qmmv3_tiling_const::L1_FOUR_BUFFER; |
| 178 | } else { | 172 | } else { |
| 179 | - tilingData_.matmulTiling.nBufferNum = L1_TWO_BUFFER; | 173 | + tilingData_.matmulTiling.nBufferNum = qmmv3_tiling_const::L1_TWO_BUFFER; |
| 180 | } | 174 | } |
| 181 | } | 175 | } |
| 182 | 176 | ||
| @@ -24,23 +24,13 @@ | |||
| 24 | using Ops::NN::MathUtil; | 24 | using Ops::NN::MathUtil; |
| 25 | using namespace QuantBatchMatmulV3Arch35TilingKey; | 25 | using namespace QuantBatchMatmulV3Arch35TilingKey; |
| 26 | namespace { | 26 | namespace { |
| 27 | -constexpr uint64_t CUBE_BLOCK = 16; | ||
| 28 | -constexpr uint64_t L1_ALIGN_SIZE = 32; | ||
| 29 | -constexpr uint64_t MX_GROUP_SIZE = 32; | ||
| 30 | -constexpr uint64_t MXFP_MULTI_BASE_SIZE = 2; | ||
| 31 | -constexpr uint32_t DOUBLE_BUFFER_NUM = 2; | ||
| 32 | 27 | ||
| 33 | -constexpr uint64_t BASIC_BLOCK_SIZE_256 = 256UL; | 28 | +constexpr uint64_t BASIC_BLOCK_SIZE_16 = 16; |
| 34 | constexpr uint64_t BASIC_BLOCK_SIZE_512 = 512UL; | 29 | constexpr uint64_t BASIC_BLOCK_SIZE_512 = 512UL; |
| 35 | constexpr uint64_t BASIC_BLOCK_SIZE_1024 = 1024UL; | 30 | constexpr uint64_t BASIC_BLOCK_SIZE_1024 = 1024UL; |
| 36 | -constexpr uint64_t BASIC_BLOCK_SIZE_32 = 32UL; | ||
| 37 | -constexpr uint64_t BASIC_BLOCK_SIZE_16 = 16; | ||
| 38 | 31 | ||
| 39 | constexpr uint32_t UB_ALIGN_SIZE = 32; | 32 | constexpr uint32_t UB_ALIGN_SIZE = 32; |
| 40 | -constexpr uint64_t L2_ALIGN_SIZE = 128; | ||
| 41 | 33 | ||
| 42 | -constexpr uint32_t SCALER_FACTOR_MAX = 127; | ||
| 43 | -constexpr uint32_t SCALER_FACTOR_MIN = 1; | ||
| 44 | constexpr uint32_t SCALER_FACTOR_DEFAULT = 1; | 34 | constexpr uint32_t SCALER_FACTOR_DEFAULT = 1; |
| 45 | constexpr uint32_t SCALER_FACTOR_B_BIT = 8; | 35 | constexpr uint32_t SCALER_FACTOR_B_BIT = 8; |
| 46 | constexpr uint32_t SCALER_FACTOR_M_BIT = 16; | 36 | constexpr uint32_t SCALER_FACTOR_M_BIT = 16; |
| @@ -48,27 +38,11 @@ constexpr uint32_t SCALER_FACTOR_N_BIT = 24; | |||
| 48 | 38 | ||
| 49 | constexpr uint32_t VEC_CORE_GROUP_NUM = 2; | 39 | constexpr uint32_t VEC_CORE_GROUP_NUM = 2; |
| 50 | 40 | ||
| 51 | -constexpr uint64_t WINDOW_LEN = 4; // Sliding-window length used by outer-axis tail merging. | ||
| 52 | -constexpr uint64_t MTE2_ADDRESS_ALIGN_SIZE = 128; // MTE2 address alignment size in bytes. | ||
| 53 | constexpr uint64_t LOAD_BALANCE_THRESHOLD = 1792; // Minimum M/N size to enable outer-axis load balancing. | 41 | constexpr uint64_t LOAD_BALANCE_THRESHOLD = 1792; // Minimum M/N size to enable outer-axis load balancing. |
| 54 | - | ||
| 55 | -struct AswPlatformInfoCache { | ||
| 56 | - bool valid = false; | ||
| 57 | - optiling::QuantBatchMatmulV3CompileInfo compileInfo = {}; | ||
| 58 | - Ops::NN::Optiling::AiCoreParams aiCoreParams = {}; | ||
| 59 | - uint32_t libApiWorkSpaceSize = 0U; | ||
| 60 | -}; | ||
| 61 | - | ||
| 62 | -thread_local AswPlatformInfoCache g_aswPlatformInfoCache; | ||
| 63 | } // namespace | 42 | } // namespace |
| 64 | 43 | ||
| 65 | namespace optiling { | 44 | namespace optiling { |
| 66 | 45 | ||
| 67 | -void ResetAdaptiveSlidingWindowPlatformInfoCache() | ||
| 68 | -{ | ||
| 69 | - g_aswPlatformInfoCache.valid = false; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | AdaptiveSlidingWindowTiling::AdaptiveSlidingWindowTiling(gert::TilingContext* context) | 46 | AdaptiveSlidingWindowTiling::AdaptiveSlidingWindowTiling(gert::TilingContext* context) |
| 73 | : QuantBatchMatmulV3TilingBase(context, false), tilingData_(tilingDataSelf_) | 47 | : QuantBatchMatmulV3TilingBase(context, false), tilingData_(tilingDataSelf_) |
| 74 | {} | 48 | {} |
| @@ -87,25 +61,6 @@ void AdaptiveSlidingWindowTiling::Reset() | |||
| 87 | } | 61 | } |
| 88 | } | 62 | } |
| 89 | 63 | ||
| 90 | -bool AdaptiveSlidingWindowTiling::SetPlatformInfoForTiling() | ||
| 91 | -{ | ||
| 92 | - if (inputParams_.initFlag && g_aswPlatformInfoCache.valid) { | ||
| 93 | - compileInfo_ = g_aswPlatformInfoCache.compileInfo; | ||
| 94 | - aicoreParams_ = g_aswPlatformInfoCache.aiCoreParams; | ||
| 95 | - inputParams_.libApiWorkSpaceSize = g_aswPlatformInfoCache.libApiWorkSpaceSize; | ||
| 96 | - compileInfoInit_ = true; | ||
| 97 | - return true; | ||
| 98 | - } | ||
| 99 | - if (!QuantBatchMatmulV3TilingBase::SetPlatformInfoForTiling()) { | ||
| 100 | - return false; | ||
| 101 | - } | ||
| 102 | - g_aswPlatformInfoCache.valid = true; | ||
| 103 | - g_aswPlatformInfoCache.compileInfo = compileInfo_; | ||
| 104 | - g_aswPlatformInfoCache.aiCoreParams = aicoreParams_; | ||
| 105 | - g_aswPlatformInfoCache.libApiWorkSpaceSize = inputParams_.libApiWorkSpaceSize; | ||
| 106 | - return true; | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | ge::graphStatus AdaptiveSlidingWindowTiling::GetShapeAttrsInfo() | 64 | ge::graphStatus AdaptiveSlidingWindowTiling::GetShapeAttrsInfo() |
| 110 | { | 65 | { |
| 111 | if (!inputParams_.initFlag && !isTilingOut_) { | 66 | if (!inputParams_.initFlag && !isTilingOut_) { |
| @@ -199,10 +154,7 @@ bool AdaptiveSlidingWindowTiling::AnalyseSlidingWinInfo() | |||
| 199 | CalcBlockWindowInfo(); | 154 | CalcBlockWindowInfo(); |
| 200 | 155 | ||
| 201 | LoadBalanceDataReset(); | 156 | LoadBalanceDataReset(); |
| 202 | - if (!OptimizeEdgeBasicBlock()) { | 157 | + OptimizeEdgeBasicBlock(); |
| 203 | - OP_LOGE(inputParams_.opName, "OptimizeEdgeBasicBlock failed."); | ||
| 204 | - return false; | ||
| 205 | - } | ||
| 206 | AnalyseFullLoadInfo(); | 158 | AnalyseFullLoadInfo(); |
| 207 | CalcTailRoundBasicBlockSplit(); | 159 | CalcTailRoundBasicBlockSplit(); |
| 208 | return true; | 160 | return true; |
| @@ -235,9 +187,9 @@ ge::graphStatus AdaptiveSlidingWindowTiling::DoLibApiTiling() | |||
| 235 | QuantBatchMatMulV3TilingUtil::SetBasicLibApiTiling(inputParams_, basicTiling_, tilingData_); | 187 | QuantBatchMatMulV3TilingUtil::SetBasicLibApiTiling(inputParams_, basicTiling_, tilingData_); |
| 236 | if (inputParams_.isMxPerGroup) { | 188 | if (inputParams_.isMxPerGroup) { |
| 237 | tilingData_.matmulTiling.mxTypePara = | 189 | tilingData_.matmulTiling.mxTypePara = |
| 238 | - (SCALER_FACTOR_MIN << SCALER_FACTOR_N_BIT) + (SCALER_FACTOR_MIN << SCALER_FACTOR_M_BIT); | 190 | + (qmmv3_tiling_const::SCALER_FACTOR_MIN << SCALER_FACTOR_N_BIT) + (qmmv3_tiling_const::SCALER_FACTOR_MIN << SCALER_FACTOR_M_BIT); |
| 239 | - if (basicTiling_.scaleFactorA >= SCALER_FACTOR_MIN && basicTiling_.scaleFactorA <= SCALER_FACTOR_MAX && | 191 | + if (basicTiling_.scaleFactorA >= qmmv3_tiling_const::SCALER_FACTOR_MIN && basicTiling_.scaleFactorA <= qmmv3_tiling_const::SCALER_FACTOR_MAX && |
| 240 | - basicTiling_.scaleFactorB >= SCALER_FACTOR_MIN && basicTiling_.scaleFactorB <= SCALER_FACTOR_MAX) { | 192 | + basicTiling_.scaleFactorB >= qmmv3_tiling_const::SCALER_FACTOR_MIN && basicTiling_.scaleFactorB <= qmmv3_tiling_const::SCALER_FACTOR_MAX) { |
| 241 | tilingData_.matmulTiling.mxTypePara += | 193 | tilingData_.matmulTiling.mxTypePara += |
| 242 | (basicTiling_.scaleFactorB << SCALER_FACTOR_B_BIT) + basicTiling_.scaleFactorA; | 194 | (basicTiling_.scaleFactorB << SCALER_FACTOR_B_BIT) + basicTiling_.scaleFactorA; |
| 243 | } else { | 195 | } else { |
| @@ -311,16 +263,16 @@ ge::graphStatus AdaptiveSlidingWindowTiling::CalcUbTiling() | |||
| 311 | // UB stores source int32, scale, per-token scale, and output, with double buffering for IO. | 263 | // UB stores source int32, scale, per-token scale, and output, with double buffering for IO. |
| 312 | // BF16 output is accounted for with int16-sized storage when estimating buffer usage. | 264 | // BF16 output is accounted for with int16-sized storage when estimating buffer usage. |
| 313 | uint64_t ubCalc = | 265 | uint64_t ubCalc = |
| 314 | - static_cast<uint64_t>(DOUBLE_BUFFER_NUM * (sizeof(int32_t) + ge::GetSizeByDataType(inputParams_.cDtype))) * | 266 | + static_cast<uint64_t>(qmmv3_tiling_const::DOUBLE_BUFFER_NUM * (sizeof(int32_t) + ge::GetSizeByDataType(inputParams_.cDtype))) * |
| 315 | static_cast<uint64_t>(basicTiling_.ubCalcN); | 267 | static_cast<uint64_t>(basicTiling_.ubCalcN); |
| 316 | // Reserve per-channel scale space when the quantization mode is not per-tensor. | 268 | // Reserve per-channel scale space when the quantization mode is not per-tensor. |
| 317 | if (!inputParams_.isPerTensor) { | 269 | if (!inputParams_.isPerTensor) { |
| 318 | ubSize -= ge::GetSizeByDataType(inputParams_.scaleDtype) * basicTiling_.ubCalcN; | 270 | ubSize -= ge::GetSizeByDataType(inputParams_.scaleDtype) * basicTiling_.ubCalcN; |
| 319 | } | 271 | } |
| 320 | // Reserve per-token scale space. | 272 | // Reserve per-token scale space. |
| 321 | - ubCalc += DOUBLE_BUFFER_NUM * ge::GetSizeByDataType(inputParams_.perTokenScaleDtype); | 273 | + ubCalc += qmmv3_tiling_const::DOUBLE_BUFFER_NUM * ge::GetSizeByDataType(inputParams_.perTokenScaleDtype); |
| 322 | // Keep the UB allocation 32-byte aligned. | 274 | // Keep the UB allocation 32-byte aligned. |
| 323 | - ubSize -= DOUBLE_BUFFER_NUM * (UB_ALIGN_SIZE - ge::GetSizeByDataType(inputParams_.perTokenScaleDtype)); | 275 | + ubSize -= qmmv3_tiling_const::DOUBLE_BUFFER_NUM * (UB_ALIGN_SIZE - ge::GetSizeByDataType(inputParams_.perTokenScaleDtype)); |
| 324 | basicTiling_.ubCalcM = static_cast<uint32_t>(ubSize / ubCalc); | 276 | basicTiling_.ubCalcM = static_cast<uint32_t>(ubSize / ubCalc); |
| 325 | basicTiling_.ubCalcM = std::min( | 277 | basicTiling_.ubCalcM = std::min( |
| 326 | std::min(basicTiling_.ubCalcM, ops::CeilDiv(basicTiling_.baseM, VEC_CORE_GROUP_NUM)), | 278 | std::min(basicTiling_.ubCalcM, ops::CeilDiv(basicTiling_.baseM, VEC_CORE_GROUP_NUM)), |
| @@ -365,7 +317,7 @@ void AdaptiveSlidingWindowTiling::SetBf16Compat() | |||
| 365 | bool AdaptiveSlidingWindowTiling::IsMxKOdd() const | 317 | bool AdaptiveSlidingWindowTiling::IsMxKOdd() const |
| 366 | { | 318 | { |
| 367 | return inputParams_.scaleDtype == ge::DT_FLOAT8_E8M0 && | 319 | return inputParams_.scaleDtype == ge::DT_FLOAT8_E8M0 && |
| 368 | - ops::CeilDiv(inputParams_.kSize, MX_GROUP_SIZE) % MXFP_MULTI_BASE_SIZE != 0; | 320 | + ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MX_GROUP_SIZE) % qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE != 0; |
| 369 | } | 321 | } |
| 370 | 322 | ||
| 371 | bool AdaptiveSlidingWindowTiling::IsMxBackwardTrans() const | 323 | bool AdaptiveSlidingWindowTiling::IsMxBackwardTrans() const |
| @@ -379,7 +331,7 @@ bool AdaptiveSlidingWindowTiling::CheckBiasAndScale(uint64_t baseN, uint64_t dbL | |||
| 379 | // UINT64/INT64 scale currently does not further limit baseN because libapi will tile a 512-wide scale. | 331 | // UINT64/INT64 scale currently does not further limit baseN because libapi will tile a 512-wide scale. |
| 380 | uint64_t maxBiasBaseN = dbL0c == 1UL ? BASIC_BLOCK_SIZE_1024 : BASIC_BLOCK_SIZE_512; | 332 | uint64_t maxBiasBaseN = dbL0c == 1UL ? BASIC_BLOCK_SIZE_1024 : BASIC_BLOCK_SIZE_512; |
| 381 | // FB uses a 2 KB tile here, and the remaining split is handled consistently with libapi/TBE tiling. | 333 | // FB uses a 2 KB tile here, and the remaining split is handled consistently with libapi/TBE tiling. |
| 382 | - uint64_t maxScaleBaseN = dbL0c == 1UL ? BASIC_BLOCK_SIZE_512 : BASIC_BLOCK_SIZE_256; | 334 | + uint64_t maxScaleBaseN = dbL0c == 1UL ? BASIC_BLOCK_SIZE_512 : qmmv3_tiling_const::BASIC_BLOCK_SIZE_256; |
| 383 | bool isBiasInvalid = inputParams_.hasBias && inputParams_.biasDtype != ge::DT_BF16 && baseN > maxBiasBaseN; | 335 | bool isBiasInvalid = inputParams_.hasBias && inputParams_.biasDtype != ge::DT_BF16 && baseN > maxBiasBaseN; |
| 384 | bool isUbQuant = inputParams_.cDtype == ge::DT_BF16 || inputParams_.isPertoken; | 336 | bool isUbQuant = inputParams_.cDtype == ge::DT_BF16 || inputParams_.isPertoken; |
| 385 | bool isScaleInvalid = !isUbQuant && baseN > maxScaleBaseN; | 337 | bool isScaleInvalid = !isUbQuant && baseN > maxScaleBaseN; |
| @@ -420,7 +372,7 @@ bool AdaptiveSlidingWindowTiling::IsInValidWeighNzTailSplit(uint64_t splitCnt, b | |||
| 420 | } | 372 | } |
| 421 | 373 | ||
| 422 | uint64_t tailN = adaptiveWin_.baseN / splitCnt; | 374 | uint64_t tailN = adaptiveWin_.baseN / splitCnt; |
| 423 | - return tailN % GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.bDtype) != 0UL; | 375 | + return tailN % GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.bDtype) != 0UL; |
| 424 | } | 376 | } |
| 425 | 377 | ||
| 426 | uint64_t AdaptiveSlidingWindowTiling::GetTailBasicBlockSplitMax( | 378 | uint64_t AdaptiveSlidingWindowTiling::GetTailBasicBlockSplitMax( |
| @@ -430,12 +382,12 @@ uint64_t AdaptiveSlidingWindowTiling::GetTailBasicBlockSplitMax( | |||
| 430 | (inputParams_.isPerBlock || | 382 | (inputParams_.isPerBlock || |
| 431 | (inputParams_.bFormat == ge::FORMAT_FRACTAL_NZ && inputParams_.transA && | 383 | (inputParams_.bFormat == ge::FORMAT_FRACTAL_NZ && inputParams_.transA && |
| 432 | adaptiveWin_.totalWinCnt == 1UL)) ? | 384 | adaptiveWin_.totalWinCnt == 1UL)) ? |
| 433 | - L2_ALIGN_SIZE : | 385 | + qmmv3_tiling_const::L2_ALIGN_SIZE : |
| 434 | - L1_ALIGN_SIZE; | 386 | + qmmv3_tiling_const::L1_ALIGN_SIZE; |
| 435 | - const uint64_t baseNAlignSize = inputParams_.isPerBlock ? L2_ALIGN_SIZE : L1_ALIGN_SIZE; | 387 | + const uint64_t baseNAlignSize = inputParams_.isPerBlock ? qmmv3_tiling_const::L2_ALIGN_SIZE : qmmv3_tiling_const::L1_ALIGN_SIZE; |
| 436 | const uint64_t splitAlignNum = | 388 | const uint64_t splitAlignNum = |
| 437 | - isMSplit ? (inputParams_.transA ? GetShapeWithDataType(baseMAlignSize, inputParams_.aDtype) : CUBE_BLOCK) : | 389 | + isMSplit ? (inputParams_.transA ? GetShapeWithDataType(baseMAlignSize, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK) : |
| 438 | - (!inputParams_.transB ? GetShapeWithDataType(baseNAlignSize, inputParams_.bDtype) : CUBE_BLOCK); | 390 | + (!inputParams_.transB ? GetShapeWithDataType(baseNAlignSize, inputParams_.bDtype) : qmmv3_tiling_const::CUBE_BLOCK); |
| 439 | return std::min(tileMax, MathUtil::CeilDivision(splitSize, splitAlignNum)); | 391 | return std::min(tileMax, MathUtil::CeilDivision(splitSize, splitAlignNum)); |
| 440 | } | 392 | } |
| 441 | 393 | ||
| @@ -456,6 +408,7 @@ uint64_t AdaptiveSlidingWindowTiling::GetTailSplitState( | |||
| 456 | const bool isMSplit = isPreSplit == isPreSplitM; | 408 | const bool isMSplit = isPreSplit == isPreSplitM; |
| 457 | const bool needWeightNzCheck = | 409 | const bool needWeightNzCheck = |
| 458 | !inputParams_.isPerBlock && inputParams_.bFormat == ge::FORMAT_FRACTAL_NZ && (isAFullLoad_ || !isMSplit); | 410 | !inputParams_.isPerBlock && inputParams_.bFormat == ge::FORMAT_FRACTAL_NZ && (isAFullLoad_ || !isMSplit); |
| 411 | + // 0: invalid split, 1: valid split, 2: valid and preferred-aligned split. | ||
| 459 | if (needWeightNzCheck && IsInValidWeighNzTailSplit(split, isPreSplit)) { | 412 | if (needWeightNzCheck && IsInValidWeighNzTailSplit(split, isPreSplit)) { |
| 460 | return 0UL; | 413 | return 0UL; |
| 461 | } | 414 | } |
| @@ -466,8 +419,8 @@ uint64_t AdaptiveSlidingWindowTiling::GetTailSplitState( | |||
| 466 | } | 419 | } |
| 467 | 420 | ||
| 468 | const uint64_t splitAlignNum = | 421 | const uint64_t splitAlignNum = |
| 469 | - isMSplit ? GetShapeWithDataType(BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : | 422 | + isMSplit ? GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : |
| 470 | - GetShapeWithDataType(BASIC_BLOCK_SIZE_32, inputParams_.bDtype); | 423 | + GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_32, inputParams_.bDtype); |
| 471 | return MathUtil::CeilDivision(splitSize, split) % splitAlignNum == 0UL ? 2UL : 1UL; | 424 | return MathUtil::CeilDivision(splitSize, split) % splitAlignNum == 0UL ? 2UL : 1UL; |
| 472 | } | 425 | } |
| 473 | 426 | ||
| @@ -485,6 +438,7 @@ void AdaptiveSlidingWindowTiling::CalcTailBasicBlockSplit( | |||
| 485 | CanIncreaseTailSplit(isPreSplitM, false, preSplit, secSplit, secSplitMax)) { | 438 | CanIncreaseTailSplit(isPreSplitM, false, preSplit, secSplit, secSplitMax)) { |
| 486 | if (CanIncreaseTailSplit(isPreSplitM, true, preSplit, secSplit, preSplitMax)) { | 439 | if (CanIncreaseTailSplit(isPreSplitM, true, preSplit, secSplit, preSplitMax)) { |
| 487 | ++preSplit; | 440 | ++preSplit; |
| 441 | + // 0: invalid split, 1: valid split, 2: valid and preferred-aligned split. | ||
| 488 | const uint64_t splitState = GetTailSplitState(isPreSplitM, true, preSplit, preSplitSize); | 442 | const uint64_t splitState = GetTailSplitState(isPreSplitM, true, preSplit, preSplitSize); |
| 489 | if (splitState > 0UL) { | 443 | if (splitState > 0UL) { |
| 490 | preSplitValid = preSplit; | 444 | preSplitValid = preSplit; |
| @@ -495,6 +449,7 @@ void AdaptiveSlidingWindowTiling::CalcTailBasicBlockSplit( | |||
| 495 | } | 449 | } |
| 496 | if (CanIncreaseTailSplit(isPreSplitM, false, preSplit, secSplit, secSplitMax)) { | 450 | if (CanIncreaseTailSplit(isPreSplitM, false, preSplit, secSplit, secSplitMax)) { |
| 497 | ++secSplit; | 451 | ++secSplit; |
| 452 | + // 0: invalid split, 1: valid split, 2: valid and preferred-aligned split. | ||
| 498 | const uint64_t splitState = GetTailSplitState(isPreSplitM, false, secSplit, secSplitSize); | 453 | const uint64_t splitState = GetTailSplitState(isPreSplitM, false, secSplit, secSplitSize); |
| 499 | if (splitState > 0UL) { | 454 | if (splitState > 0UL) { |
| 500 | secSplitValid = secSplit; | 455 | secSplitValid = secSplit; |
| @@ -554,7 +509,7 @@ void AdaptiveSlidingWindowTiling::CalcTailBasicBlockAfullLoad() | |||
| 554 | uint64_t nTileValid = 1UL; | 509 | uint64_t nTileValid = 1UL; |
| 555 | if (adaptiveWin_.tailWinBlockCnt != 0UL) { | 510 | if (adaptiveWin_.tailWinBlockCnt != 0UL) { |
| 556 | while (CalUsedCoreNum(adaptiveWin_.mTailTile, (nTile + 1UL)) <= aicoreParams_.aicNum && | 511 | while (CalUsedCoreNum(adaptiveWin_.mTailTile, (nTile + 1UL)) <= aicoreParams_.aicNum && |
| 557 | - adaptiveWin_.baseN / (nTile + 1UL) >= CUBE_BLOCK) { | 512 | + adaptiveWin_.baseN / (nTile + 1UL) >= qmmv3_tiling_const::CUBE_BLOCK) { |
| 558 | nTile += 1UL; | 513 | nTile += 1UL; |
| 559 | if (IsInValidWeighNzTailSplit(nTile, true)) { | 514 | if (IsInValidWeighNzTailSplit(nTile, true)) { |
| 560 | continue; | 515 | continue; |
| @@ -626,7 +581,7 @@ void AdaptiveSlidingWindowTiling::GetOuterMAxisTailCnt(uint64_t& baseTailSplitCn | |||
| 626 | uint64_t mTailSize = inputParams_.mSize % adaptiveWin_.baseM; | 581 | uint64_t mTailSize = inputParams_.mSize % adaptiveWin_.baseM; |
| 627 | uint64_t baseTailCntMax = std::min((adaptiveWin_.baseM - mTailSize) / BASIC_BLOCK_SIZE_16, | 582 | uint64_t baseTailCntMax = std::min((adaptiveWin_.baseM - mTailSize) / BASIC_BLOCK_SIZE_16, |
| 628 | adaptiveWin_.mBlockCnt); | 583 | adaptiveWin_.mBlockCnt); |
| 629 | - uint64_t windowSize = std::min(WINDOW_LEN, adaptiveWin_.mBlockCnt); | 584 | + uint64_t windowSize = std::min(qmmv3_tiling_const::WINDOW_LEN, adaptiveWin_.mBlockCnt); |
| 630 | uint64_t mainWindowNum = adaptiveWin_.mBlockCnt / windowSize - 1UL; | 585 | uint64_t mainWindowNum = adaptiveWin_.mBlockCnt / windowSize - 1UL; |
| 631 | uint64_t tailWindowSize = adaptiveWin_.mBlockCnt - mainWindowNum * windowSize; | 586 | uint64_t tailWindowSize = adaptiveWin_.mBlockCnt - mainWindowNum * windowSize; |
| 632 | uint64_t perfRes = (mainWindowNum + 1UL) * adaptiveWin_.baseM; | 587 | uint64_t perfRes = (mainWindowNum + 1UL) * adaptiveWin_.baseM; |
| @@ -688,7 +643,7 @@ void AdaptiveSlidingWindowTiling::GetOuterNAxisTailCnt(uint64_t& baseTailSplitCn | |||
| 688 | 643 | ||
| 689 | if (blockCnt <= aicoreParams_.aicNum || | 644 | if (blockCnt <= aicoreParams_.aicNum || |
| 690 | (adaptiveWin_.mBlockCnt % aicoreParams_.aicNum == 0UL && | 645 | (adaptiveWin_.mBlockCnt % aicoreParams_.aicNum == 0UL && |
| 691 | - (adaptiveWin_.nBlockCnt % WINDOW_LEN == 0UL || WINDOW_LEN % adaptiveWin_.nBlockCnt == 0UL))) { | 646 | + (adaptiveWin_.nBlockCnt % qmmv3_tiling_const::WINDOW_LEN == 0UL || qmmv3_tiling_const::WINDOW_LEN % adaptiveWin_.nBlockCnt == 0UL))) { |
| 692 | mainWindows = totalWindows; | 647 | mainWindows = totalWindows; |
| 693 | } | 648 | } |
| 694 | uint64_t tailWindows = totalWindows - mainWindows; | 649 | uint64_t tailWindows = totalWindows - mainWindows; |
| @@ -707,15 +662,15 @@ void AdaptiveSlidingWindowTiling::GetOuterNAxisTailCnt(uint64_t& baseTailSplitCn | |||
| 707 | } | 662 | } |
| 708 | } | 663 | } |
| 709 | 664 | ||
| 710 | -bool AdaptiveSlidingWindowTiling::OptimizeEdgeBasicBlock() | 665 | +void AdaptiveSlidingWindowTiling::OptimizeEdgeBasicBlock() |
| 711 | { | 666 | { |
| 712 | if (compileInfo_.supportMmadS8S4 || (inputParams_.transA && !inputParams_.transB) || | 667 | if (compileInfo_.supportMmadS8S4 || (inputParams_.transA && !inputParams_.transB) || |
| 713 | (inputParams_.isPerBlock && inputParams_.groupSizeM != 1UL)) { | 668 | (inputParams_.isPerBlock && inputParams_.groupSizeM != 1UL)) { |
| 714 | - return true; | 669 | + return; |
| 715 | } | 670 | } |
| 716 | 671 | ||
| 717 | if (adaptiveWin_.mBlockCnt == 1UL || adaptiveWin_.nBlockCnt == 1UL) { | 672 | if (adaptiveWin_.mBlockCnt == 1UL || adaptiveWin_.nBlockCnt == 1UL) { |
| 718 | - return true; | 673 | + return; |
| 719 | } | 674 | } |
| 720 | 675 | ||
| 721 | uint64_t mBaseTail = static_cast<uint64_t>(inputParams_.mSize % adaptiveWin_.baseM); | 676 | uint64_t mBaseTail = static_cast<uint64_t>(inputParams_.mSize % adaptiveWin_.baseM); |
| @@ -726,7 +681,8 @@ bool AdaptiveSlidingWindowTiling::OptimizeEdgeBasicBlock() | |||
| 726 | (inputParams_.kSize == BASIC_BLOCK_SIZE_1024 && | 681 | (inputParams_.kSize == BASIC_BLOCK_SIZE_1024 && |
| 727 | adaptiveWin_.nBlockCnt >= 8)); // With enough N tiles, imbalance impact is negligible. | 682 | adaptiveWin_.nBlockCnt >= 8)); // With enough N tiles, imbalance impact is negligible. |
| 728 | bool isInnerAxisAlign = | 683 | bool isInnerAxisAlign = |
| 729 | - GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype) % MTE2_ADDRESS_ALIGN_SIZE == 0UL; | 684 | + GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype) % |
| 685 | + qmmv3_tiling_const::MTE2_ADDRESS_ALIGN_SIZE == 0UL; | ||
| 730 | if (mBaseTail > 0UL && !inputParams_.transA && | 686 | if (mBaseTail > 0UL && !inputParams_.transA && |
| 731 | (isInnerAxisAlign || (inputParams_.mSize >= LOAD_BALANCE_THRESHOLD && !isMxfp4))) { | 687 | (isInnerAxisAlign || (inputParams_.mSize >= LOAD_BALANCE_THRESHOLD && !isMxfp4))) { |
| 732 | GetOuterMAxisTailCnt(adaptiveWin_.mBaseTailSplitCnt, adaptiveWin_.mTailMain); | 688 | GetOuterMAxisTailCnt(adaptiveWin_.mBaseTailSplitCnt, adaptiveWin_.mTailMain); |
| @@ -735,7 +691,7 @@ bool AdaptiveSlidingWindowTiling::OptimizeEdgeBasicBlock() | |||
| 735 | (isInnerAxisAlign || (inputParams_.nSize >= LOAD_BALANCE_THRESHOLD))) { | 691 | (isInnerAxisAlign || (inputParams_.nSize >= LOAD_BALANCE_THRESHOLD))) { |
| 736 | GetOuterNAxisTailCnt(adaptiveWin_.nBaseTailSplitCnt, adaptiveWin_.nTailMain); | 692 | GetOuterNAxisTailCnt(adaptiveWin_.nBaseTailSplitCnt, adaptiveWin_.nTailMain); |
| 737 | } | 693 | } |
| 738 | - return true; | 694 | + |
| 739 | } | 695 | } |
| 740 | 696 | ||
| 741 | } // namespace optiling | 697 | } // namespace optiling |
| @@ -21,8 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | 23 | ||
| 24 | -void ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 25 | - | ||
| 26 | struct AdaptiveSlidingWindow { | 24 | struct AdaptiveSlidingWindow { |
| 27 | uint64_t baseM = 0; // Base M block size for the main window. | 25 | uint64_t baseM = 0; // Base M block size for the main window. |
| 28 | uint64_t baseN = 0; // Base N block size for the main window. | 26 | uint64_t baseN = 0; // Base N block size for the main window. |
| @@ -74,7 +72,6 @@ protected: | |||
| 74 | virtual uint64_t GetBatchCoreCnt() const; | 72 | virtual uint64_t GetBatchCoreCnt() const; |
| 75 | virtual const void* GetTilingData() const; | 73 | virtual const void* GetTilingData() const; |
| 76 | bool CheckDtype() const override; | 74 | bool CheckDtype() const override; |
| 77 | - bool SetPlatformInfoForTiling() override; | ||
| 78 | bool CheckShape( | 75 | bool CheckShape( |
| 79 | const std::vector<gert::Shape*>& mandtoryShape, const gert::StorageShape* biasShape, | 76 | const std::vector<gert::Shape*>& mandtoryShape, const gert::StorageShape* biasShape, |
| 80 | const gert::StorageShape* pertokenShape, const std::vector<int64_t>& dimValueOfMKN) const override; | 77 | const gert::StorageShape* pertokenShape, const std::vector<int64_t>& dimValueOfMKN) const override; |
| @@ -109,7 +106,7 @@ protected: | |||
| 109 | bool IsInValidWeighNzTailSplit(uint64_t splitCnt, bool isPreSplit) const; | 106 | bool IsInValidWeighNzTailSplit(uint64_t splitCnt, bool isPreSplit) const; |
| 110 | 107 | ||
| 111 | void LoadBalanceDataReset(); | 108 | void LoadBalanceDataReset(); |
| 112 | - bool OptimizeEdgeBasicBlock(); | 109 | + void OptimizeEdgeBasicBlock(); |
| 113 | void CalculateCurrentPerf(uint64_t mergeLen, uint64_t nTail, uint64_t& newTailMain, uint64_t& curPerf); | 110 | void CalculateCurrentPerf(uint64_t mergeLen, uint64_t nTail, uint64_t& newTailMain, uint64_t& curPerf); |
| 114 | void GetOuterMAxisTailCnt(uint64_t& baseTailSplitCnt, uint64_t& tailMain); | 111 | void GetOuterMAxisTailCnt(uint64_t& baseTailSplitCnt, uint64_t& tailMain); |
| 115 | void GetOuterNAxisTailCnt(uint64_t& baseTailSplitCnt, uint64_t& tailMain); | 112 | void GetOuterNAxisTailCnt(uint64_t& baseTailSplitCnt, uint64_t& tailMain); |
| @@ -16,24 +16,20 @@ | |||
| 16 | 16 | ||
| 17 | #include <algorithm> | 17 | #include <algorithm> |
| 18 | #include "error_util.h" | 18 | #include "error_util.h" |
| 19 | +#include "quant_batch_matmul_v3_tiling_util.h" | ||
| 19 | #include "util/math_util.h" | 20 | #include "util/math_util.h" |
| 20 | 21 | ||
| 21 | namespace { | 22 | namespace { |
| 22 | -constexpr uint64_t CUBE_BLOCK = 16UL; | ||
| 23 | -constexpr uint64_t L1_ALIGN_SIZE = 32UL; | ||
| 24 | -constexpr uint64_t L2_ALIGN_SIZE = 128UL; | ||
| 25 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32UL; | ||
| 26 | -constexpr uint64_t MXFP_DIVISOR_SIZE = 64UL; | ||
| 27 | -constexpr uint64_t PER_BLOCK_SIZE = 128UL; | ||
| 28 | -constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 29 | -constexpr uint64_t BASIC_BLOCK_SIZE_256 = 256UL; | ||
| 30 | -constexpr uint64_t BASIC_BLOCK_SIZE_32 = 32UL; | ||
| 31 | constexpr uint64_t PER_BLOCK_BASE_SIZE_256 = 256UL; | 23 | constexpr uint64_t PER_BLOCK_BASE_SIZE_256 = 256UL; |
| 24 | +// If adjusted baseN loses 128B alignment and K is below this threshold, keep the original base block. | ||
| 25 | +constexpr uint64_t LOAD_BALANCE_BASE_N_128_ALIGN_K_THRESHOLD = 2560UL; | ||
| 26 | +// Rebalance M/N split when one base dimension is at least twice the other. | ||
| 32 | constexpr uint64_t BASEM_BASEN_RATIO = 2UL; | 27 | constexpr uint64_t BASEM_BASEN_RATIO = 2UL; |
| 28 | +// Oversized baseK candidates are halved above this supported tiling range. | ||
| 33 | constexpr uint64_t BASEK_LIMIT = 4095UL; | 29 | constexpr uint64_t BASEK_LIMIT = 4095UL; |
| 34 | -constexpr uint32_t DB_SIZE = 2U; | ||
| 35 | -constexpr uint32_t NUM_HALF = 2U; | ||
| 36 | constexpr uint32_t DOUBLE_CORE_NUM = 2U; | 30 | constexpr uint32_t DOUBLE_CORE_NUM = 2U; |
| 31 | +// Epsilon for comparing score ratios during base-block search. | ||
| 32 | +constexpr double SCORE_COMPARE_EPS = 1e-12; | ||
| 37 | 33 | ||
| 38 | uint64_t GetShapeWithDataType(uint64_t size, ge::DataType dtype) | 34 | uint64_t GetShapeWithDataType(uint64_t size, ge::DataType dtype) |
| 39 | { | 35 | { |
| @@ -43,6 +39,31 @@ uint64_t GetShapeWithDataType(uint64_t size, ge::DataType dtype) | |||
| 43 | uint64_t dtypeSize = static_cast<uint64_t>(ge::GetSizeByDataType(dtype)); | 39 | uint64_t dtypeSize = static_cast<uint64_t>(ge::GetSizeByDataType(dtype)); |
| 44 | return dtypeSize == 0UL ? 0UL : size / dtypeSize; | 40 | return dtypeSize == 0UL ? 0UL : size / dtypeSize; |
| 45 | } | 41 | } |
| 42 | + | ||
| 43 | +uint64_t GetNextLoadBalanceBase(uint64_t curBase, uint64_t baseAlign) | ||
| 44 | +{ | ||
| 45 | + if (curBase <= baseAlign) { | ||
| 46 | + return 0UL; | ||
| 47 | + } | ||
| 48 | + return curBase - baseAlign; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +bool IsScoreEqual(double lhs, double rhs) | ||
| 52 | +{ | ||
| 53 | + return lhs + SCORE_COMPARE_EPS >= rhs && rhs + SCORE_COMPARE_EPS >= lhs; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +double GetBaseShapeScore(uint64_t baseM, uint64_t baseN) | ||
| 57 | +{ | ||
| 58 | + // Smaller ratio means the M/N split is closer to square. | ||
| 59 | + return static_cast<double>(std::max(baseM, baseN)) / std::min(baseM, baseN); | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +double GetMemoryComputeScore(uint64_t baseM, uint64_t baseN) | ||
| 63 | +{ | ||
| 64 | + // This is (baseM + baseN) / (baseM * baseN); lower means smaller baseM + baseN for the same output area. | ||
| 65 | + return (static_cast<double>(baseM) + baseN) / (static_cast<double>(baseM) * baseN); | ||
| 66 | +} | ||
| 46 | } // namespace | 67 | } // namespace |
| 47 | 68 | ||
| 48 | namespace optiling { | 69 | namespace optiling { |
| @@ -72,10 +93,11 @@ bool BaseBlockCalculator::Compute(BaseBlockMode mode) | |||
| 72 | ComputeBaseBlockDefault(); | 93 | ComputeBaseBlockDefault(); |
| 73 | break; | 94 | break; |
| 74 | } | 95 | } |
| 75 | - if (!AdjustBaseBlock(mode)) { | 96 | + if (!OptimizeBaseBlockForCoreUtilization(mode)) { |
| 76 | OP_LOGE(inputParams_.opName, "Failed to adjust base block."); | 97 | OP_LOGE(inputParams_.opName, "Failed to adjust base block."); |
| 77 | return false; | 98 | return false; |
| 78 | } | 99 | } |
| 100 | + OptimizeBaseBlockForLoadBalance(); | ||
| 79 | return ValidateBaseBlock(); | 101 | return ValidateBaseBlock(); |
| 80 | } | 102 | } |
| 81 | 103 | ||
| @@ -121,65 +143,67 @@ bool BaseBlockCalculator::ValidateBaseBlock() const | |||
| 121 | 143 | ||
| 122 | void BaseBlockCalculator::ComputeBaseBlockDefault() | 144 | void BaseBlockCalculator::ComputeBaseBlockDefault() |
| 123 | { | 145 | { |
| 124 | - baseBlockRes_.baseM = ops::CeilAlign(std::min(inputParams_.mSize, BASIC_BLOCK_SIZE_256), GetBaseMAlignSize()); | 146 | + baseBlockRes_.baseM = ops::CeilAlign(std::min(inputParams_.mSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256), GetBaseMAlignSize()); |
| 125 | - baseBlockRes_.baseN = ops::CeilAlign(std::min(inputParams_.nSize, BASIC_BLOCK_SIZE_256), GetBaseNAlignSize()); | 147 | + baseBlockRes_.baseN = ops::CeilAlign(std::min(inputParams_.nSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256), GetBaseNAlignSize()); |
| 126 | 148 | ||
| 127 | - uint64_t baseKDefaultSize = GetShapeWithDataType(BASIC_BLOCK_SIZE_128, inputParams_.aDtype); | 149 | + uint64_t baseKDefaultSize = GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_128, inputParams_.aDtype); |
| 128 | baseBlockRes_.baseK = ops::CeilAlign(std::min(baseKDefaultSize, inputParams_.kSize), GetBaseKAlignSize()); | 150 | baseBlockRes_.baseK = ops::CeilAlign(std::min(baseKDefaultSize, inputParams_.kSize), GetBaseKAlignSize()); |
| 129 | } | 151 | } |
| 130 | 152 | ||
| 131 | void BaseBlockCalculator::ComputeBaseBlockPerblock() | 153 | void BaseBlockCalculator::ComputeBaseBlockPerblock() |
| 132 | { | 154 | { |
| 133 | - if (inputParams_.mSize <= PER_BLOCK_SIZE || inputParams_.mSize % PER_BLOCK_SIZE != 0UL) { | 155 | + if (inputParams_.mSize <= qmmv3_tiling_const::PER_BLOCK_SIZE || inputParams_.mSize % qmmv3_tiling_const::PER_BLOCK_SIZE != 0UL) { |
| 134 | - baseBlockRes_.baseM = inputParams_.groupSizeM == 1UL && inputParams_.mSize < PER_BLOCK_SIZE ? | 156 | + baseBlockRes_.baseM = inputParams_.groupSizeM == 1UL && inputParams_.mSize < qmmv3_tiling_const::PER_BLOCK_SIZE ? |
| 135 | ops::CeilAlign(inputParams_.mSize, GetBaseMAlignSize()) : | 157 | ops::CeilAlign(inputParams_.mSize, GetBaseMAlignSize()) : |
| 136 | - PER_BLOCK_SIZE; | 158 | + qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 137 | - baseBlockRes_.baseN = inputParams_.nSize % PER_BLOCK_SIZE == 0UL ? PER_BLOCK_BASE_SIZE_256 : PER_BLOCK_SIZE; | 159 | + baseBlockRes_.baseN = inputParams_.nSize % qmmv3_tiling_const::PER_BLOCK_SIZE == 0UL ? PER_BLOCK_BASE_SIZE_256 : qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 138 | } else { | 160 | } else { |
| 139 | baseBlockRes_.baseM = PER_BLOCK_BASE_SIZE_256; | 161 | baseBlockRes_.baseM = PER_BLOCK_BASE_SIZE_256; |
| 140 | - baseBlockRes_.baseN = PER_BLOCK_SIZE; | 162 | + baseBlockRes_.baseN = qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 141 | } | 163 | } |
| 142 | - baseBlockRes_.baseK = PER_BLOCK_SIZE; | 164 | + baseBlockRes_.baseK = qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 143 | } | 165 | } |
| 144 | 166 | ||
| 145 | void BaseBlockCalculator::ComputeBaseBlockMmadS8S4() | 167 | void BaseBlockCalculator::ComputeBaseBlockMmadS8S4() |
| 146 | { | 168 | { |
| 147 | - baseBlockRes_.baseM = ops::CeilAlign(std::min(inputParams_.mSize, BASIC_BLOCK_SIZE_256), GetBaseMAlignSize()); | 169 | + baseBlockRes_.baseM = ops::CeilAlign(std::min(inputParams_.mSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256), GetBaseMAlignSize()); |
| 148 | - baseBlockRes_.baseN = ops::CeilAlign(std::min(inputParams_.nSize, BASIC_BLOCK_SIZE_256), GetBaseNAlignSize()); | 170 | + baseBlockRes_.baseN = ops::CeilAlign(std::min(inputParams_.nSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256), GetBaseNAlignSize()); |
| 149 | 171 | ||
| 150 | - uint64_t basicBlockSizeA = BASIC_BLOCK_SIZE_128; | 172 | + uint64_t basicBlockSizeA = qmmv3_tiling_const::BASIC_BLOCK_SIZE_128; |
| 151 | - uint64_t basicBlockSizeB = BASIC_BLOCK_SIZE_128; | 173 | + uint64_t basicBlockSizeB = qmmv3_tiling_const::BASIC_BLOCK_SIZE_128; |
| 152 | - if (baseBlockRes_.baseM != 0UL && compileInfo_.l0aSize / DB_SIZE / baseBlockRes_.baseM >= BASIC_BLOCK_SIZE_256) { | 174 | + if (baseBlockRes_.baseM != 0UL && |
| 153 | - basicBlockSizeA = BASIC_BLOCK_SIZE_256; | 175 | + compileInfo_.l0aSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM / baseBlockRes_.baseM >= qmmv3_tiling_const::BASIC_BLOCK_SIZE_256) { |
| 176 | + basicBlockSizeA = qmmv3_tiling_const::BASIC_BLOCK_SIZE_256; | ||
| 154 | } | 177 | } |
| 155 | - if (baseBlockRes_.baseN != 0UL && compileInfo_.l0bSize / DB_SIZE / baseBlockRes_.baseN >= BASIC_BLOCK_SIZE_256) { | 178 | + if (baseBlockRes_.baseN != 0UL && |
| 156 | - basicBlockSizeB = BASIC_BLOCK_SIZE_256; | 179 | + compileInfo_.l0bSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM / baseBlockRes_.baseN >= qmmv3_tiling_const::BASIC_BLOCK_SIZE_256) { |
| 180 | + basicBlockSizeB = qmmv3_tiling_const::BASIC_BLOCK_SIZE_256; | ||
| 157 | } | 181 | } |
| 158 | uint64_t minBaseK = std::min( | 182 | uint64_t minBaseK = std::min( |
| 159 | std::min( | 183 | std::min( |
| 160 | GetShapeWithDataType(basicBlockSizeA, inputParams_.aDtype), | 184 | GetShapeWithDataType(basicBlockSizeA, inputParams_.aDtype), |
| 161 | GetShapeWithDataType(basicBlockSizeB, inputParams_.bDtype)), | 185 | GetShapeWithDataType(basicBlockSizeB, inputParams_.bDtype)), |
| 162 | inputParams_.kSize); | 186 | inputParams_.kSize); |
| 163 | - uint64_t maxAlignSize = std::max(GetBaseKAlignSize(), GetShapeWithDataType(CUBE_REDUCE_BLOCK, inputParams_.bDtype)); | 187 | + uint64_t maxAlignSize = std::max(GetBaseKAlignSize(), GetShapeWithDataType(qmmv3_tiling_const::CUBE_REDUCE_BLOCK, inputParams_.bDtype)); |
| 164 | baseBlockRes_.baseK = ops::CeilAlign(minBaseK, maxAlignSize); | 188 | baseBlockRes_.baseK = ops::CeilAlign(minBaseK, maxAlignSize); |
| 165 | } | 189 | } |
| 166 | 190 | ||
| 167 | uint64_t BaseBlockCalculator::GetBaseMAlignSize() const | 191 | uint64_t BaseBlockCalculator::GetBaseMAlignSize() const |
| 168 | { | 192 | { |
| 169 | - return inputParams_.transA ? GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.aDtype) : CUBE_BLOCK; | 193 | + return inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 170 | } | 194 | } |
| 171 | 195 | ||
| 172 | uint64_t BaseBlockCalculator::GetBaseNAlignSize() const | 196 | uint64_t BaseBlockCalculator::GetBaseNAlignSize() const |
| 173 | { | 197 | { |
| 174 | - return inputParams_.transB ? CUBE_BLOCK : GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.bDtype); | 198 | + return inputParams_.transB ? qmmv3_tiling_const::CUBE_BLOCK : GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.bDtype); |
| 175 | } | 199 | } |
| 176 | 200 | ||
| 177 | uint64_t BaseBlockCalculator::GetBaseKAlignSize() const | 201 | uint64_t BaseBlockCalculator::GetBaseKAlignSize() const |
| 178 | { | 202 | { |
| 179 | - return inputParams_.isMxPerGroup ? MXFP_DIVISOR_SIZE : GetShapeWithDataType(CUBE_REDUCE_BLOCK, inputParams_.aDtype); | 203 | + return inputParams_.isMxPerGroup ? qmmv3_tiling_const::MXFP_DIVISOR_SIZE : GetShapeWithDataType(qmmv3_tiling_const::CUBE_REDUCE_BLOCK, inputParams_.aDtype); |
| 180 | } | 204 | } |
| 181 | 205 | ||
| 182 | -bool BaseBlockCalculator::AdjustBaseBlock(BaseBlockMode mode) | 206 | +bool BaseBlockCalculator::OptimizeBaseBlockForCoreUtilization(BaseBlockMode mode) |
| 183 | { | 207 | { |
| 184 | uint64_t oriBlock = batchCoreCnt_ * ops::CeilDiv(inputParams_.mSize, baseBlockRes_.baseM) * | 208 | uint64_t oriBlock = batchCoreCnt_ * ops::CeilDiv(inputParams_.mSize, baseBlockRes_.baseM) * |
| 185 | ops::CeilDiv(inputParams_.nSize, baseBlockRes_.baseN); | 209 | ops::CeilDiv(inputParams_.nSize, baseBlockRes_.baseN); |
| @@ -197,17 +221,139 @@ bool BaseBlockCalculator::AdjustBaseBlock(BaseBlockMode mode) | |||
| 197 | } | 221 | } |
| 198 | } | 222 | } |
| 199 | 223 | ||
| 224 | +void BaseBlockCalculator::OptimizeBaseBlockForLoadBalance() | ||
| 225 | +{ | ||
| 226 | + if (!inputParams_.isMxPerGroup || compileInfo_.npuArch != NpuArch::DAV_3510) { | ||
| 227 | + return; | ||
| 228 | + } | ||
| 229 | + uint64_t roundLimit = GetSingleCoreMaxRound(baseBlockRes_.baseM, baseBlockRes_.baseN); | ||
| 230 | + // Rebalance only two- or three-round cases; keep the default block otherwise. | ||
| 231 | + if (roundLimit == 1UL || roundLimit > 3UL) { | ||
| 232 | + return; | ||
| 233 | + } | ||
| 234 | + uint64_t originLastRoundBlockCnt = GetLastRoundBlockCnt(baseBlockRes_.baseM, baseBlockRes_.baseN); | ||
| 235 | + if (originLastRoundBlockCnt == 0UL) { | ||
| 236 | + return; | ||
| 237 | + } | ||
| 238 | + const uint64_t originLastRoundUsedCore = | ||
| 239 | + originLastRoundBlockCnt * (static_cast<uint64_t>(compileInfo_.aicNum) / originLastRoundBlockCnt); | ||
| 240 | + const double originMemoryComputeScore = GetMemoryComputeScore(baseBlockRes_.baseM, baseBlockRes_.baseN); | ||
| 241 | + uint64_t bestBaseM = baseBlockRes_.baseM; | ||
| 242 | + uint64_t bestBaseN = baseBlockRes_.baseN; | ||
| 243 | + SearchLoadBalanceBaseBlock(roundLimit, originLastRoundUsedCore, originMemoryComputeScore, bestBaseM, bestBaseN); | ||
| 244 | + TryApplyLoadBalanceBase(bestBaseM, bestBaseN); | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +void BaseBlockCalculator::SearchLoadBalanceBaseBlock( | ||
| 248 | + uint64_t roundLimit, uint64_t originLastRoundUsedCore, double originMemoryComputeScore, | ||
| 249 | + uint64_t& bestBaseM, uint64_t& bestBaseN) const | ||
| 250 | +{ | ||
| 251 | + double balanceRate = 0.0; | ||
| 252 | + double memoryComputeScore = 0.0; | ||
| 253 | + uint64_t baseMAlignNum = | ||
| 254 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; | ||
| 255 | + uint64_t baseNAlignNum = | ||
| 256 | + inputParams_.transB ? qmmv3_tiling_const::CUBE_BLOCK : GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.bDtype); | ||
| 257 | + uint64_t searchBaseM = ops::CeilAlign(baseBlockRes_.baseM, baseMAlignNum); | ||
| 258 | + uint64_t searchBaseN = ops::CeilAlign(baseBlockRes_.baseN, baseNAlignNum); | ||
| 259 | + bool hasCandidate = false; | ||
| 260 | + for (uint64_t curBaseM = searchBaseM; curBaseM != 0UL; | ||
| 261 | + curBaseM = GetNextLoadBalanceBase(curBaseM, baseMAlignNum)) { | ||
| 262 | + for (uint64_t curBaseN = searchBaseN; curBaseN != 0UL; | ||
| 263 | + curBaseN = GetNextLoadBalanceBase(curBaseN, baseNAlignNum)) { | ||
| 264 | + uint64_t curRound = GetSingleCoreMaxRound(curBaseM, curBaseN); | ||
| 265 | + // Decreasing baseN only increases tile count in this loop, so later candidates will not recover. | ||
| 266 | + if (curRound > roundLimit) { | ||
| 267 | + break; | ||
| 268 | + } | ||
| 269 | + if (ShouldSkipLoadBalanceCandidate( | ||
| 270 | + curBaseM, curBaseN, originLastRoundUsedCore, originMemoryComputeScore)) { | ||
| 271 | + continue; | ||
| 272 | + } | ||
| 273 | + double curBalanceRate = GetBalanceRate(curBaseM, curBaseN); | ||
| 274 | + double curMemoryComputeScore = GetMemoryComputeScore(curBaseM, curBaseN); | ||
| 275 | + // Pick higher curBalanceRate first; use memory-compute score only as a tie-breaker. | ||
| 276 | + bool balanceBetter = curBalanceRate > balanceRate + SCORE_COMPARE_EPS; | ||
| 277 | + bool memoryComputeBetter = IsScoreEqual(curBalanceRate, balanceRate) && | ||
| 278 | + curMemoryComputeScore + SCORE_COMPARE_EPS < memoryComputeScore; | ||
| 279 | + if (!hasCandidate || balanceBetter || memoryComputeBetter) { | ||
| 280 | + bestBaseM = curBaseM; | ||
| 281 | + bestBaseN = curBaseN; | ||
| 282 | + balanceRate = curBalanceRate; | ||
| 283 | + memoryComputeScore = curMemoryComputeScore; | ||
| 284 | + hasCandidate = true; | ||
| 285 | + } | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | +} | ||
| 289 | + | ||
| 290 | +bool BaseBlockCalculator::ShouldSkipLoadBalanceCandidate( | ||
| 291 | + uint64_t curBaseM, uint64_t curBaseN, uint64_t originLastRoundUsedCore, | ||
| 292 | + double originMemoryComputeScore) const | ||
| 293 | +{ | ||
| 294 | + bool isOriginBase = curBaseM == baseBlockRes_.baseM && curBaseN == baseBlockRes_.baseN; | ||
| 295 | + uint64_t curLastRoundBlockCnt = GetLastRoundBlockCnt(curBaseM, curBaseN); | ||
| 296 | + double curMemoryComputeScore = GetMemoryComputeScore(curBaseM, curBaseN); | ||
| 297 | + bool lastRoundBlockCntLess = curLastRoundBlockCnt < originLastRoundUsedCore; | ||
| 298 | + bool memoryComputeWorseWithoutCoreGain = curLastRoundBlockCnt == originLastRoundUsedCore && | ||
| 299 | + curMemoryComputeScore > originMemoryComputeScore + SCORE_COMPARE_EPS; | ||
| 300 | + return isOriginBase || lastRoundBlockCntLess || memoryComputeWorseWithoutCoreGain; | ||
| 301 | +} | ||
| 302 | + | ||
| 303 | +void BaseBlockCalculator::TryApplyLoadBalanceBase(uint64_t bestBaseM, uint64_t bestBaseN) | ||
| 304 | +{ | ||
| 305 | + uint64_t baseN128AlignFallbackKThreshold = | ||
| 306 | + GetShapeWithDataType(LOAD_BALANCE_BASE_N_128_ALIGN_K_THRESHOLD, inputParams_.aDtype); | ||
| 307 | + // For small K, keep the original base if the candidate baseN is not 128-aligned. | ||
| 308 | + bool shouldFallbackToOriginBase = | ||
| 309 | + bestBaseN % qmmv3_tiling_const::BASIC_BLOCK_SIZE_128 != 0UL && inputParams_.kSize < baseN128AlignFallbackKThreshold; | ||
| 310 | + if (shouldFallbackToOriginBase) { | ||
| 311 | + return; | ||
| 312 | + } | ||
| 313 | + baseBlockRes_.baseM = bestBaseM; | ||
| 314 | + baseBlockRes_.baseN = bestBaseN; | ||
| 315 | + if (baseBlockRes_.baseM > inputParams_.mSize) { | ||
| 316 | + baseBlockRes_.baseM = ops::CeilAlign(inputParams_.mSize, GetBaseMAlignSize()); | ||
| 317 | + } | ||
| 318 | + if (baseBlockRes_.baseN > inputParams_.nSize) { | ||
| 319 | + baseBlockRes_.baseN = ops::CeilAlign(inputParams_.nSize, GetBaseNAlignSize()); | ||
| 320 | + } | ||
| 321 | +} | ||
| 322 | + | ||
| 323 | +uint64_t BaseBlockCalculator::GetSingleCoreMaxRound(uint64_t baseM, uint64_t baseN) const | ||
| 324 | +{ | ||
| 325 | + uint64_t blockCnt = batchCoreCnt_ * ops::CeilDiv(inputParams_.mSize, baseM) * | ||
| 326 | + ops::CeilDiv(inputParams_.nSize, baseN); | ||
| 327 | + return ops::CeilDiv(blockCnt, static_cast<uint64_t>(compileInfo_.aicNum)); | ||
| 328 | +} | ||
| 329 | + | ||
| 330 | +double BaseBlockCalculator::GetBalanceRate(uint64_t baseM, uint64_t baseN) const | ||
| 331 | +{ | ||
| 332 | + uint64_t round = GetSingleCoreMaxRound(baseM, baseN); | ||
| 333 | + return static_cast<double>(batchCoreCnt_) * inputParams_.mSize * inputParams_.nSize / compileInfo_.aicNum / | ||
| 334 | + (static_cast<double>(round) * baseM * baseN); | ||
| 335 | +} | ||
| 336 | + | ||
| 337 | +uint64_t BaseBlockCalculator::GetLastRoundBlockCnt(uint64_t baseM, uint64_t baseN) const | ||
| 338 | +{ | ||
| 339 | + uint64_t aicNum = static_cast<uint64_t>(compileInfo_.aicNum); | ||
| 340 | + uint64_t blockCnt = | ||
| 341 | + batchCoreCnt_ * ops::CeilDiv(inputParams_.mSize, baseM) * ops::CeilDiv(inputParams_.nSize, baseN); | ||
| 342 | + uint64_t tailBlockCnt = blockCnt % aicNum; | ||
| 343 | + return tailBlockCnt == 0UL ? aicNum : tailBlockCnt; | ||
| 344 | +} | ||
| 345 | + | ||
| 200 | bool BaseBlockCalculator::AdjustBaseBlockDefault() | 346 | bool BaseBlockCalculator::AdjustBaseBlockDefault() |
| 201 | { | 347 | { |
| 202 | uint64_t baseMAlignNum = | 348 | uint64_t baseMAlignNum = |
| 203 | - inputParams_.transA ? GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.aDtype) : CUBE_BLOCK; | 349 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 204 | uint64_t baseNAlignNum = | 350 | uint64_t baseNAlignNum = |
| 205 | - inputParams_.transB ? CUBE_BLOCK : GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.bDtype); | 351 | + inputParams_.transB ? qmmv3_tiling_const::CUBE_BLOCK : GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.bDtype); |
| 206 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) ? | 352 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) ? |
| 207 | - GetShapeWithDataType(BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : | 353 | + GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : |
| 208 | - GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.aDtype); | 354 | + GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype); |
| 209 | if (IsMxBackwardTrans()) { | 355 | if (IsMxBackwardTrans()) { |
| 210 | - baseKAlignNum = GetShapeWithDataType(MXFP_DIVISOR_SIZE, inputParams_.aDtype); | 356 | + baseKAlignNum = GetShapeWithDataType(qmmv3_tiling_const::MXFP_DIVISOR_SIZE, inputParams_.aDtype); |
| 211 | } | 357 | } |
| 212 | OP_TILING_CHECK( | 358 | OP_TILING_CHECK( |
| 213 | baseMAlignNum == 0UL || baseNAlignNum == 0UL || baseKAlignNum == 0UL, | 359 | baseMAlignNum == 0UL || baseNAlignNum == 0UL || baseKAlignNum == 0UL, |
| @@ -228,7 +374,7 @@ bool BaseBlockCalculator::AdjustBaseBlockDefault() | |||
| 228 | 374 | ||
| 229 | uint64_t mCore = MathUtil::CeilDivision(inputParams_.mSize, baseBlockRes_.baseM); | 375 | uint64_t mCore = MathUtil::CeilDivision(inputParams_.mSize, baseBlockRes_.baseM); |
| 230 | uint64_t nCore = MathUtil::CeilDivision(inputParams_.nSize, baseBlockRes_.baseN); | 376 | uint64_t nCore = MathUtil::CeilDivision(inputParams_.nSize, baseBlockRes_.baseN); |
| 231 | - if (mMaxtile < nMaxtile || (mMaxtile == nMaxtile && baseNAlignNum == CUBE_BLOCK)) { | 377 | + if (mMaxtile < nMaxtile || (mMaxtile == nMaxtile && baseNAlignNum == qmmv3_tiling_const::CUBE_BLOCK)) { |
| 232 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); | 378 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); |
| 233 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); | 379 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); |
| 234 | nCore = coreNumMN / mCore; | 380 | nCore = coreNumMN / mCore; |
| @@ -240,7 +386,7 @@ bool BaseBlockCalculator::AdjustBaseBlockDefault() | |||
| 240 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); | 386 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); |
| 241 | } | 387 | } |
| 242 | 388 | ||
| 243 | - while (tempBaseN >= tempBaseM * BASEM_BASEN_RATIO && nCore < coreNumMN / NUM_HALF && tempBaseN != baseNAlignNum) { | 389 | + while (tempBaseN >= tempBaseM * BASEM_BASEN_RATIO && nCore < coreNumMN / qmmv3_tiling_const::NUM_HALF && tempBaseN != baseNAlignNum) { |
| 244 | nCore = nCore * DOUBLE_CORE_NUM; | 390 | nCore = nCore * DOUBLE_CORE_NUM; |
| 245 | mCore = coreNumMN / nCore; | 391 | mCore = coreNumMN / nCore; |
| 246 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); | 392 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); |
| @@ -248,7 +394,7 @@ bool BaseBlockCalculator::AdjustBaseBlockDefault() | |||
| 248 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); | 394 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); |
| 249 | nCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); | 395 | nCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); |
| 250 | } | 396 | } |
| 251 | - while (tempBaseM >= tempBaseN * BASEM_BASEN_RATIO && mCore < coreNumMN / NUM_HALF && tempBaseM != baseMAlignNum) { | 397 | + while (tempBaseM >= tempBaseN * BASEM_BASEN_RATIO && mCore < coreNumMN / qmmv3_tiling_const::NUM_HALF && tempBaseM != baseMAlignNum) { |
| 252 | mCore = mCore * DOUBLE_CORE_NUM; | 398 | mCore = mCore * DOUBLE_CORE_NUM; |
| 253 | nCore = coreNumMN / mCore; | 399 | nCore = coreNumMN / mCore; |
| 254 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); | 400 | tempBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, mCore), baseMAlignNum); |
| @@ -256,22 +402,55 @@ bool BaseBlockCalculator::AdjustBaseBlockDefault() | |||
| 256 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); | 402 | mCore = MathUtil::CeilDivision(inputParams_.mSize, tempBaseM); |
| 257 | nCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); | 403 | nCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); |
| 258 | } | 404 | } |
| 405 | + TrySwapBaseMNForMxFalseTrue(tempBaseM, tempBaseN); | ||
| 259 | uint64_t kValueAlign = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); | 406 | uint64_t kValueAlign = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); |
| 260 | - uint64_t kValueMax = | 407 | + uint64_t kValueMax = GetShapeWithDataType(compileInfo_.l0aSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM, inputParams_.aDtype) / |
| 261 | - GetShapeWithDataType(compileInfo_.l0aSize / DB_SIZE, inputParams_.aDtype) / std::max(tempBaseM, tempBaseN); | 408 | + std::max(tempBaseM, tempBaseN); |
| 262 | if (kValueMax >= baseKAlignNum) { | 409 | if (kValueMax >= baseKAlignNum) { |
| 263 | baseBlockRes_.baseM = tempBaseM; | 410 | baseBlockRes_.baseM = tempBaseM; |
| 264 | baseBlockRes_.baseN = tempBaseN; | 411 | baseBlockRes_.baseN = tempBaseN; |
| 265 | kValueMax = ops::FloorAlign(kValueMax, baseKAlignNum); | 412 | kValueMax = ops::FloorAlign(kValueMax, baseKAlignNum); |
| 266 | baseBlockRes_.baseK = std::min(kValueAlign, kValueMax); | 413 | baseBlockRes_.baseK = std::min(kValueAlign, kValueMax); |
| 267 | baseBlockRes_.baseK = baseBlockRes_.baseK > BASEK_LIMIT ? | 414 | baseBlockRes_.baseK = baseBlockRes_.baseK > BASEK_LIMIT ? |
| 268 | - ops::CeilAlign(baseBlockRes_.baseK / NUM_HALF, baseKAlignNum) : | 415 | + ops::CeilAlign(baseBlockRes_.baseK / qmmv3_tiling_const::NUM_HALF, baseKAlignNum) : |
| 269 | baseBlockRes_.baseK; | 416 | baseBlockRes_.baseK; |
| 270 | baseBlockRes_.useTailWinLogic = false; | 417 | baseBlockRes_.useTailWinLogic = false; |
| 271 | } | 418 | } |
| 272 | return true; | 419 | return true; |
| 273 | } | 420 | } |
| 274 | 421 | ||
| 422 | +void BaseBlockCalculator::TrySwapBaseMNForMxFalseTrue(uint64_t& baseM, uint64_t& baseN) const | ||
| 423 | +{ | ||
| 424 | + // MX false/true can end up with a narrow unaligned N tile. In single-round cases, try swapping M/N so baseN | ||
| 425 | + // becomes 128-aligned without reducing core utilization. | ||
| 426 | + if (!inputParams_.isMxPerGroup || inputParams_.transA || !inputParams_.transB || | ||
| 427 | + baseN % qmmv3_tiling_const::BASIC_BLOCK_SIZE_128 == 0UL) { | ||
| 428 | + return; | ||
| 429 | + } | ||
| 430 | + uint64_t swapBaseM = baseN; | ||
| 431 | + uint64_t swapBaseN = baseM; | ||
| 432 | + uint64_t swapRound = GetSingleCoreMaxRound(swapBaseM, swapBaseN); | ||
| 433 | + // Only adjust single-round cases here; multi-round shapes are handled by load-balance search. | ||
| 434 | + if (swapRound != 1UL) { | ||
| 435 | + return; | ||
| 436 | + } | ||
| 437 | + uint64_t curMCore = MathUtil::CeilDivision(inputParams_.mSize, baseM); | ||
| 438 | + uint64_t curNCore = MathUtil::CeilDivision(inputParams_.nSize, baseN); | ||
| 439 | + uint64_t swapMCore = MathUtil::CeilDivision(inputParams_.mSize, swapBaseM); | ||
| 440 | + uint64_t swapNCore = MathUtil::CeilDivision(inputParams_.nSize, swapBaseN); | ||
| 441 | + uint64_t curUsedCore = curMCore * curNCore; | ||
| 442 | + uint64_t swapUsedCore = swapMCore * swapNCore; | ||
| 443 | + double curCoreShapeScore = GetBaseShapeScore(curMCore, curNCore); | ||
| 444 | + double swapCoreShapeScore = GetBaseShapeScore(swapMCore, swapNCore); | ||
| 445 | + bool swapCoreShapeBetter = swapCoreShapeScore + SCORE_COMPARE_EPS < curCoreShapeScore; | ||
| 446 | + bool swapBaseNIsFriendly = IsScoreEqual(swapCoreShapeScore, curCoreShapeScore) && | ||
| 447 | + swapBaseN % qmmv3_tiling_const::BASIC_BLOCK_SIZE_128 == 0UL; | ||
| 448 | + if (swapUsedCore >= curUsedCore && (swapCoreShapeBetter || swapBaseNIsFriendly)) { | ||
| 449 | + baseM = swapBaseM; | ||
| 450 | + baseN = swapBaseN; | ||
| 451 | + } | ||
| 452 | +} | ||
| 453 | + | ||
| 275 | bool BaseBlockCalculator::AdjustBaseBlockPerblock() | 454 | bool BaseBlockCalculator::AdjustBaseBlockPerblock() |
| 276 | { | 455 | { |
| 277 | uint64_t coreNumMN = compileInfo_.aicNum / batchCoreCnt_; | 456 | uint64_t coreNumMN = compileInfo_.aicNum / batchCoreCnt_; |
| @@ -279,14 +458,14 @@ bool BaseBlockCalculator::AdjustBaseBlockPerblock() | |||
| 279 | return AdjustBaseBlockPertile(coreNumMN); | 458 | return AdjustBaseBlockPertile(coreNumMN); |
| 280 | } else if ( | 459 | } else if ( |
| 281 | baseBlockRes_.baseM == PER_BLOCK_BASE_SIZE_256 && | 460 | baseBlockRes_.baseM == PER_BLOCK_BASE_SIZE_256 && |
| 282 | - ops::CeilDiv(inputParams_.mSize, PER_BLOCK_SIZE) * ops::CeilDiv(inputParams_.nSize, baseBlockRes_.baseN) <= | 461 | + ops::CeilDiv(inputParams_.mSize, qmmv3_tiling_const::PER_BLOCK_SIZE) * ops::CeilDiv(inputParams_.nSize, baseBlockRes_.baseN) <= |
| 283 | coreNumMN) { | 462 | coreNumMN) { |
| 284 | - baseBlockRes_.baseM = PER_BLOCK_SIZE; | 463 | + baseBlockRes_.baseM = qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 285 | } else if ( | 464 | } else if ( |
| 286 | baseBlockRes_.baseN == PER_BLOCK_BASE_SIZE_256 && | 465 | baseBlockRes_.baseN == PER_BLOCK_BASE_SIZE_256 && |
| 287 | - ops::CeilDiv(inputParams_.mSize, baseBlockRes_.baseM) * ops::CeilDiv(inputParams_.nSize, PER_BLOCK_SIZE) <= | 466 | + ops::CeilDiv(inputParams_.mSize, baseBlockRes_.baseM) * ops::CeilDiv(inputParams_.nSize, qmmv3_tiling_const::PER_BLOCK_SIZE) <= |
| 288 | coreNumMN) { | 467 | coreNumMN) { |
| 289 | - baseBlockRes_.baseN = PER_BLOCK_SIZE; | 468 | + baseBlockRes_.baseN = qmmv3_tiling_const::PER_BLOCK_SIZE; |
| 290 | } | 469 | } |
| 291 | return true; | 470 | return true; |
| 292 | } | 471 | } |
| @@ -294,9 +473,9 @@ bool BaseBlockCalculator::AdjustBaseBlockPerblock() | |||
| 294 | bool BaseBlockCalculator::AdjustBaseBlockPertile(uint64_t coreNumMN) | 473 | bool BaseBlockCalculator::AdjustBaseBlockPertile(uint64_t coreNumMN) |
| 295 | { | 474 | { |
| 296 | uint64_t baseMAlignNum = | 475 | uint64_t baseMAlignNum = |
| 297 | - inputParams_.transA ? GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.aDtype) : CUBE_BLOCK; | 476 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 298 | uint64_t baseNAlignNum = | 477 | uint64_t baseNAlignNum = |
| 299 | - !inputParams_.transB ? GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.bDtype) : CUBE_BLOCK; | 478 | + !inputParams_.transB ? GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.bDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 300 | uint64_t adjustBaseM = baseBlockRes_.baseM; | 479 | uint64_t adjustBaseM = baseBlockRes_.baseM; |
| 301 | uint64_t adjustBaseN = baseBlockRes_.baseN; | 480 | uint64_t adjustBaseN = baseBlockRes_.baseN; |
| 302 | uint64_t adjustMCore = MathUtil::CeilDivision(inputParams_.mSize, adjustBaseM); | 481 | uint64_t adjustMCore = MathUtil::CeilDivision(inputParams_.mSize, adjustBaseM); |
| @@ -306,14 +485,14 @@ bool BaseBlockCalculator::AdjustBaseBlockPertile(uint64_t coreNumMN) | |||
| 306 | adjustBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, adjustMCore), baseMAlignNum); | 485 | adjustBaseM = ops::CeilAlign(MathUtil::CeilDivision(inputParams_.mSize, adjustMCore), baseMAlignNum); |
| 307 | adjustMCore = MathUtil::CeilDivision(inputParams_.mSize, adjustBaseM); | 486 | adjustMCore = MathUtil::CeilDivision(inputParams_.mSize, adjustBaseM); |
| 308 | 487 | ||
| 309 | - while (adjustBaseN / NUM_HALF >= baseNAlignNum && | 488 | + while (adjustBaseN / qmmv3_tiling_const::NUM_HALF >= baseNAlignNum && |
| 310 | - adjustMCore * MathUtil::CeilDivision(inputParams_.nSize, adjustBaseN / NUM_HALF) <= coreNumMN) { | 489 | + adjustMCore * MathUtil::CeilDivision(inputParams_.nSize, adjustBaseN / qmmv3_tiling_const::NUM_HALF) <= coreNumMN) { |
| 311 | - adjustBaseN = adjustBaseN / NUM_HALF; | 490 | + adjustBaseN = adjustBaseN / qmmv3_tiling_const::NUM_HALF; |
| 312 | adjustNCore = MathUtil::CeilDivision(inputParams_.nSize, adjustBaseN); | 491 | adjustNCore = MathUtil::CeilDivision(inputParams_.nSize, adjustBaseN); |
| 313 | } | 492 | } |
| 314 | 493 | ||
| 315 | - while (adjustBaseN > adjustBaseM * BASEM_BASEN_RATIO && adjustBaseN / NUM_HALF >= baseNAlignNum) { | 494 | + while (adjustBaseN > adjustBaseM * BASEM_BASEN_RATIO && adjustBaseN / qmmv3_tiling_const::NUM_HALF >= baseNAlignNum) { |
| 316 | - uint64_t tempBaseN = adjustBaseN / NUM_HALF; | 495 | + uint64_t tempBaseN = adjustBaseN / qmmv3_tiling_const::NUM_HALF; |
| 317 | uint64_t tempNCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); | 496 | uint64_t tempNCore = MathUtil::CeilDivision(inputParams_.nSize, tempBaseN); |
| 318 | if (tempNCore == 0UL || tempNCore > coreNumMN) { | 497 | if (tempNCore == 0UL || tempNCore > coreNumMN) { |
| 319 | break; | 498 | break; |
| @@ -340,11 +519,11 @@ bool BaseBlockCalculator::AdjustBaseBlockPertile(uint64_t coreNumMN) | |||
| 340 | bool BaseBlockCalculator::AdjustBaseBlockMmadS8S4(uint64_t oriBlock) | 519 | bool BaseBlockCalculator::AdjustBaseBlockMmadS8S4(uint64_t oriBlock) |
| 341 | { | 520 | { |
| 342 | uint64_t baseMAlignNum = | 521 | uint64_t baseMAlignNum = |
| 343 | - inputParams_.transA ? GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.aDtype) : CUBE_BLOCK; | 522 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 344 | - uint64_t baseNAlignNum = L2_ALIGN_SIZE; | 523 | + uint64_t baseNAlignNum = qmmv3_tiling_const::L2_ALIGN_SIZE; |
| 345 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) ? | 524 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) ? |
| 346 | - GetShapeWithDataType(BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : | 525 | + GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_32, inputParams_.aDtype) : |
| 347 | - GetShapeWithDataType(L2_ALIGN_SIZE, inputParams_.aDtype); | 526 | + GetShapeWithDataType(qmmv3_tiling_const::L2_ALIGN_SIZE, inputParams_.aDtype); |
| 348 | baseKAlignNum = std::min(baseKAlignNum, inputParams_.kSize); | 527 | baseKAlignNum = std::min(baseKAlignNum, inputParams_.kSize); |
| 349 | OP_TILING_CHECK( | 528 | OP_TILING_CHECK( |
| 350 | baseMAlignNum == 0UL || baseNAlignNum == 0UL || baseKAlignNum == 0UL, | 529 | baseMAlignNum == 0UL || baseNAlignNum == 0UL || baseKAlignNum == 0UL, |
| @@ -379,17 +558,17 @@ bool BaseBlockCalculator::AdjustBaseBlockMmadS8S4(uint64_t oriBlock) | |||
| 379 | optimalFound = CalculateOptimalSplit(tempBaseM, tempBaseN, baseMAlignNum, baseNAlignNum, baseKAlignNum); | 558 | optimalFound = CalculateOptimalSplit(tempBaseM, tempBaseN, baseMAlignNum, baseNAlignNum, baseKAlignNum); |
| 380 | } | 559 | } |
| 381 | uint64_t kValueAlign = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); | 560 | uint64_t kValueAlign = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); |
| 382 | - uint64_t kValueMax = | 561 | + uint64_t kValueMax = GetShapeWithDataType(compileInfo_.l0aSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM, inputParams_.aDtype) / |
| 383 | - GetShapeWithDataType(compileInfo_.l0aSize / DB_SIZE, inputParams_.aDtype) / std::max(tempBaseM, tempBaseN); | 562 | + std::max(tempBaseM, tempBaseN); |
| 384 | if (kValueMax >= baseKAlignNum && optimalFound) { | 563 | if (kValueMax >= baseKAlignNum && optimalFound) { |
| 385 | baseBlockRes_.baseM = tempBaseM; | 564 | baseBlockRes_.baseM = tempBaseM; |
| 386 | baseBlockRes_.baseN = tempBaseN; | 565 | baseBlockRes_.baseN = tempBaseN; |
| 387 | kValueMax = ops::FloorAlign(kValueMax, baseKAlignNum); | 566 | kValueMax = ops::FloorAlign(kValueMax, baseKAlignNum); |
| 388 | baseBlockRes_.baseK = std::min(kValueAlign, kValueMax); | 567 | baseBlockRes_.baseK = std::min(kValueAlign, kValueMax); |
| 389 | - baseBlockRes_.baseK = baseBlockRes_.baseK > BASEK_LIMIT ? baseBlockRes_.baseK / NUM_HALF : baseBlockRes_.baseK; | 568 | + baseBlockRes_.baseK = baseBlockRes_.baseK > BASEK_LIMIT ? baseBlockRes_.baseK / qmmv3_tiling_const::NUM_HALF : baseBlockRes_.baseK; |
| 390 | uint64_t maxAlignSize = std::max( | 569 | uint64_t maxAlignSize = std::max( |
| 391 | - GetShapeWithDataType(CUBE_REDUCE_BLOCK, inputParams_.aDtype), | 570 | + GetShapeWithDataType(qmmv3_tiling_const::CUBE_REDUCE_BLOCK, inputParams_.aDtype), |
| 392 | - GetShapeWithDataType(CUBE_REDUCE_BLOCK, inputParams_.bDtype)); | 571 | + GetShapeWithDataType(qmmv3_tiling_const::CUBE_REDUCE_BLOCK, inputParams_.bDtype)); |
| 393 | OP_TILING_CHECK( | 572 | OP_TILING_CHECK( |
| 394 | maxAlignSize == 0UL, | 573 | maxAlignSize == 0UL, |
| 395 | CUBE_INNER_ERR_REPORT( | 574 | CUBE_INNER_ERR_REPORT( |
| @@ -412,7 +591,7 @@ bool BaseBlockCalculator::CalculateOptimalSplit( | |||
| 412 | uint64_t maxDiff = UINT64_MAX; | 591 | uint64_t maxDiff = UINT64_MAX; |
| 413 | uint64_t iterMSplite = std::min(mMaxtile, static_cast<uint64_t>(compileInfo_.aicNum / batchCoreCnt_)); | 592 | uint64_t iterMSplite = std::min(mMaxtile, static_cast<uint64_t>(compileInfo_.aicNum / batchCoreCnt_)); |
| 414 | uint64_t iterNSplite = std::min(nMaxtile, static_cast<uint64_t>(compileInfo_.aicNum / batchCoreCnt_)); | 593 | uint64_t iterNSplite = std::min(nMaxtile, static_cast<uint64_t>(compileInfo_.aicNum / batchCoreCnt_)); |
| 415 | - uint64_t l0aHalfShape = GetShapeWithDataType(compileInfo_.l0aSize / DB_SIZE, inputParams_.aDtype); | 594 | + uint64_t l0aHalfShape = GetShapeWithDataType(compileInfo_.l0aSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM, inputParams_.aDtype); |
| 416 | bool optimalFound = false; | 595 | bool optimalFound = false; |
| 417 | for (uint64_t mFactor = 1UL; mFactor <= iterMSplite; ++mFactor) { | 596 | for (uint64_t mFactor = 1UL; mFactor <= iterMSplite; ++mFactor) { |
| 418 | for (uint64_t nFactor = 1UL; nFactor <= iterNSplite; ++nFactor) { | 597 | for (uint64_t nFactor = 1UL; nFactor <= iterNSplite; ++nFactor) { |
| @@ -53,11 +53,23 @@ private: | |||
| 53 | uint64_t GetBaseMAlignSize() const; | 53 | uint64_t GetBaseMAlignSize() const; |
| 54 | uint64_t GetBaseNAlignSize() const; | 54 | uint64_t GetBaseNAlignSize() const; |
| 55 | uint64_t GetBaseKAlignSize() const; | 55 | uint64_t GetBaseKAlignSize() const; |
| 56 | - bool AdjustBaseBlock(BaseBlockMode mode); | 56 | + bool OptimizeBaseBlockForCoreUtilization(BaseBlockMode mode); |
| 57 | + void OptimizeBaseBlockForLoadBalance(); | ||
| 58 | + void SearchLoadBalanceBaseBlock( | ||
| 59 | + uint64_t roundLimit, uint64_t originLastRoundUsedCore, double originMemoryComputeScore, | ||
| 60 | + uint64_t& bestBaseM, uint64_t& bestBaseN) const; | ||
| 61 | + bool ShouldSkipLoadBalanceCandidate( | ||
| 62 | + uint64_t curBaseM, uint64_t curBaseN, uint64_t originLastRoundUsedCore, | ||
| 63 | + double originMemoryComputeScore) const; | ||
| 64 | + void TryApplyLoadBalanceBase(uint64_t bestBaseM, uint64_t bestBaseN); | ||
| 57 | bool AdjustBaseBlockDefault(); | 65 | bool AdjustBaseBlockDefault(); |
| 66 | + void TrySwapBaseMNForMxFalseTrue(uint64_t& baseM, uint64_t& baseN) const; | ||
| 58 | bool AdjustBaseBlockPerblock(); | 67 | bool AdjustBaseBlockPerblock(); |
| 59 | bool AdjustBaseBlockPertile(uint64_t coreNumMN); | 68 | bool AdjustBaseBlockPertile(uint64_t coreNumMN); |
| 60 | bool AdjustBaseBlockMmadS8S4(uint64_t oriBlock); | 69 | bool AdjustBaseBlockMmadS8S4(uint64_t oriBlock); |
| 70 | + uint64_t GetSingleCoreMaxRound(uint64_t baseM, uint64_t baseN) const; | ||
| 71 | + double GetBalanceRate(uint64_t baseM, uint64_t baseN) const; | ||
| 72 | + uint64_t GetLastRoundBlockCnt(uint64_t baseM, uint64_t baseN) const; | ||
| 61 | bool CalculateOptimalSplit( | 73 | bool CalculateOptimalSplit( |
| 62 | uint64_t& baseM, uint64_t& baseN, uint64_t baseMAlignNum, uint64_t baseNAlignNum, uint64_t baseKAlignNum) const; | 74 | uint64_t& baseM, uint64_t& baseN, uint64_t baseMAlignNum, uint64_t baseNAlignNum, uint64_t baseKAlignNum) const; |
| 63 | bool IsMxBackwardTrans() const; | 75 | bool IsMxBackwardTrans() const; |
| @@ -16,25 +16,15 @@ | |||
| 16 | 16 | ||
| 17 | #include <algorithm> | 17 | #include <algorithm> |
| 18 | #include "error_util.h" | 18 | #include "error_util.h" |
| 19 | +#include "quant_batch_matmul_v3_tiling_util.h" | ||
| 19 | 20 | ||
| 20 | namespace { | 21 | namespace { |
| 21 | -constexpr uint64_t CUBE_BLOCK = 16UL; | 22 | + |
| 22 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32UL; | ||
| 23 | -constexpr uint64_t L1_ALIGN_SIZE = 32UL; | ||
| 24 | -constexpr uint64_t BASIC_BLOCK_SIZE_256 = 256UL; | ||
| 25 | -constexpr uint64_t BASIC_BLOCK_SIZE_512 = 512UL; | ||
| 26 | constexpr uint64_t MTE2_MIN_LOAD_SIZE = 32768UL; | 23 | constexpr uint64_t MTE2_MIN_LOAD_SIZE = 32768UL; |
| 27 | -constexpr uint64_t L2_ALIGN_SIZE = 128UL; | 24 | +constexpr uint64_t MIN_CARRY_DATA_SIZE_32K = 32UL * 1024UL; |
| 28 | -constexpr uint64_t MX_GROUP_SIZE = 32UL; | 25 | +constexpr uint64_t FULL_LOAD_DATA_SIZE_64K = 64UL * 1024UL; |
| 29 | -constexpr uint64_t MXFP_MULTI_BASE_SIZE = 2UL; | ||
| 30 | -constexpr uint64_t MIN_CARRY_DATA_SIZE_32K = 32 * 1024UL; | ||
| 31 | -constexpr uint64_t FULL_LOAD_DATA_SIZE_64K = 64 * 1024UL; | ||
| 32 | constexpr uint64_t CACHE_LINE_512B = 512UL; | 26 | constexpr uint64_t CACHE_LINE_512B = 512UL; |
| 33 | constexpr uint32_t MAX_STEPK_With_BL1_FULL = 8U; | 27 | constexpr uint32_t MAX_STEPK_With_BL1_FULL = 8U; |
| 34 | -constexpr uint32_t DB_SIZE = 2U; | ||
| 35 | -constexpr uint32_t NUM_HALF = 2U; | ||
| 36 | -constexpr uint32_t SCALER_FACTOR_MAX = 127U; | ||
| 37 | -constexpr uint32_t SCALER_FACTOR_MIN = 1U; | ||
| 38 | 28 | ||
| 39 | uint64_t GetSizeWithDataType(uint64_t shape, ge::DataType dtype) | 29 | uint64_t GetSizeWithDataType(uint64_t shape, ge::DataType dtype) |
| 40 | { | 30 | { |
| @@ -133,22 +123,22 @@ bool L1TilingDataCalculator::InitLeftL1Size() | |||
| 133 | if (inputParams_.cDtype == ge::DT_INT32) { | 123 | if (inputParams_.cDtype == ge::DT_INT32) { |
| 134 | scaleDtypeSize = 0UL; | 124 | scaleDtypeSize = 0UL; |
| 135 | } | 125 | } |
| 136 | - uint64_t singleCoreBiasSize = inputParams_.hasBias ? baseN_ * biasDtypeSize : 0UL; | 126 | + uint64_t biasL1Size = inputParams_.hasBias ? baseN_ * biasDtypeSize * qmmv3_tiling_const::DOUBLE_BUFFER_NUM : 0UL; |
| 137 | - uint64_t singleCoreScaleSize = inputParams_.isPerChannel ? baseN_ * scaleDtypeSize : 0UL; | 127 | + uint64_t scaleL1Size = inputParams_.isPerChannel ? baseN_ * scaleDtypeSize * qmmv3_tiling_const::DOUBLE_BUFFER_NUM : 0UL; |
| 138 | OP_TILING_CHECK( | 128 | OP_TILING_CHECK( |
| 139 | - compileInfo_.l1Size < singleCoreBiasSize, | 129 | + compileInfo_.l1Size < biasL1Size, |
| 140 | CUBE_INNER_ERR_REPORT( | 130 | CUBE_INNER_ERR_REPORT( |
| 141 | - inputParams_.opName, "Subtraction underflow: l1Size(%lu) - singleCoreBiasSize(%lu).", compileInfo_.l1Size, | 131 | + inputParams_.opName, "Subtraction underflow: l1Size(%lu) - biasL1Size(%lu).", compileInfo_.l1Size, |
| 142 | - singleCoreBiasSize), | 132 | + biasL1Size), |
| 143 | return false); | 133 | return false); |
| 144 | - uint64_t leftL1SizeAfterBias = compileInfo_.l1Size - singleCoreBiasSize; | 134 | + uint64_t leftL1SizeAfterBias = compileInfo_.l1Size - biasL1Size; |
| 145 | OP_TILING_CHECK( | 135 | OP_TILING_CHECK( |
| 146 | - leftL1SizeAfterBias < singleCoreScaleSize, | 136 | + leftL1SizeAfterBias < scaleL1Size, |
| 147 | CUBE_INNER_ERR_REPORT( | 137 | CUBE_INNER_ERR_REPORT( |
| 148 | - inputParams_.opName, "Subtraction underflow: leftL1SizeAfterBias(%lu) - singleCoreScaleSize(%lu).", | 138 | + inputParams_.opName, "Subtraction underflow: leftL1SizeAfterBias(%lu) - scaleL1Size(%lu).", |
| 149 | - leftL1SizeAfterBias, singleCoreScaleSize), | 139 | + leftL1SizeAfterBias, scaleL1Size), |
| 150 | return false); | 140 | return false); |
| 151 | - leftL1Size_ = leftL1SizeAfterBias - singleCoreScaleSize; | 141 | + leftL1Size_ = leftL1SizeAfterBias - scaleL1Size; |
| 152 | return true; | 142 | return true; |
| 153 | } | 143 | } |
| 154 | 144 | ||
| @@ -157,7 +147,7 @@ bool L1TilingDataCalculator::ComputeL1TilingDefault() | |||
| 157 | if (inputParams_.isMxPerGroup) { | 147 | if (inputParams_.isMxPerGroup) { |
| 158 | uint64_t baseASize = GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype); | 148 | uint64_t baseASize = GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype); |
| 159 | uint64_t baseBSize = GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype); | 149 | uint64_t baseBSize = GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype); |
| 160 | - uint64_t scaleBaseK = ops::CeilAlign(ops::CeilDiv(baseK_, MX_GROUP_SIZE), MXFP_MULTI_BASE_SIZE); | 150 | + uint64_t scaleBaseK = ops::CeilAlign(ops::CeilDiv(baseK_, qmmv3_tiling_const::MX_GROUP_SIZE), qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE); |
| 161 | uint64_t baseScaleASize = GetSizeWithDataType(scaleBaseK * baseM_, inputParams_.perTokenScaleDtype); | 151 | uint64_t baseScaleASize = GetSizeWithDataType(scaleBaseK * baseM_, inputParams_.perTokenScaleDtype); |
| 162 | uint64_t baseScaleBSize = GetSizeWithDataType(scaleBaseK * baseN_, inputParams_.scaleDtype); | 152 | uint64_t baseScaleBSize = GetSizeWithDataType(scaleBaseK * baseN_, inputParams_.scaleDtype); |
| 163 | uint64_t baseL1Size = baseASize + baseBSize + baseScaleASize + baseScaleBSize; | 153 | uint64_t baseL1Size = baseASize + baseBSize + baseScaleASize + baseScaleBSize; |
| @@ -166,24 +156,10 @@ bool L1TilingDataCalculator::ComputeL1TilingDefault() | |||
| 166 | CUBE_INNER_ERR_REPORT( | 156 | CUBE_INNER_ERR_REPORT( |
| 167 | inputParams_.opName, "Invalid MX L1 divisor: baseL1Size(%lu) should be greater than 0.", baseL1Size), | 157 | inputParams_.opName, "Invalid MX L1 divisor: baseL1Size(%lu) should be greater than 0.", baseL1Size), |
| 168 | return false); | 158 | return false); |
| 169 | - uint64_t depthInit = GetDepthA1B1(leftL1Size_, baseL1Size, 1UL); | 159 | + uint64_t depthInit = GetDepthA1B1(); |
| 170 | - OP_TILING_CHECK( | 160 | + l1TilingData_.depthKa_ = depthInit; |
| 171 | - baseL1Size > leftL1Size_ / depthInit, | 161 | + l1TilingData_.depthKb_ = depthInit; |
| 172 | - CUBE_INNER_ERR_REPORT( | 162 | + if (!CalStepKs() || !CalScaleFactors(baseASize, baseBSize)) { |
| 173 | - inputParams_.opName, "Subtraction underflow: leftL1Size(%lu) - depthInit(%lu) * baseL1Size(%lu).", | ||
| 174 | - leftL1Size_, depthInit, baseL1Size), | ||
| 175 | - return false); | ||
| 176 | - uint64_t usedL1SizeByDepthInit = depthInit * baseL1Size; | ||
| 177 | - uint64_t leftL1SizeByDepthInit = leftL1Size_ - usedL1SizeByDepthInit; | ||
| 178 | - uint64_t depthASec = GetDepthA1B1(leftL1SizeByDepthInit, (baseASize + baseScaleASize) * depthInit, depthInit); | ||
| 179 | - uint64_t depthBSec = GetDepthA1B1(leftL1SizeByDepthInit, (baseBSize + baseScaleBSize) * depthInit, depthInit); | ||
| 180 | - l1TilingData_.depthKa_ = std::max(depthASec, depthBSec); | ||
| 181 | - l1TilingData_.depthKb_ = l1TilingData_.depthKa_; | ||
| 182 | - if (l1TilingData_.depthKa_ * baseL1Size > leftL1Size_) { | ||
| 183 | - l1TilingData_.depthKa_ = depthASec >= depthBSec ? depthASec : depthInit; | ||
| 184 | - l1TilingData_.depthKb_ = depthASec < depthBSec ? depthBSec : depthInit; | ||
| 185 | - } | ||
| 186 | - if (!CalStepKs() || !CalScaleFactors(baseASize, baseBSize, baseScaleASize, baseScaleBSize)) { | ||
| 187 | return false; | 163 | return false; |
| 188 | } | 164 | } |
| 189 | } else { | 165 | } else { |
| @@ -198,8 +174,8 @@ bool L1TilingDataCalculator::ComputeL1TilingDefault() | |||
| 198 | "Invalid L1 base size: baseASize(%lu) and baseBSize(%lu) should be greater than 0.", baseASize, | 174 | "Invalid L1 base size: baseASize(%lu) and baseBSize(%lu) should be greater than 0.", baseASize, |
| 199 | baseBSize), | 175 | baseBSize), |
| 200 | return false); | 176 | return false); |
| 201 | - l1TilingData_.depthKa_ = leftL1Size_ / NUM_HALF / baseASize; | 177 | + l1TilingData_.depthKa_ = leftL1Size_ / qmmv3_tiling_const::NUM_HALF / baseASize; |
| 202 | - l1TilingData_.depthKb_ = leftL1Size_ / NUM_HALF / baseBSize; | 178 | + l1TilingData_.depthKb_ = leftL1Size_ / qmmv3_tiling_const::NUM_HALF / baseBSize; |
| 203 | if (!CalStepKs()) { | 179 | if (!CalStepKs()) { |
| 204 | return false; | 180 | return false; |
| 205 | } | 181 | } |
| @@ -224,9 +200,9 @@ bool L1TilingDataCalculator::ComputeL1TilingAL1FullLoad() | |||
| 224 | if (inputParams_.isMxPerGroup) { | 200 | if (inputParams_.isMxPerGroup) { |
| 225 | uint64_t singleCoreScaleASize = GetSizeWithDataType( | 201 | uint64_t singleCoreScaleASize = GetSizeWithDataType( |
| 226 | std::min(inputParams_.mSize, baseM_) * | 202 | std::min(inputParams_.mSize, baseM_) * |
| 227 | - ops::CeilAlign(ops::CeilDiv(inputParams_.kSize, MX_GROUP_SIZE), MXFP_MULTI_BASE_SIZE), | 203 | + ops::CeilAlign(ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MX_GROUP_SIZE), qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE), |
| 228 | inputParams_.perTokenScaleDtype); | 204 | inputParams_.perTokenScaleDtype); |
| 229 | - uint64_t alignedSingleCoreScaleASize = ops::CeilAlign(singleCoreScaleASize, L1_ALIGN_SIZE); | 205 | + uint64_t alignedSingleCoreScaleASize = ops::CeilAlign(singleCoreScaleASize, qmmv3_tiling_const::L1_ALIGN_SIZE); |
| 230 | l1TilingData_.scaleFactorA_ = 1UL; | 206 | l1TilingData_.scaleFactorA_ = 1UL; |
| 231 | OP_TILING_CHECK( | 207 | OP_TILING_CHECK( |
| 232 | leftL1SizeAfterFullA < alignedSingleCoreScaleASize, | 208 | leftL1SizeAfterFullA < alignedSingleCoreScaleASize, |
| @@ -238,8 +214,8 @@ bool L1TilingDataCalculator::ComputeL1TilingAL1FullLoad() | |||
| 238 | leftL1SizeAfterFullA -= alignedSingleCoreScaleASize; | 214 | leftL1SizeAfterFullA -= alignedSingleCoreScaleASize; |
| 239 | l1TilingData_.depthKb_ = GetDepthB1AfullLoad(leftL1SizeAfterFullA); | 215 | l1TilingData_.depthKb_ = GetDepthB1AfullLoad(leftL1SizeAfterFullA); |
| 240 | l1TilingData_.stepKb_ = | 216 | l1TilingData_.stepKb_ = |
| 241 | - l1TilingData_.depthKb_ == 1UL ? l1TilingData_.depthKb_ : l1TilingData_.depthKb_ / DB_SIZE; | 217 | + l1TilingData_.depthKb_ == 1UL ? l1TilingData_.depthKb_ : l1TilingData_.depthKb_ / qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 242 | - uint64_t alignedBSize = ops::CeilAlign(l1TilingData_.depthKb_ * baseBSize, L1_ALIGN_SIZE); | 218 | + uint64_t alignedBSize = ops::CeilAlign(l1TilingData_.depthKb_ * baseBSize, qmmv3_tiling_const::L1_ALIGN_SIZE); |
| 243 | OP_TILING_CHECK( | 219 | OP_TILING_CHECK( |
| 244 | leftL1SizeAfterFullA < alignedBSize, | 220 | leftL1SizeAfterFullA < alignedBSize, |
| 245 | CUBE_INNER_ERR_REPORT( | 221 | CUBE_INNER_ERR_REPORT( |
| @@ -250,7 +226,7 @@ bool L1TilingDataCalculator::ComputeL1TilingAL1FullLoad() | |||
| 250 | } else { | 226 | } else { |
| 251 | l1TilingData_.depthKb_ = GetDepthB1AfullLoad(leftL1SizeAfterFullA); | 227 | l1TilingData_.depthKb_ = GetDepthB1AfullLoad(leftL1SizeAfterFullA); |
| 252 | l1TilingData_.stepKb_ = | 228 | l1TilingData_.stepKb_ = |
| 253 | - l1TilingData_.depthKb_ == 1UL ? l1TilingData_.depthKb_ : l1TilingData_.depthKb_ / DB_SIZE; | 229 | + l1TilingData_.depthKb_ == 1UL ? l1TilingData_.depthKb_ : l1TilingData_.depthKb_ / qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 254 | } | 230 | } |
| 255 | return true; | 231 | return true; |
| 256 | } | 232 | } |
| @@ -270,14 +246,14 @@ bool L1TilingDataCalculator::ComputeL1TilingBL1FullLoad() | |||
| 270 | uint64_t leftL1SizeAfterFullB = leftL1Size_ - alignedSingleCoreBSize; | 246 | uint64_t leftL1SizeAfterFullB = leftL1Size_ - alignedSingleCoreBSize; |
| 271 | l1TilingData_.depthKa_ = GetDepthA1BfullLoad(leftL1SizeAfterFullB); | 247 | l1TilingData_.depthKa_ = GetDepthA1BfullLoad(leftL1SizeAfterFullB); |
| 272 | l1TilingData_.stepKa_ = | 248 | l1TilingData_.stepKa_ = |
| 273 | - l1TilingData_.depthKa_ == 1UL ? l1TilingData_.depthKa_ : l1TilingData_.depthKa_ / DB_SIZE; | 249 | + l1TilingData_.depthKa_ == 1UL ? l1TilingData_.depthKa_ : l1TilingData_.depthKa_ / qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 274 | return true; | 250 | return true; |
| 275 | } | 251 | } |
| 276 | 252 | ||
| 277 | bool L1TilingDataCalculator::CalStepKs() | 253 | bool L1TilingDataCalculator::CalStepKs() |
| 278 | { | 254 | { |
| 279 | - l1TilingData_.stepKa_ = l1TilingData_.depthKa_ / DB_SIZE; | 255 | + l1TilingData_.stepKa_ = l1TilingData_.depthKa_ / qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 280 | - l1TilingData_.stepKb_ = l1TilingData_.depthKb_ / DB_SIZE; | 256 | + l1TilingData_.stepKb_ = l1TilingData_.depthKb_ / qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 281 | 257 | ||
| 282 | if (l1TilingData_.stepKa_ * baseK_ > inputParams_.kSize) { | 258 | if (l1TilingData_.stepKa_ * baseK_ > inputParams_.kSize) { |
| 283 | l1TilingData_.stepKa_ = ops::CeilDiv(inputParams_.kSize, baseK_); | 259 | l1TilingData_.stepKa_ = ops::CeilDiv(inputParams_.kSize, baseK_); |
| @@ -304,117 +280,77 @@ bool L1TilingDataCalculator::CalStepKs() | |||
| 304 | l1TilingData_.stepKb_ = std::min(l1TilingData_.stepKb_, 4UL); | 280 | l1TilingData_.stepKb_ = std::min(l1TilingData_.stepKb_, 4UL); |
| 305 | } | 281 | } |
| 306 | if (inputParams_.isPerBlock && inputParams_.hasBias) { | 282 | if (inputParams_.isPerBlock && inputParams_.hasBias) { |
| 307 | - l1TilingData_.stepKa_ = (l1TilingData_.stepKa_ + l1TilingData_.stepKb_) / NUM_HALF; | 283 | + // The current pertile/perblock tiling constraints keep the averaged stepK within L1 capacity. |
| 284 | + l1TilingData_.stepKa_ = (l1TilingData_.stepKa_ + l1TilingData_.stepKb_) / qmmv3_tiling_const::NUM_HALF; | ||
| 308 | l1TilingData_.stepKb_ = l1TilingData_.stepKa_; | 285 | l1TilingData_.stepKb_ = l1TilingData_.stepKa_; |
| 309 | } | 286 | } |
| 310 | - l1TilingData_.depthKa_ = l1TilingData_.stepKa_ * DB_SIZE; | 287 | + l1TilingData_.depthKa_ = l1TilingData_.stepKa_ * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 311 | - l1TilingData_.depthKb_ = l1TilingData_.stepKb_ * DB_SIZE; | 288 | + l1TilingData_.depthKb_ = l1TilingData_.stepKb_ * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 312 | return true; | 289 | return true; |
| 313 | } | 290 | } |
| 314 | 291 | ||
| 315 | -bool L1TilingDataCalculator::CalScaleFactors( | 292 | +bool L1TilingDataCalculator::CalScaleFactors(uint64_t baseASize, uint64_t baseBSize) |
| 316 | - uint64_t baseASize, uint64_t baseBSize, uint64_t baseScaleASize, uint64_t baseScaleBSize) | ||
| 317 | { | 293 | { |
| 318 | - uint64_t biasDtypeSize = ge::GetSizeByDataType(inputParams_.biasDtype); | 294 | + uint64_t usedABSize = l1TilingData_.depthKa_ * baseASize + l1TilingData_.depthKb_ * baseBSize; |
| 319 | - uint64_t baseBiasSize = inputParams_.hasBias ? baseN_ * biasDtypeSize : 0UL; | ||
| 320 | OP_TILING_CHECK( | 295 | OP_TILING_CHECK( |
| 321 | - baseScaleASize == 0UL || baseScaleBSize == 0UL, | 296 | + leftL1Size_ < usedABSize, |
| 322 | CUBE_INNER_ERR_REPORT( | 297 | CUBE_INNER_ERR_REPORT( |
| 323 | - inputParams_.opName, | 298 | + inputParams_.opName, "Subtraction underflow: leftL1Size(%lu) - usedABSize(%lu).", leftL1Size_, |
| 324 | - "Invalid scale factor divisor: baseScaleASize(%lu) and baseScaleBSize(%lu) should be greater than 0.", | 299 | + usedABSize), |
| 325 | - baseScaleASize, baseScaleBSize), | 300 | + return false); |
| 301 | + uint64_t leftL1Size = leftL1Size_ - usedABSize; | ||
| 302 | + | ||
| 303 | + uint64_t stepK = std::min(l1TilingData_.stepKa_, l1TilingData_.stepKb_); | ||
| 304 | + uint64_t kL1 = stepK * baseK_; | ||
| 305 | + | ||
| 306 | + // One MX scale group covers 64 K elements and stores two scale values. A/B scale buffers are double-buffered, | ||
| 307 | + // so this is the L1 cost for extending scaleKL1 by one 64-element group. | ||
| 308 | + uint64_t scaleGroupL1Size = | ||
这里直接用 scaleGroupL1Size 做除法,但没有校验 scaleGroupL1Size 是否为 0。原实现会分别校验 baseScaleASize/baseScaleBSize,当前改动删除了这层保护;一旦 scale dtype size 获取为 0,或者后续 MX 支持范围变化导致该路径进入异常 dtype,会在 host tiling 阶段触发除 0。建议恢复 divisor 校验:scaleGroupL1Size == 0 时通过 OP_TILING_CHECK 返回失败,并打印 baseM/baseN、scale dtype 等上下文。 ![]() ![]() | |||
| 309 | + (GetSizeWithDataType(baseM_, inputParams_.perTokenScaleDtype) + | ||
| 310 | + GetSizeWithDataType(baseN_, inputParams_.scaleDtype)) * | ||
| 311 | + qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; | ||
| 312 | + uint64_t maxScaleKL1ByL1 = leftL1Size / scaleGroupL1Size * qmmv3_tiling_const::MXFP_DIVISOR_SIZE; | ||
| 313 | + uint64_t maxScaleKL1 = ops::CeilAlign(inputParams_.kSize, kL1); | ||
| 314 | + uint64_t scaleKL1 = std::min(maxScaleKL1ByL1, maxScaleKL1); | ||
| 315 | + // Libapi scaleFactor is scaleKL1 / kL1, so scaleKL1 must be rounded down to a kL1 multiple. | ||
| 316 | + scaleKL1 = scaleKL1 / kL1 * kL1; | ||
| 317 | + | ||
| 318 | + OP_TILING_CHECK( | ||
| 319 | + scaleKL1 == 0UL, | ||
| 320 | + CUBE_INNER_ERR_REPORT( | ||
| 321 | + inputParams_.opName, "Insufficient L1 for MX scale buffer. leftL1Size(%lu), kL1(%lu).", leftL1Size, | ||
| 322 | + kL1), | ||
| 326 | return false); | 323 | return false); |
| 327 | 324 | ||
| 328 | - // Compute scaleFactorA/scaleFactorB from K-axis constraints first. | 325 | + uint64_t scaleFactor = scaleKL1 / kL1; |
| 329 | - uint64_t scaleFactorAMax = std::min(MTE2_MIN_LOAD_SIZE / baseScaleASize, static_cast<uint64_t>(SCALER_FACTOR_MAX)); | 326 | + l1TilingData_.scaleFactorA_ = scaleFactor; |
| 330 | - uint64_t scaleFactorBMax = std::min(MTE2_MIN_LOAD_SIZE / baseScaleBSize, static_cast<uint64_t>(SCALER_FACTOR_MAX)); | 327 | + l1TilingData_.scaleFactorB_ = scaleFactor; |
| 331 | - uint64_t scaleFactorA = inputParams_.kSize / (l1TilingData_.stepKa_ * baseK_); | ||
| 332 | - uint64_t scaleFactorB = inputParams_.kSize / (l1TilingData_.stepKb_ * baseK_); | ||
| 333 | - l1TilingData_.scaleFactorA_ = std::max(static_cast<uint64_t>(SCALER_FACTOR_MIN), scaleFactorA); | ||
| 334 | - l1TilingData_.scaleFactorB_ = std::max(static_cast<uint64_t>(SCALER_FACTOR_MIN), scaleFactorB); | ||
| 335 | - l1TilingData_.scaleFactorA_ = std::min(scaleFactorAMax, l1TilingData_.scaleFactorA_); | ||
| 336 | - l1TilingData_.scaleFactorB_ = std::min(scaleFactorBMax, l1TilingData_.scaleFactorB_); | ||
| 337 | - | ||
| 338 | - // Then apply the L1 size constraint. | ||
| 339 | - uint64_t usedASize = l1TilingData_.depthKa_ * baseASize; | ||
| 340 | - uint64_t usedBSize = l1TilingData_.depthKb_ * baseBSize; | ||
| 341 | - OP_TILING_CHECK( | ||
| 342 | - compileInfo_.l1Size < usedASize, | ||
| 343 | - CUBE_INNER_ERR_REPORT( | ||
| 344 | - inputParams_.opName, "Subtraction underflow: l1Size(%lu) - usedASize(%lu).", compileInfo_.l1Size, | ||
| 345 | - usedASize), | ||
| 346 | - return false); | ||
| 347 | - uint64_t leftL1Size = compileInfo_.l1Size - usedASize; | ||
| 348 | - OP_TILING_CHECK( | ||
| 349 | - leftL1Size < usedBSize, | ||
| 350 | - CUBE_INNER_ERR_REPORT( | ||
| 351 | - inputParams_.opName, "Subtraction underflow: leftL1Size(%lu) - usedBSize(%lu).", leftL1Size, usedBSize), | ||
| 352 | - return false); | ||
| 353 | - leftL1Size -= usedBSize; | ||
| 354 | - OP_TILING_CHECK( | ||
| 355 | - leftL1Size < baseBiasSize, | ||
| 356 | - CUBE_INNER_ERR_REPORT( | ||
| 357 | - inputParams_.opName, "Subtraction underflow: leftL1Size(%lu) - baseBiasSize(%lu).", leftL1Size, | ||
| 358 | - baseBiasSize), | ||
| 359 | - return false); | ||
| 360 | - leftL1Size -= baseBiasSize; | ||
| 361 | - uint64_t scaleADivisor = l1TilingData_.depthKa_ * baseScaleASize; | ||
| 362 | - uint64_t scaleBDivisor = l1TilingData_.depthKb_ * baseScaleBSize; | ||
| 363 | - uint64_t scaleInitDivisor = scaleADivisor + scaleBDivisor; | ||
| 364 | - uint64_t scaleInit = leftL1Size / scaleInitDivisor; | ||
| 365 | - if (l1TilingData_.scaleFactorA_ <= scaleInit && l1TilingData_.scaleFactorB_ > scaleInit) { | ||
| 366 | - uint64_t usedScaleASize = l1TilingData_.scaleFactorA_ * l1TilingData_.depthKa_ * baseScaleASize; | ||
| 367 | - leftL1Size -= usedScaleASize; | ||
| 368 | - l1TilingData_.scaleFactorB_ = std::min(leftL1Size / scaleBDivisor, l1TilingData_.scaleFactorB_); | ||
| 369 | - } else if (l1TilingData_.scaleFactorB_ <= scaleInit && l1TilingData_.scaleFactorA_ > scaleInit) { | ||
| 370 | - uint64_t usedScaleBSize = l1TilingData_.scaleFactorB_ * l1TilingData_.depthKb_ * baseScaleBSize; | ||
| 371 | - leftL1Size -= usedScaleBSize; | ||
| 372 | - l1TilingData_.scaleFactorA_ = std::min(leftL1Size / scaleADivisor, l1TilingData_.scaleFactorA_); | ||
| 373 | - } else if (l1TilingData_.scaleFactorA_ > scaleInit && l1TilingData_.scaleFactorB_ > scaleInit) { | ||
| 374 | - uint64_t usedScaleInitSize = | ||
| 375 | - scaleInit * l1TilingData_.depthKb_ * baseScaleBSize + scaleInit * l1TilingData_.depthKa_ * baseScaleASize; | ||
| 376 | - leftL1Size -= usedScaleInitSize; | ||
| 377 | - uint64_t scaleASec = std::min(leftL1Size / scaleADivisor, l1TilingData_.scaleFactorA_ - scaleInit); | ||
| 378 | - uint64_t scaleBSec = std::min(leftL1Size / scaleBDivisor, l1TilingData_.scaleFactorB_ - scaleInit); | ||
| 379 | - l1TilingData_.scaleFactorA_ = scaleASec >= scaleBSec ? scaleASec + scaleInit : scaleInit; | ||
| 380 | - l1TilingData_.scaleFactorB_ = scaleASec < scaleBSec ? scaleBSec + scaleInit : scaleInit; | ||
| 381 | - } | ||
| 382 | return true; | 328 | return true; |
| 383 | } | 329 | } |
| 384 | 330 | ||
| 385 | -uint64_t L1TilingDataCalculator::GetDepthA1B1(uint64_t leftSize, uint64_t perDepthSize, uint64_t depthInit) const | 331 | +uint64_t L1TilingDataCalculator::GetDepthA1B1() const |
| 386 | { | 332 | { |
| 387 | - if (perDepthSize == 0UL) { | 333 | + constexpr uint64_t INDEX = 2UL; |
| 388 | - return depthInit; | 334 | + uint64_t depth = 1UL; |
| 335 | + uint64_t scaleKL1 = std::min(inputParams_.kSize, qmmv3_tiling_const::ESTIMATED_SCALE_K); | ||
| 336 | + uint64_t baseABSize = GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype) + | ||
| 337 | + GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype); | ||
| 338 | + uint64_t baseScaleSize = GetSizeWithDataType(baseM_, inputParams_.perTokenScaleDtype) + | ||
| 339 | + GetSizeWithDataType(baseN_, inputParams_.scaleDtype); | ||
| 340 | + // Reserve a bounded scale window while searching depth. If depth later covers more K than the estimate, | ||
| 341 | + // scaleL1Size is raised accordingly before accepting that depth. | ||
| 342 | + uint64_t scaleL1Size = baseScaleSize * ops::CeilDiv(scaleKL1, qmmv3_tiling_const::MXFP_DIVISOR_SIZE) * | ||
| 343 | + qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; | ||
| 344 | + while (depth * baseABSize + scaleL1Size <= leftL1Size_) { | ||
| 345 | + depth *= INDEX; | ||
| 346 | + uint64_t kL1 = depth / qmmv3_tiling_const::DOUBLE_BUFFER_NUM * baseK_; | ||
| 347 | + if (kL1 > scaleKL1) { | ||
| 348 | + scaleKL1 = kL1; | ||
| 349 | + scaleL1Size = baseScaleSize * ops::CeilDiv(scaleKL1, qmmv3_tiling_const::MXFP_DIVISOR_SIZE) * | ||
| 350 | + qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; | ||
| 351 | + } | ||
| 389 | } | 352 | } |
| 390 | - if (depthInit > 1UL && perDepthSize > DB_SIZE * MTE2_MIN_LOAD_SIZE) { | 353 | + return depth == 1UL ? depth : depth / INDEX; |
| 391 | - return depthInit; | ||
| 392 | - } | ||
| 393 | - uint64_t depthScale = leftSize / perDepthSize; | ||
| 394 | - if (depthInit > 1UL) { | ||
| 395 | - uint64_t baseKSize = GetSizeWithDataType(baseK_, inputParams_.aDtype); | ||
| 396 | - if (baseKSize == 0UL) { | ||
| 397 | - return depthInit; | ||
| 398 | - } | ||
| 399 | - while ((depthScale * baseKSize) % BASIC_BLOCK_SIZE_512 != 0UL && | ||
| 400 | - (depthScale * baseKSize) > BASIC_BLOCK_SIZE_512) { | ||
| 401 | - depthScale -= 1UL; | ||
| 402 | - } | ||
| 403 | - if ((depthScale * baseKSize) % BASIC_BLOCK_SIZE_512 != 0UL && | ||
| 404 | - (depthScale * baseKSize) >= BASIC_BLOCK_SIZE_256) { | ||
| 405 | - depthScale = BASIC_BLOCK_SIZE_256 / baseKSize; | ||
| 406 | - } | ||
| 407 | - depthScale = std::max(depthScale, 1UL); | ||
| 408 | - } else { | ||
| 409 | - // Depth grows by powers of two. | ||
| 410 | - constexpr uint64_t INDEX = 2UL; | ||
| 411 | - depthScale = 1UL; | ||
| 412 | - while (depthScale * perDepthSize < leftSize) { | ||
| 413 | - depthScale *= INDEX; | ||
| 414 | - } | ||
| 415 | - depthScale = depthScale == 1UL ? depthScale : depthScale / INDEX; | ||
| 416 | - } | ||
| 417 | - return depthInit * depthScale; | ||
| 418 | } | 354 | } |
| 419 | 355 | ||
| 420 | uint64_t L1TilingDataCalculator::GetDepthB1AfullLoad(uint64_t leftSize) const | 356 | uint64_t L1TilingDataCalculator::GetDepthB1AfullLoad(uint64_t leftSize) const |
| @@ -423,23 +359,23 @@ uint64_t L1TilingDataCalculator::GetDepthB1AfullLoad(uint64_t leftSize) const | |||
| 423 | uint64_t stepKbBase = 1UL; | 359 | uint64_t stepKbBase = 1UL; |
| 424 | if (inputParams_.transB) { | 360 | if (inputParams_.transB) { |
| 425 | uint64_t singleBaseKSize = GetSizeWithDataType(baseK_, inputParams_.bDtype); | 361 | uint64_t singleBaseKSize = GetSizeWithDataType(baseK_, inputParams_.bDtype); |
| 426 | - if (singleBaseKSize != 0UL && singleBaseKSize < L2_ALIGN_SIZE) { | 362 | + if (singleBaseKSize != 0UL && singleBaseKSize < qmmv3_tiling_const::L2_ALIGN_SIZE) { |
| 427 | - stepKbBase = ops::CeilDiv(L2_ALIGN_SIZE, singleBaseKSize); | 363 | + stepKbBase = ops::CeilDiv(qmmv3_tiling_const::L2_ALIGN_SIZE, singleBaseKSize); |
| 428 | } | 364 | } |
| 429 | } | 365 | } |
| 430 | 366 | ||
| 431 | // Keep single-copy size at least 32KB without exceeding L1. | 367 | // Keep single-copy size at least 32KB without exceeding L1. |
| 432 | uint64_t scaleBBaseK = | 368 | uint64_t scaleBBaseK = |
| 433 | - inputParams_.isMxPerGroup ? ops::CeilAlign(ops::CeilDiv(baseK_, MX_GROUP_SIZE), MXFP_MULTI_BASE_SIZE) : 0UL; | 369 | + inputParams_.isMxPerGroup ? ops::CeilAlign(ops::CeilDiv(baseK_, qmmv3_tiling_const::MX_GROUP_SIZE), qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE) : 0UL; |
| 434 | uint64_t baseBSize = GetSizeWithDataType(baseN_ * (baseK_ + scaleBBaseK) * stepKbBase, inputParams_.bDtype); | 370 | uint64_t baseBSize = GetSizeWithDataType(baseN_ * (baseK_ + scaleBBaseK) * stepKbBase, inputParams_.bDtype); |
| 435 | if (baseBSize == 0UL) { | 371 | if (baseBSize == 0UL) { |
| 436 | - return DB_SIZE; | 372 | + return qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 437 | } | 373 | } |
| 438 | uint64_t stepKbBaseScale = 1UL; | 374 | uint64_t stepKbBaseScale = 1UL; |
| 439 | - if (leftSize >= MTE2_MIN_LOAD_SIZE * DB_SIZE) { | 375 | + if (leftSize >= MTE2_MIN_LOAD_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM) { |
| 440 | stepKbBaseScale = ops::CeilDiv(MTE2_MIN_LOAD_SIZE, baseBSize); | 376 | stepKbBaseScale = ops::CeilDiv(MTE2_MIN_LOAD_SIZE, baseBSize); |
| 441 | } else { | 377 | } else { |
| 442 | - stepKbBaseScale = ops::CeilDiv(leftSize / DB_SIZE, baseBSize); | 378 | + stepKbBaseScale = ops::CeilDiv(leftSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM, baseBSize); |
| 443 | } | 379 | } |
| 444 | stepKbBase *= stepKbBaseScale; | 380 | stepKbBase *= stepKbBaseScale; |
| 445 | 381 | ||
| @@ -448,7 +384,7 @@ uint64_t L1TilingDataCalculator::GetDepthB1AfullLoad(uint64_t leftSize) const | |||
| 448 | if (stepKbBase == 1UL && inputParams_.kSize > baseK_ && leftSize > baseBSize * refinedStepKb) { | 384 | if (stepKbBase == 1UL && inputParams_.kSize > baseK_ && leftSize > baseBSize * refinedStepKb) { |
| 449 | stepKbBase = refinedStepKb; | 385 | stepKbBase = refinedStepKb; |
| 450 | } | 386 | } |
| 451 | - return stepKbBase * DB_SIZE; | 387 | + return stepKbBase * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 452 | } | 388 | } |
| 453 | 389 | ||
| 454 | uint64_t L1TilingDataCalculator::GetDepthA1BfullLoad(uint64_t leftSize) const | 390 | uint64_t L1TilingDataCalculator::GetDepthA1BfullLoad(uint64_t leftSize) const |
| @@ -457,20 +393,20 @@ uint64_t L1TilingDataCalculator::GetDepthA1BfullLoad(uint64_t leftSize) const | |||
| 457 | uint64_t stepKaBase = 1UL; | 393 | uint64_t stepKaBase = 1UL; |
| 458 | if (!inputParams_.transA) { | 394 | if (!inputParams_.transA) { |
| 459 | uint64_t singleBaseKSize = GetSizeWithDataType(baseK_, inputParams_.aDtype); | 395 | uint64_t singleBaseKSize = GetSizeWithDataType(baseK_, inputParams_.aDtype); |
| 460 | - if (singleBaseKSize != 0UL && singleBaseKSize < L2_ALIGN_SIZE) { | 396 | + if (singleBaseKSize != 0UL && singleBaseKSize < qmmv3_tiling_const::L2_ALIGN_SIZE) { |
| 461 | - stepKaBase = ops::CeilDiv(L2_ALIGN_SIZE, singleBaseKSize); | 397 | + stepKaBase = ops::CeilDiv(qmmv3_tiling_const::L2_ALIGN_SIZE, singleBaseKSize); |
| 462 | } | 398 | } |
| 463 | } | 399 | } |
| 464 | 400 | ||
| 465 | uint64_t baseASize = GetSizeWithDataType(baseM_ * baseK_ * stepKaBase, inputParams_.aDtype); | 401 | uint64_t baseASize = GetSizeWithDataType(baseM_ * baseK_ * stepKaBase, inputParams_.aDtype); |
| 466 | if (baseASize == 0UL) { | 402 | if (baseASize == 0UL) { |
| 467 | - return DB_SIZE; | 403 | + return qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 468 | } | 404 | } |
| 469 | uint64_t stepKaBaseScale = 1UL; | 405 | uint64_t stepKaBaseScale = 1UL; |
| 470 | - if (leftSize >= MTE2_MIN_LOAD_SIZE * DB_SIZE) { | 406 | + if (leftSize >= MTE2_MIN_LOAD_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM) { |
| 471 | stepKaBaseScale = ops::CeilDiv(MTE2_MIN_LOAD_SIZE, baseASize); | 407 | stepKaBaseScale = ops::CeilDiv(MTE2_MIN_LOAD_SIZE, baseASize); |
| 472 | } else { | 408 | } else { |
| 473 | - stepKaBaseScale = ops::CeilDiv(leftSize / DB_SIZE, baseASize); | 409 | + stepKaBaseScale = ops::CeilDiv(leftSize / qmmv3_tiling_const::DOUBLE_BUFFER_NUM, baseASize); |
| 474 | } | 410 | } |
| 475 | stepKaBase *= stepKaBaseScale; | 411 | stepKaBase *= stepKaBaseScale; |
| 476 | 412 | ||
| @@ -478,12 +414,12 @@ uint64_t L1TilingDataCalculator::GetDepthA1BfullLoad(uint64_t leftSize) const | |||
| 478 | if (stepKaBase == 1UL && inputParams_.kSize > baseK_ && leftSize > baseASize * refinedStepKa) { | 414 | if (stepKaBase == 1UL && inputParams_.kSize > baseK_ && leftSize > baseASize * refinedStepKa) { |
| 479 | stepKaBase = refinedStepKa; | 415 | stepKaBase = refinedStepKa; |
| 480 | } | 416 | } |
| 481 | - return stepKaBase * DB_SIZE; | 417 | + return stepKaBase * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 482 | } | 418 | } |
| 483 | 419 | ||
| 484 | uint64_t L1TilingDataCalculator::GetScaleFactorBAfullLoad(uint64_t leftSize) const | 420 | uint64_t L1TilingDataCalculator::GetScaleFactorBAfullLoad(uint64_t leftSize) const |
| 485 | { | 421 | { |
| 486 | - uint64_t scaleBaseK = ops::CeilAlign(ops::CeilDiv(baseK_, MX_GROUP_SIZE), MXFP_MULTI_BASE_SIZE); | 422 | + uint64_t scaleBaseK = ops::CeilAlign(ops::CeilDiv(baseK_, qmmv3_tiling_const::MX_GROUP_SIZE), qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE); |
| 487 | uint64_t baseScaleBSize = GetSizeWithDataType(baseN_ * scaleBaseK, inputParams_.scaleDtype); | 423 | uint64_t baseScaleBSize = GetSizeWithDataType(baseN_ * scaleBaseK, inputParams_.scaleDtype); |
| 488 | if (baseScaleBSize == 0UL || l1TilingData_.stepKb_ == 0UL || l1TilingData_.depthKb_ == 0UL) { | 424 | if (baseScaleBSize == 0UL || l1TilingData_.stepKb_ == 0UL || l1TilingData_.depthKb_ == 0UL) { |
| 489 | return 1UL; | 425 | return 1UL; |
| @@ -493,18 +429,18 @@ uint64_t L1TilingDataCalculator::GetScaleFactorBAfullLoad(uint64_t leftSize) con | |||
| 493 | if (inputParams_.transB) { | 429 | if (inputParams_.transB) { |
| 494 | // K is the inner axis. | 430 | // K is the inner axis. |
| 495 | uint64_t singleScaleBBaseKSize = GetSizeWithDataType(scaleBaseK, inputParams_.scaleDtype); | 431 | uint64_t singleScaleBBaseKSize = GetSizeWithDataType(scaleBaseK, inputParams_.scaleDtype); |
| 496 | - if (singleScaleBBaseKSize != 0UL && singleScaleBBaseKSize < L2_ALIGN_SIZE) { | 432 | + if (singleScaleBBaseKSize != 0UL && singleScaleBBaseKSize < qmmv3_tiling_const::L2_ALIGN_SIZE) { |
| 497 | - scaleFactorBBase = ops::CeilDiv(L2_ALIGN_SIZE, singleScaleBBaseKSize); | 433 | + scaleFactorBBase = ops::CeilDiv(qmmv3_tiling_const::L2_ALIGN_SIZE, singleScaleBBaseKSize); |
| 498 | } | 434 | } |
| 499 | } | 435 | } |
| 500 | 436 | ||
| 501 | uint64_t scaleFactorBMaxFromK = inputParams_.kSize / (l1TilingData_.stepKb_ * baseK_); | 437 | uint64_t scaleFactorBMaxFromK = inputParams_.kSize / (l1TilingData_.stepKb_ * baseK_); |
| 502 | - scaleFactorBMaxFromK = std::min(static_cast<uint64_t>(SCALER_FACTOR_MAX), scaleFactorBMaxFromK); | 438 | + scaleFactorBMaxFromK = std::min(static_cast<uint64_t>(qmmv3_tiling_const::SCALER_FACTOR_MAX), scaleFactorBMaxFromK); |
| 503 | - scaleFactorBMaxFromK = std::max(static_cast<uint64_t>(SCALER_FACTOR_MIN), scaleFactorBMaxFromK); | 439 | + scaleFactorBMaxFromK = std::max(static_cast<uint64_t>(qmmv3_tiling_const::SCALER_FACTOR_MIN), scaleFactorBMaxFromK); |
| 504 | 440 | ||
| 505 | uint64_t scaleFactorB = 1UL; | 441 | uint64_t scaleFactorB = 1UL; |
| 506 | uint64_t scaleFactorBMax = | 442 | uint64_t scaleFactorBMax = |
| 507 | - std::min(MTE2_MIN_LOAD_SIZE * DB_SIZE, leftSize) / (baseScaleBSize * l1TilingData_.depthKb_); | 443 | + std::min(MTE2_MIN_LOAD_SIZE * qmmv3_tiling_const::DOUBLE_BUFFER_NUM, leftSize) / (baseScaleBSize * l1TilingData_.depthKb_); |
| 508 | if (scaleFactorBMax != 0UL) { | 444 | if (scaleFactorBMax != 0UL) { |
| 509 | if (scaleFactorBBase <= scaleFactorBMaxFromK && scaleFactorBMax >= scaleFactorBBase) { | 445 | if (scaleFactorBBase <= scaleFactorBMaxFromK && scaleFactorBMax >= scaleFactorBBase) { |
| 510 | // Keep 128B inner-axis alignment while meeting 32KB copy size and L1 limits. | 446 | // Keep 128B inner-axis alignment while meeting 32KB copy size and L1 limits. |
| @@ -533,9 +469,9 @@ bool L1TilingDataCalculator::ComputeL1TilingMmadS8S4() | |||
| 533 | PostCacheLinePass(leftL1Size_, maxStepK); | 469 | PostCacheLinePass(leftL1Size_, maxStepK); |
| 534 | 470 | ||
| 535 | l1TilingData_.stepKa_ = isAFullLoad_ ? 1UL : l1TilingData_.stepKa_; | 471 | l1TilingData_.stepKa_ = isAFullLoad_ ? 1UL : l1TilingData_.stepKa_; |
| 536 | - l1TilingData_.depthKa_ = isAFullLoad_ ? l1TilingData_.stepKa_ : l1TilingData_.stepKa_ * DB_SIZE; | 472 | + l1TilingData_.depthKa_ = isAFullLoad_ ? l1TilingData_.stepKa_ : l1TilingData_.stepKa_ * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 537 | l1TilingData_.stepKb_ = isBFullLoad_ ? 1UL : l1TilingData_.stepKb_; | 473 | l1TilingData_.stepKb_ = isBFullLoad_ ? 1UL : l1TilingData_.stepKb_; |
| 538 | - l1TilingData_.depthKb_ = isBFullLoad_ ? l1TilingData_.stepKb_ : l1TilingData_.stepKb_ * DB_SIZE; | 474 | + l1TilingData_.depthKb_ = isBFullLoad_ ? l1TilingData_.stepKb_ : l1TilingData_.stepKb_ * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 539 | return true; | 475 | return true; |
| 540 | } | 476 | } |
| 541 | 477 | ||
| @@ -571,24 +507,36 @@ bool L1TilingDataCalculator::ComputeL1TilingMmadS8S4LUT() | |||
| 571 | 507 | ||
| 572 | uint64_t L1TilingDataCalculator::GetSingleCoreAFullLoadSize() const | 508 | uint64_t L1TilingDataCalculator::GetSingleCoreAFullLoadSize() const |
| 573 | { | 509 | { |
| 510 | + if (inputParams_.isMxPerGroup) { | ||
| 511 | + // MX kernels consume K in 64-element groups; scale bytes are reserved separately. | ||
| 512 | + return GetSizeWithDataType(baseM_ * ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE), | ||
| 513 | + inputParams_.aDtype); | ||
| 514 | + } | ||
| 574 | return baseM_ * | 515 | return baseM_ * |
| 575 | (inputParams_.transA ? | 516 | (inputParams_.transA ? |
| 576 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.aDtype) : | 517 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.aDtype) : |
| 577 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), CUBE_REDUCE_BLOCK)); | 518 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.aDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK)); |
| 578 | } | 519 | } |
| 579 | 520 | ||
| 580 | uint64_t L1TilingDataCalculator::GetSingleCoreBFullLoadSize() const | 521 | uint64_t L1TilingDataCalculator::GetSingleCoreBFullLoadSize() const |
| 581 | { | 522 | { |
| 523 | + if (inputParams_.isMxPerGroup) { | ||
| 524 | + // MX kernels consume K in 64-element groups; scale bytes are reserved separately. | ||
| 525 | + return GetSizeWithDataType(baseN_ * ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE), | ||
| 526 | + inputParams_.bDtype); | ||
| 527 | + } | ||
| 582 | return baseN_ * | 528 | return baseN_ * |
| 583 | (inputParams_.transB ? | 529 | (inputParams_.transB ? |
| 584 | - ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), CUBE_REDUCE_BLOCK) : | 530 | + ops::CeilAlign(GetSizeWithDataType(inputParams_.kSize, inputParams_.bDtype), qmmv3_tiling_const::CUBE_REDUCE_BLOCK) : |
| 585 | - GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, CUBE_BLOCK), inputParams_.bDtype)); | 531 | + GetSizeWithDataType(ops::CeilAlign(inputParams_.kSize, qmmv3_tiling_const::CUBE_BLOCK), inputParams_.bDtype)); |
| 586 | } | 532 | } |
| 587 | 533 | ||
| 588 | bool L1TilingDataCalculator::CheckL1Size(uint64_t leftL1Size, uint64_t tempStepKa, uint64_t tempStepKb) const | 534 | bool L1TilingDataCalculator::CheckL1Size(uint64_t leftL1Size, uint64_t tempStepKa, uint64_t tempStepKb) const |
| 589 | { | 535 | { |
| 590 | - uint64_t singleCoreASize = tempStepKa * GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype) * DB_SIZE; | 536 | + uint64_t singleCoreASize = |
| 591 | - uint64_t singleCoreBSize = tempStepKb * GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype) * DB_SIZE; | 537 | + tempStepKa * GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype) * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 538 | + uint64_t singleCoreBSize = | ||
| 539 | + tempStepKb * GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype) * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; | ||
| 592 | 540 | ||
| 593 | if (isAFullLoad_) { | 541 | if (isAFullLoad_) { |
| 594 | singleCoreASize = GetSingleCoreAFullLoadSize(); | 542 | singleCoreASize = GetSingleCoreAFullLoadSize(); |
| @@ -601,8 +549,8 @@ bool L1TilingDataCalculator::CheckL1Size(uint64_t leftL1Size, uint64_t tempStepK | |||
| 601 | void L1TilingDataCalculator::AdjustStepK( | 549 | void L1TilingDataCalculator::AdjustStepK( |
| 602 | uint64_t leftL1Size, uint64_t& tempStepKa, uint64_t& tempStepKb, bool isStepKa) const | 550 | uint64_t leftL1Size, uint64_t& tempStepKa, uint64_t& tempStepKb, bool isStepKa) const |
| 603 | { | 551 | { |
| 604 | - uint64_t oneBaseADataSize = GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype) * DB_SIZE; | 552 | + uint64_t oneBaseADataSize = GetSizeWithDataType(baseM_ * baseK_, inputParams_.aDtype) * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 605 | - uint64_t oneBaseBDataSize = GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype) * DB_SIZE; | 553 | + uint64_t oneBaseBDataSize = GetSizeWithDataType(baseN_ * baseK_, inputParams_.bDtype) * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 606 | if (isStepKa) { | 554 | if (isStepKa) { |
| 607 | uint64_t singleCoreBSize = tempStepKb * oneBaseBDataSize; | 555 | uint64_t singleCoreBSize = tempStepKb * oneBaseBDataSize; |
| 608 | if (isBFullLoad_) { | 556 | if (isBFullLoad_) { |
| @@ -694,7 +642,7 @@ void L1TilingDataCalculator::L1FullLoadCacheLinePass( | |||
| 694 | OP_LOGE(inputParams_.opName, "Invalid aCacheLine or bCacheLine."); | 642 | OP_LOGE(inputParams_.opName, "Invalid aCacheLine or bCacheLine."); |
| 695 | return; | 643 | return; |
| 696 | } | 644 | } |
| 697 | - uint32_t maxStepKWithSmallCase = 4U * DB_SIZE; | 645 | + uint32_t maxStepKWithSmallCase = 4U * qmmv3_tiling_const::DOUBLE_BUFFER_NUM; |
| 698 | if (ops::CeilDiv(inputParams_.kSize, baseK_) < maxStepKWithSmallCase) { | 646 | if (ops::CeilDiv(inputParams_.kSize, baseK_) < maxStepKWithSmallCase) { |
| 699 | return; | 647 | return; |
| 700 | } | 648 | } |
| @@ -61,8 +61,8 @@ private: | |||
| 61 | bool ComputeL1TilingMmadS8S4(); | 61 | bool ComputeL1TilingMmadS8S4(); |
| 62 | bool ComputeL1TilingMmadS8S4LUT(); | 62 | bool ComputeL1TilingMmadS8S4LUT(); |
| 63 | bool CalStepKs(); | 63 | bool CalStepKs(); |
| 64 | - bool CalScaleFactors(uint64_t baseASize, uint64_t baseBSize, uint64_t baseScaleASize, uint64_t baseScaleBSize); | 64 | + bool CalScaleFactors(uint64_t baseASize, uint64_t baseBSize); |
| 65 | - uint64_t GetDepthA1B1(uint64_t leftSize, uint64_t perDepthSize, uint64_t depthInit) const; | 65 | + uint64_t GetDepthA1B1() const; |
| 66 | uint64_t GetDepthB1AfullLoad(uint64_t leftSize) const; | 66 | uint64_t GetDepthB1AfullLoad(uint64_t leftSize) const; |
| 67 | uint64_t GetDepthA1BfullLoad(uint64_t leftSize) const; | 67 | uint64_t GetDepthA1BfullLoad(uint64_t leftSize) const; |
| 68 | uint64_t GetScaleFactorBAfullLoad(uint64_t leftSize) const; | 68 | uint64_t GetScaleFactorBAfullLoad(uint64_t leftSize) const; |
| @@ -17,13 +17,10 @@ | |||
| 17 | #include "log/log.h" | 17 | #include "log/log.h" |
| 18 | #include "matmul/common/op_host/log_format_util.h" | 18 | #include "matmul/common/op_host/log_format_util.h" |
| 19 | #include "quant_batch_matmul_v3_checker.h" | 19 | #include "quant_batch_matmul_v3_checker.h" |
| 20 | +#include "quant_batch_matmul_v3_tiling_util.h" | ||
| 20 | #include "error_util.h" | 21 | #include "error_util.h" |
| 21 | 22 | ||
| 22 | namespace { | 23 | namespace { |
| 23 | -constexpr uint64_t MX_GROUP_SIZE = 32UL; | ||
| 24 | -constexpr uint64_t MXFP_DIVISOR_SIZE = 64UL; | ||
| 25 | -constexpr uint64_t MXFP_MULTI_BASE_SIZE = 2UL; | ||
| 26 | -constexpr uint64_t PER_BLOCK_SIZE = 128UL; | ||
| 27 | constexpr size_t LAST_FIRST_DIM_INDEX = 1; | 24 | constexpr size_t LAST_FIRST_DIM_INDEX = 1; |
| 28 | constexpr size_t DIM_NUM_TWO = 2; | 25 | constexpr size_t DIM_NUM_TWO = 2; |
| 29 | constexpr size_t SCALE_THREE_DIM = 3; | 26 | constexpr size_t SCALE_THREE_DIM = 3; |
| @@ -553,17 +550,17 @@ bool QuantBatchMatmulV3Checker::CheckInputValidInPerblockMode(const gert::Shape& | |||
| 553 | 550 | ||
| 554 | bool QuantBatchMatmulV3Checker::CheckGroupValidInPerblockMode() const | 551 | bool QuantBatchMatmulV3Checker::CheckGroupValidInPerblockMode() const |
| 555 | { | 552 | { |
| 556 | - OP_TILING_CHECK(inputParams_.groupSizeM != PER_BLOCK_SIZE && inputParams_.groupSizeM != 1UL, | 553 | + OP_TILING_CHECK(inputParams_.groupSizeM != qmmv3_tiling_const::PER_BLOCK_SIZE && inputParams_.groupSizeM != 1UL, |
| 557 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 554 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 558 | inputParams_.opName, "groupSizeM", std::to_string(inputParams_.groupSizeM).c_str(), | 555 | inputParams_.opName, "groupSizeM", std::to_string(inputParams_.groupSizeM).c_str(), |
| 559 | "when the quantization mode is G-B or B-B, input or inferred groupSizeM must be 128 or 1, groupSizeM = (groupSize >> 32) & 0xFFFF"), | 556 | "when the quantization mode is G-B or B-B, input or inferred groupSizeM must be 128 or 1, groupSizeM = (groupSize >> 32) & 0xFFFF"), |
| 560 | return false); | 557 | return false); |
| 561 | - OP_TILING_CHECK(inputParams_.groupSizeK != PER_BLOCK_SIZE, | 558 | + OP_TILING_CHECK(inputParams_.groupSizeK != qmmv3_tiling_const::PER_BLOCK_SIZE, |
| 562 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 559 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 563 | inputParams_.opName, "groupSizeK", std::to_string(inputParams_.groupSizeK).c_str(), | 560 | inputParams_.opName, "groupSizeK", std::to_string(inputParams_.groupSizeK).c_str(), |
| 564 | "when the quantization mode is G-B or B-B, input or inferred groupSizeK must be 128, groupSizeK = groupSize & 0xFFFF"), | 561 | "when the quantization mode is G-B or B-B, input or inferred groupSizeK must be 128, groupSizeK = groupSize & 0xFFFF"), |
| 565 | return false); | 562 | return false); |
| 566 | - OP_TILING_CHECK(inputParams_.groupSizeN != PER_BLOCK_SIZE, | 563 | + OP_TILING_CHECK(inputParams_.groupSizeN != qmmv3_tiling_const::PER_BLOCK_SIZE, |
| 567 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 564 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 568 | inputParams_.opName, "groupSizeN", std::to_string(inputParams_.groupSizeN).c_str(), | 565 | inputParams_.opName, "groupSizeN", std::to_string(inputParams_.groupSizeN).c_str(), |
| 569 | "when the quantization mode is G-B or B-B, input or inferred groupSizeN must be 128, groupSizeN = (groupSize >> 16) & 0xFFFF"), | 566 | "when the quantization mode is G-B or B-B, input or inferred groupSizeN must be 128, groupSizeN = (groupSize >> 16) & 0xFFFF"), |
| @@ -578,9 +575,9 @@ bool QuantBatchMatmulV3Checker::CheckShapeValidInPerblockMode(const gert::Shape& | |||
| 578 | auto x1ShapeLen = x1Shape.GetDimNum(); | 575 | auto x1ShapeLen = x1Shape.GetDimNum(); |
| 579 | auto x2ShapeLen = x2Shape.GetDimNum(); | 576 | auto x2ShapeLen = x2Shape.GetDimNum(); |
| 580 | OP_TILING_CHECK( | 577 | OP_TILING_CHECK( |
| 581 | - (ops::CeilDiv(static_cast<uint64_t>(x2Shape.GetDim(x2ShapeLen - 2)), PER_BLOCK_SIZE) != | 578 | + (ops::CeilDiv(static_cast<uint64_t>(x2Shape.GetDim(x2ShapeLen - 2)), qmmv3_tiling_const::PER_BLOCK_SIZE) != |
| 582 | static_cast<uint64_t>(scaleShape.GetDim(x2ShapeLen - 2)) || | 579 | static_cast<uint64_t>(scaleShape.GetDim(x2ShapeLen - 2)) || |
| 583 | - ops::CeilDiv(static_cast<uint64_t>(x2Shape.GetDim(x2ShapeLen - 1)), PER_BLOCK_SIZE) != | 580 | + ops::CeilDiv(static_cast<uint64_t>(x2Shape.GetDim(x2ShapeLen - 1)), qmmv3_tiling_const::PER_BLOCK_SIZE) != |
| 584 | static_cast<uint64_t>(scaleShape.GetDim(x2ShapeLen - 1))), | 581 | static_cast<uint64_t>(scaleShape.GetDim(x2ShapeLen - 1))), |
| 585 | OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( | 582 | OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( |
| 586 | inputParams_.opName, "scale, x2", | 583 | inputParams_.opName, "scale, x2", |
| @@ -672,7 +669,7 @@ bool QuantBatchMatmulV3Checker::MxPertokenScaleShapeCheck(const gert::StorageSha | |||
| 672 | auto mDimIdx = inputParams_.transA ? 1 : 0; | 669 | auto mDimIdx = inputParams_.transA ? 1 : 0; |
| 673 | auto kDimIdx = inputParams_.transA ? 0 : 1; | 670 | auto kDimIdx = inputParams_.transA ? 0 : 1; |
| 674 | OP_TILING_CHECK( | 671 | OP_TILING_CHECK( |
| 675 | - static_cast<uint64_t>(pertoken.GetDim(kDimIdx)) != ops::CeilDiv(inputParams_.kSize, MXFP_DIVISOR_SIZE), | 672 | + static_cast<uint64_t>(pertoken.GetDim(kDimIdx)) != ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE), |
| 676 | OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( | 673 | OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( |
| 677 | inputParams_.opName, "x1K, pertokenScaleK", | 674 | inputParams_.opName, "x1K, pertokenScaleK", |
| 678 | FormatString("%lu, %ld", inputParams_.kSize, pertoken.GetDim(kDimIdx)).c_str(), | 675 | FormatString("%lu, %ld", inputParams_.kSize, pertoken.GetDim(kDimIdx)).c_str(), |
| @@ -684,7 +681,7 @@ bool QuantBatchMatmulV3Checker::MxPertokenScaleShapeCheck(const gert::StorageSha | |||
| 684 | FormatString("%lu, %ld", inputParams_.mSize, pertoken.GetDim(mDimIdx)).c_str(), | 681 | FormatString("%lu, %ld", inputParams_.mSize, pertoken.GetDim(mDimIdx)).c_str(), |
| 685 | "when the quantization mode is mx, the m dimension of pertokenScale must be equal to the m dimension size of x1"), | 682 | "when the quantization mode is mx, the m dimension of pertokenScale must be equal to the m dimension size of x1"), |
| 686 | return false); | 683 | return false); |
| 687 | - OP_TILING_CHECK(static_cast<uint64_t>(pertoken.GetDim(pertokenShapeLen - 1)) != MXFP_MULTI_BASE_SIZE, | 684 | + OP_TILING_CHECK(static_cast<uint64_t>(pertoken.GetDim(pertokenShapeLen - 1)) != qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE, |
| 688 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 685 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 689 | inputParams_.opName, "pertokenScale last dimension", | 686 | inputParams_.opName, "pertokenScale last dimension", |
| 690 | std::to_string(pertoken.GetDim(pertokenShapeLen - 1)).c_str(), | 687 | std::to_string(pertoken.GetDim(pertokenShapeLen - 1)).c_str(), |
| @@ -704,13 +701,21 @@ bool QuantBatchMatmulV3Checker::MxScaleShapeCheck(const gert::Shape &scaleShape) | |||
| 704 | return false); | 701 | return false); |
| 705 | auto kDimIdx = inputParams_.transB ? 1 : 0; | 702 | auto kDimIdx = inputParams_.transB ? 1 : 0; |
| 706 | auto nDimIdx = inputParams_.transB ? 0 : 1; | 703 | auto nDimIdx = inputParams_.transB ? 0 : 1; |
| 707 | -bool nDimHasOne = (scaleShape.GetDim(kDimIdx) == 1 && static_cast<uint64_t>(scaleShape.GetDim(nDimIdx)) == ops::CeilDiv(inputParams_.kSize, MXFP_DIVISOR_SIZE)) || | 704 | + bool nDimHasOne = |
| 708 | - (scaleShape.GetDim(nDimIdx) == 1 && static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) == ops::CeilDiv(inputParams_.kSize, MXFP_DIVISOR_SIZE)); | 705 | + (scaleShape.GetDim(kDimIdx) == 1 && |
| 709 | - bool kDimHasOne = (scaleShape.GetDim(kDimIdx) == 1 && static_cast<uint64_t>(scaleShape.GetDim(nDimIdx)) == inputParams_.nSize) || | 706 | + static_cast<uint64_t>(scaleShape.GetDim(nDimIdx)) == |
| 710 | - (scaleShape.GetDim(nDimIdx) == 1 && static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) == inputParams_.nSize); | 707 | + ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE)) || |
| 708 | + (scaleShape.GetDim(nDimIdx) == 1 && | ||
| 709 | + static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) == | ||
| 710 | + ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE)); | ||
| 711 | + bool kDimHasOne = | ||
| 712 | + (scaleShape.GetDim(kDimIdx) == 1 && | ||
| 713 | + static_cast<uint64_t>(scaleShape.GetDim(nDimIdx)) == inputParams_.nSize) || | ||
| 714 | + (scaleShape.GetDim(nDimIdx) == 1 && | ||
| 715 | + static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) == inputParams_.nSize); | ||
| 711 | if(!nDimHasOne && !kDimHasOne){ | 716 | if(!nDimHasOne && !kDimHasOne){ |
| 712 | OP_TILING_CHECK( | 717 | OP_TILING_CHECK( |
| 713 | - static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) != ops::CeilDiv(inputParams_.kSize, MXFP_DIVISOR_SIZE), | 718 | + static_cast<uint64_t>(scaleShape.GetDim(kDimIdx)) != ops::CeilDiv(inputParams_.kSize, qmmv3_tiling_const::MXFP_DIVISOR_SIZE), |
| 714 | OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( | 719 | OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( |
| 715 | inputParams_.opName, "x2K, scaleK", | 720 | inputParams_.opName, "x2K, scaleK", |
| 716 | FormatString("%lu, %ld", inputParams_.kSize, scaleShape.GetDim(kDimIdx)).c_str(), | 721 | FormatString("%lu, %ld", inputParams_.kSize, scaleShape.GetDim(kDimIdx)).c_str(), |
| @@ -723,7 +728,7 @@ bool nDimHasOne = (scaleShape.GetDim(kDimIdx) == 1 && static_cast<uint64_t>(scal | |||
| 723 | "when the quantization mode is mx, the n dimension of scale must be equal to the n dimension size of x2"), | 728 | "when the quantization mode is mx, the n dimension of scale must be equal to the n dimension size of x2"), |
| 724 | return false); | 729 | return false); |
| 725 | } | 730 | } |
| 726 | - OP_TILING_CHECK(static_cast<uint64_t>(scaleShape.GetDim(scaleShapeLen - 1)) != MXFP_MULTI_BASE_SIZE, | 731 | + OP_TILING_CHECK(static_cast<uint64_t>(scaleShape.GetDim(scaleShapeLen - 1)) != qmmv3_tiling_const::MXFP_MULTI_BASE_SIZE, |
| 727 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 732 | OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 728 | inputParams_.opName, "scale dimension 2", | 733 | inputParams_.opName, "scale dimension 2", |
| 729 | std::to_string(scaleShape.GetDim(scaleShapeLen - 1)).c_str(), | 734 | std::to_string(scaleShape.GetDim(scaleShapeLen - 1)).c_str(), |
Mmatmul/quant_batch_matmul_v3/op_host/op_tiling/arch35/quant_batch_matmul_v3_iterbatch_tiling.cpp+14-24
| @@ -28,16 +28,6 @@ using namespace QuantBatchMatmulV3Arch35TilingKey; | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | namespace { | 30 | namespace { |
| 31 | -constexpr uint64_t CUBE_BLOCK = 16; | ||
| 32 | -constexpr uint64_t L1_ALIGN_SIZE = 32; | ||
| 33 | -constexpr uint64_t CUBE_REDUCE_BLOCK = 32; | ||
| 34 | -constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 35 | -constexpr uint64_t BASIC_BLOCK_SIZE_256 = 256UL; | ||
| 36 | -constexpr uint64_t BASIC_BLOCK_SIZE_512 = 512UL; | ||
| 37 | -constexpr uint64_t BASIC_BLOCK_SIZE_1024 = 1024UL; | ||
| 38 | -constexpr uint64_t BASIC_BLOCK_SIZE_32 = 32; | ||
| 39 | -constexpr uint32_t DB_SIZE = 2; | ||
| 40 | -constexpr uint32_t DATA_SIZE_L0C = 4; | ||
| 41 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_RESV)}; | 31 | const std::vector<int32_t> supportedNpuArch = {static_cast<int32_t>(NpuArch::DAV_RESV)}; |
| 42 | constexpr int32_t TILING_PRIORITY = optiling::strategy::ITER_BATCH; | 32 | constexpr int32_t TILING_PRIORITY = optiling::strategy::ITER_BATCH; |
| 43 | } // namespace | 33 | } // namespace |
| @@ -158,12 +148,12 @@ uint32_t QuantBatchMatmulV3IterbatchTiling::CalcIterBatch() | |||
| 158 | { | 148 | { |
| 159 | // get align m,k,n value | 149 | // get align m,k,n value |
| 160 | uint64_t baseMAlignNum = | 150 | uint64_t baseMAlignNum = |
| 161 | - inputParams_.transA ? GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.aDtype) : CUBE_BLOCK; | 151 | + inputParams_.transA ? GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.aDtype) : qmmv3_tiling_const::CUBE_BLOCK; |
| 162 | uint64_t baseNAlignNum = | 152 | uint64_t baseNAlignNum = |
| 163 | - inputParams_.transB ? CUBE_BLOCK : GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.bDtype); | 153 | + inputParams_.transB ? qmmv3_tiling_const::CUBE_BLOCK : GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.bDtype); |
| 164 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) | 154 | uint64_t baseKAlignNum = (inputParams_.transA && !inputParams_.transB) |
| 165 | - ? CUBE_BLOCK | 155 | + ? qmmv3_tiling_const::CUBE_BLOCK |
| 166 | - : GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.aDtype); | 156 | + : GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.aDtype); |
| 167 | uint64_t alignMValue = ops::CeilAlign(inputParams_.mSize, baseMAlignNum); | 157 | uint64_t alignMValue = ops::CeilAlign(inputParams_.mSize, baseMAlignNum); |
| 168 | uint64_t alignNValue = ops::CeilAlign(inputParams_.nSize, baseNAlignNum); | 158 | uint64_t alignNValue = ops::CeilAlign(inputParams_.nSize, baseNAlignNum); |
| 169 | uint64_t alignKValue = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); | 159 | uint64_t alignKValue = ops::CeilAlign(inputParams_.kSize, baseKAlignNum); |
| @@ -240,21 +230,21 @@ ge::graphStatus QuantBatchMatmulV3IterbatchTiling::DoOpTiling() { | |||
| 240 | basicTiling_.singleCoreM = inputParams_.mSize; | 230 | basicTiling_.singleCoreM = inputParams_.mSize; |
| 241 | basicTiling_.singleCoreN = inputParams_.nSize; | 231 | basicTiling_.singleCoreN = inputParams_.nSize; |
| 242 | basicTiling_.singleCoreK = inputParams_.kSize; | 232 | basicTiling_.singleCoreK = inputParams_.kSize; |
| 243 | - basicTiling_.baseM = std::min(inputParams_.mSize, BASIC_BLOCK_SIZE_256); | 233 | + basicTiling_.baseM = std::min(inputParams_.mSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256); |
| 244 | basicTiling_.baseM = | 234 | basicTiling_.baseM = |
| 245 | !inputParams_.transA | 235 | !inputParams_.transA |
| 246 | - ? ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseM), CUBE_BLOCK) | 236 | + ? ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseM), qmmv3_tiling_const::CUBE_BLOCK) |
| 247 | : ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseM), | 237 | : ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseM), |
| 248 | - GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.aDtype)); | 238 | + GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.aDtype)); |
| 249 | - basicTiling_.baseN = std::min(inputParams_.nSize, BASIC_BLOCK_SIZE_256); | 239 | + basicTiling_.baseN = std::min(inputParams_.nSize, qmmv3_tiling_const::BASIC_BLOCK_SIZE_256); |
| 250 | basicTiling_.baseN = | 240 | basicTiling_.baseN = |
| 251 | inputParams_.transB | 241 | inputParams_.transB |
| 252 | - ? ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseN), CUBE_BLOCK) | 242 | + ? ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseN), qmmv3_tiling_const::CUBE_BLOCK) |
| 253 | : ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseN), | 243 | : ops::CeilAlign(static_cast<uint64_t>(basicTiling_.baseN), |
| 254 | - GetShapeWithDataType(L1_ALIGN_SIZE, inputParams_.bDtype)); | 244 | + GetShapeWithDataType(qmmv3_tiling_const::L1_ALIGN_SIZE, inputParams_.bDtype)); |
| 255 | basicTiling_.baseK = | 245 | basicTiling_.baseK = |
| 256 | - ops::CeilAlign(std::min(GetShapeWithDataType(BASIC_BLOCK_SIZE_128, inputParams_.aDtype), inputParams_.kSize), | 246 | + ops::CeilAlign(std::min(GetShapeWithDataType(qmmv3_tiling_const::BASIC_BLOCK_SIZE_128, inputParams_.aDtype), inputParams_.kSize), |
| 257 | - GetShapeWithDataType(CUBE_REDUCE_BLOCK, inputParams_.aDtype)); | 247 | + GetShapeWithDataType(qmmv3_tiling_const::CUBE_REDUCE_BLOCK, inputParams_.aDtype)); |
| 258 | basicTiling_.stepKa = ops::CeilDiv(inputParams_.kSize, static_cast<uint64_t>(basicTiling_.baseK)); | 248 | basicTiling_.stepKa = ops::CeilDiv(inputParams_.kSize, static_cast<uint64_t>(basicTiling_.baseK)); |
| 259 | basicTiling_.stepKb = basicTiling_.stepKa; | 249 | basicTiling_.stepKb = basicTiling_.stepKa; |
| 260 | basicTiling_.stepM = ops::CeilDiv(inputParams_.mSize, static_cast<uint64_t>(basicTiling_.baseM)); | 250 | basicTiling_.stepM = ops::CeilDiv(inputParams_.mSize, static_cast<uint64_t>(basicTiling_.baseM)); |
| @@ -262,8 +252,8 @@ ge::graphStatus QuantBatchMatmulV3IterbatchTiling::DoOpTiling() { | |||
| 262 | basicTiling_.depthA1 = basicTiling_.stepKa * basicTiling_.stepM; | 252 | basicTiling_.depthA1 = basicTiling_.stepKa * basicTiling_.stepM; |
| 263 | basicTiling_.depthB1 = basicTiling_.stepKb * basicTiling_.stepN; | 253 | basicTiling_.depthB1 = basicTiling_.stepKb * basicTiling_.stepN; |
| 264 | basicTiling_.dbL0c = | 254 | basicTiling_.dbL0c = |
| 265 | - ((basicTiling_.baseM * basicTiling_.baseN * DATA_SIZE_L0C * DB_SIZE <= aicoreParams_.l0cSize)) | 255 | + ((basicTiling_.baseM * basicTiling_.baseN * qmmv3_tiling_const::DATA_SIZE_L0C * qmmv3_tiling_const::DOUBLE_BUFFER_NUM <= aicoreParams_.l0cSize)) |
| 266 | - ? DB_SIZE | 256 | + ? qmmv3_tiling_const::DOUBLE_BUFFER_NUM |
| 267 | : 1; | 257 | : 1; |
| 268 | SetTilingData(); | 258 | SetTilingData(); |
| 269 | return ge::GRAPH_SUCCESS; | 259 | return ge::GRAPH_SUCCESS; |
| @@ -25,6 +25,36 @@ | |||
| 25 | 25 | ||
| 26 | namespace optiling { | 26 | namespace optiling { |
| 27 | 27 | ||
| 28 | +namespace qmmv3_tiling_const { | ||
| 29 | +constexpr uint64_t CUBE_BLOCK = 16UL; | ||
| 30 | +constexpr uint64_t CUBE_REDUCE_BLOCK = 32UL; | ||
| 31 | +constexpr uint64_t L1_ALIGN_SIZE = 32UL; | ||
| 32 | +constexpr uint64_t L2_ALIGN_SIZE = 128UL; | ||
| 33 | +// MTE2 address alignment size in bytes. | ||
| 34 | +constexpr uint64_t MTE2_ADDRESS_ALIGN_SIZE = 128UL; | ||
| 35 | +constexpr uint64_t MX_GROUP_SIZE = 32UL; | ||
| 36 | +constexpr uint64_t MXFP_DIVISOR_SIZE = 64UL; | ||
| 37 | +constexpr uint64_t MXFP_MULTI_BASE_SIZE = 2UL; | ||
| 38 | +constexpr uint64_t BASIC_BLOCK_SIZE_32 = 32UL; | ||
| 39 | +constexpr uint64_t BASIC_BLOCK_SIZE_128 = 128UL; | ||
| 40 | +constexpr uint64_t BASIC_BLOCK_SIZE_256 = 256UL; | ||
| 41 | +constexpr uint64_t PER_BLOCK_SIZE = 128UL; | ||
| 42 | +constexpr uint32_t DOUBLE_BUFFER_NUM = 2U; | ||
| 43 | +constexpr uint32_t DATA_SIZE_L0C = 4U; | ||
| 44 | +constexpr uint8_t L1_TWO_BUFFER = 2U; | ||
| 45 | +constexpr uint8_t L1_FOUR_BUFFER = 4U; | ||
| 46 | +constexpr uint32_t NUM_HALF = 2U; | ||
| 47 | +// Mix/per-block templates require the AIC:AIV core ratio to be 1:2. | ||
| 48 | +constexpr uint32_t CORE_RATIO = 2U; | ||
| 49 | +constexpr uint64_t WINDOW_LEN = 4UL; | ||
| 50 | +constexpr uint64_t AFULLLOAD_SINGLE_CORE_A_SCALER = 2UL; | ||
| 51 | +constexpr uint64_t AFULLLOAD_SINGLE_CORE_B_SCALER = 2UL; | ||
| 52 | +// Heuristic cap for reserved MX scaleKL1 size. | ||
| 53 | +constexpr uint64_t ESTIMATED_SCALE_K = 4096UL; | ||
| 54 | +constexpr uint32_t SCALER_FACTOR_MAX = 127U; | ||
| 55 | +constexpr uint32_t SCALER_FACTOR_MIN = 1U; | ||
| 56 | +} // namespace qmmv3_tiling_const | ||
| 57 | + | ||
| 28 | struct BasicRunInfoTiling { | 58 | struct BasicRunInfoTiling { |
| 29 | uint32_t usedCoreNum = 1; | 59 | uint32_t usedCoreNum = 1; |
| 30 | uint32_t singleCoreM = 1; | 60 | uint32_t singleCoreM = 1; |
| @@ -18,7 +18,6 @@ | |||
| 18 | #include <map> | 18 | #include <map> |
| 19 | #include <numeric> | 19 | #include <numeric> |
| 20 | 20 | ||
| 21 | -#include "arch35/adaptive_sliding_window_tiling.h" | ||
| 22 | #include "arch35/quant_batch_matmul_v3_tiling_strategy.h" | 21 | #include "arch35/quant_batch_matmul_v3_tiling_strategy.h" |
| 23 | #include "op_host/tiling_templates_registry.h" | 22 | #include "op_host/tiling_templates_registry.h" |
| 24 | #include "common/op_host/op_tiling/tiling_type.h" | 23 | #include "common/op_host/op_tiling/tiling_type.h" |
| @@ -1559,7 +1558,6 @@ static ge::graphStatus QuantBatchMatmulV3TilingFunc(gert::TilingContext* context | |||
| 1559 | auto npuArch = compileInfoPtr->supportMmadS8S4 ? NpuArch::DAV_RESV : compileInfoPtr->npuArch; | 1558 | auto npuArch = compileInfoPtr->supportMmadS8S4 ? NpuArch::DAV_RESV : compileInfoPtr->npuArch; |
| 1560 | if (PlatformUtil::IsAdvancedArch(npuArch)) { | 1559 | if (PlatformUtil::IsAdvancedArch(npuArch)) { |
| 1561 | ResetQuantBatchMatmulV3InputParams(); | 1560 | ResetQuantBatchMatmulV3InputParams(); |
| 1562 | - ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 1563 | const auto& priorities = strategy::GetQuantBatchMatmulV3Priorities(npuArch); | 1561 | const auto& priorities = strategy::GetQuantBatchMatmulV3Priorities(npuArch); |
| 1564 | return TilingRegistryArch::GetInstance().DoTilingImpl(context, priorities, static_cast<int32_t>(npuArch)); | 1562 | return TilingRegistryArch::GetInstance().DoTilingImpl(context, priorities, static_cast<int32_t>(npuArch)); |
| 1565 | } else if (IsSocVersionArch20Pertoken(context)) { | 1563 | } else if (IsSocVersionArch20Pertoken(context)) { |
| @@ -224,10 +224,10 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/19,,invalidInputDt | |||
| 224 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/20,,invalidScaleDtype,,,3,3,3,1,1,1,13,320,952,0,0,1,0,1,0,INT8,INT8,INT8,FLOAT,INT32,INT8,ND,ND,FALSE,32,4,,FALSE, | 224 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/20,,invalidScaleDtype,,,3,3,3,1,1,1,13,320,952,0,0,1,0,1,0,INT8,INT8,INT8,FLOAT,INT32,INT8,ND,ND,FALSE,32,4,,FALSE, |
| 225 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/21,,invalidBiasDtype,,,3,3,3,1,1,1,13,320,952,0,0,1,0,1,0,INT8,INT8,UINT64,FLOAT,FLOAT,INT8,ND,ND,FALSE,32,4,,FALSE, | 225 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/21,,invalidBiasDtype,,,3,3,3,1,1,1,13,320,952,0,0,1,0,1,0,INT8,INT8,UINT64,FLOAT,FLOAT,INT8,ND,ND,FALSE,32,4,,FALSE, |
| 226 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/22,,invalidOffset,,,3,3,3,1,1,1,13,320,952,1,0,1,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,FALSE,32,4,,FALSE, | 226 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/22,,invalidOffset,,,3,3,3,1,1,1,13,320,952,1,0,1,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,FALSE,32,4,,FALSE, |
| 227 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/25,,mxfp4-pergroup-quanliang,,,3,3,3,1,1,1,5344,1260,1976,0,1,1,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,5344 1976 1260 1024 16777472 256 131072 65538 2097153 131074 65537 0 67592 258 0 0,FALSE, | 227 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/25,,mxfp4-pergroup-quanliang,,,3,3,3,1,1,1,5344,1260,1976,0,1,1,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,5344 1976 1260 1536 16777472 256 131072 65538 2097153 131074 65537 0 67592 258 0 0,FALSE, |
| 228 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/27,,mxfp4-pergroup-zengliang,,,3,3,3,1,1,1,1,14336,5120,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,1 5120 14336 14336 10485776 256 262144 65540 2097153 65537 65537 0 50333704 516 0 0,FALSE, | 228 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/27,,mxfp4-pergroup-zengliang,,,3,3,3,1,1,1,1,14336,5120,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,1 5120 14336 14336 10485776 256 262144 65540 2097153 65537 65537 0 50333704 516 0 0,FALSE, |
| 229 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/28,,mxfp4-pergroup-kNotAlign64-NnotAlign16,,,3,3,3,1,1,1,192,4066,255,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,192 255 4066 5120 2097200 1280 262144 65540 2097153 65537 65537 0 50333704 514 0 0,FALSE, | 229 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/28,,mxfp4-pergroup-kNotAlign64-NnotAlign16,,,3,3,3,1,1,1,192,4066,255,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,192 255 4066 5120 2097200 1280 262144 65540 2097153 65537 65537 0 50333704 514 0 0,FALSE, |
| 230 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/29,,mxfp4-pergroup-kNotAlign256,,,3,3,3,1,1,1,4096,7104,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,4096 2048 7104 6656 16777472 256 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, | 230 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/29,,mxfp4-pergroup-kNotAlign256,,,3,3,3,1,1,1,4096,7104,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,4096 2048 7104 7168 16777472 256 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, |
| 231 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/30,,mxfp4-pergroup-kLess64-NnotAlign16,,,3,3,3,1,1,1,4097,62,3,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10500,4097 3 62 256 1048720 256 65536 65537 2097153 65537 65537 0 50333704 516 0 0,FALSE, | 231 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/30,,mxfp4-pergroup-kLess64-NnotAlign16,,,3,3,3,1,1,1,4097,62,3,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10500,4097 3 62 256 1048720 256 65536 65537 2097153 65537 65537 0 50333704 516 0 0,FALSE, |
| 232 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/31,,mxfp4-pergroup-MnotAlign16,,,3,3,3,1,1,1,1023,382,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,1023 2048 382 512 16777472 256 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, | 232 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/31,,mxfp4-pergroup-MnotAlign16,,,3,3,3,1,1,1,1023,382,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10500,1023 2048 382 512 16777472 256 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, |
| 233 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/32,,mxfp4-pergroup-inputDtypeError,,,3,3,3,1,1,1,1023,382,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT4-E2M1,ND,ND,FALSE,32,4,,FALSE, | 233 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/32,,mxfp4-pergroup-inputDtypeError,,,3,3,3,1,1,1,1023,382,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT4-E2M1,ND,ND,FALSE,32,4,,FALSE, |
| @@ -249,8 +249,8 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/49,,mxfp8-pergroup | |||
| 249 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/50,,mxfp8-pergroup-AttrError,,,3,3,3,1,1,1,1023,382,2048,0,1,0,1,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,FALSE,32,4,,FALSE, | 249 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/50,,mxfp8-pergroup-AttrError,,,3,3,3,1,1,1,1023,382,2048,0,1,0,1,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,FALSE,32,4,,FALSE, |
| 250 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/51,,mxfp8-pergroup-ScaleInnerNotEven,,,3,3,3,1,1,1,1023,32,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,8196,,TRUE, | 250 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/51,,mxfp8-pergroup-ScaleInnerNotEven,,,3,3,3,1,1,1,1023,32,2048,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,8196,,TRUE, |
| 251 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/52,,mxfp8-pergroup-perTokenNull,,,3,3,3,1,1,1,1900,1706,4096,0,0,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,FALSE,32,4,,FALSE, | 251 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/52,,mxfp8-pergroup-perTokenNull,,,3,3,3,1,1,1,1900,1706,4096,0,0,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,FALSE,32,4,,FALSE, |
| 252 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/53,,mxfp8-pergroup-AB-large-scaleInit,,,2,2,2,0,0,0,1206,8512,1048,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,30,10500,1206 1048 8512 2560 14680272 128 262144 65540 2097153 65537 65537 0 67592 258 0 0,FALSE, | 252 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/53,,mxfp8-pergroup-AB-large-scaleInit,,,2,2,2,0,0,0,1206,8512,1048,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,30,10500,1206 1048 8512 8704 14680272 128 131072 65538 2097153 65537 65537 0 67592 258 0 0,FALSE, |
| 253 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/54,,mxfp8-pergroup-AB-less-scaleInit,,,2,2,2,0,0,0,1420,4096,1560,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,1420 1560 4096 4096 16777472 128 131072 65538 2097153 65539 458758 14680304 67592 258 0 0,FALSE, | 253 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/54,,mxfp8-pergroup-AB-less-scaleInit,,,2,2,2,0,0,0,1420,4096,1560,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,1420 1560 4096 4096 14680224 128 131072 65538 2097153 65537 65537 0 67592 260 0 0,FALSE, |
| 254 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/55,,Al1fullload-mcnt1-pertoken,,,3,3,3,1,1,1,16,6656,8192,0,1,1,0,1,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 8 256 0 0 0 3 0 0 0 0 0 0 32 16 8192 6656 6656 16 256 6656 16 256 128 52 4 1 1 1 0 0 0 0 0 0 0 0 0 0 52 2 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 254 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/55,,Al1fullload-mcnt1-pertoken,,,3,3,3,1,1,1,16,6656,8192,0,1,1,0,1,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 8 256 0 0 0 3 0 0 0 0 0 0 32 16 8192 6656 6656 16 256 6656 16 256 128 52 4 1 1 1 0 0 0 0 0 0 0 0 0 0 52 2 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 255 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/56,,Al1fullload-mcnt2-pertoken,,,3,3,3,1,1,1,426,1024,8192,0,1,1,1,0,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,769,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 426 8192 1024 1024 256 256 1024 256 256 128 8 4 1 1 1 0 0 0 0 0 0 0 0 0 0 8 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 255 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/56,,Al1fullload-mcnt2-pertoken,,,3,3,3,1,1,1,426,1024,8192,0,1,1,1,0,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,769,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 426 8192 1024 1024 256 256 1024 256 256 128 8 4 1 1 1 0 0 0 0 0 0 0 0 0 0 8 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 256 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/57,,Al1fullload-mcnt4-pertoken,,,3,3,3,1,1,1,128,3072,1024,0,1,1,0,0,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,768,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 16 128 0 0 0 3 0 0 0 0 0 0 32 128 1024 3072 3072 32 128 3072 32 128 256 12 4 1 1 1 0 0 0 0 0 0 0 0 0 0 12 2 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 256 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/57,,Al1fullload-mcnt4-pertoken,,,3,3,3,1,1,1,128,3072,1024,0,1,1,0,0,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,768,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 16 128 0 0 0 3 0 0 0 0 0 0 32 128 1024 3072 3072 32 128 3072 32 128 256 12 4 1 1 1 0 0 0 0 0 0 0 0 0 0 12 2 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| @@ -260,8 +260,8 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/60,,Al1fullload-mc | |||
| 260 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/61,,Al1fullload-mcnt4-A8W8-01-nopertoken,,,3,3,3,1,1,1,512,320,1048,0,0,0,0,1,0,FLOAT8-E4M3,FLOAT8-E4M3,UINT64,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 512 1048 320 128 144 128 0 196611 0 131076 1 1 1 1 0 0,FALSE, | 260 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/61,,Al1fullload-mcnt4-A8W8-01-nopertoken,,,3,3,3,1,1,1,512,320,1048,0,0,0,0,1,0,FLOAT8-E4M3,FLOAT8-E4M3,UINT64,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 512 1048 320 128 144 128 0 196611 0 131076 1 1 1 1 0 0,FALSE, |
| 261 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/62,,Al1fullload-mcnt4-A8W8-11-nopertoken,,,3,3,3,1,1,1,512,320,1048,0,0,0,1,1,0,FLOAT8-E4M3,FLOAT8-E4M3,UINT64,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,8197,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 512 1048 320 128 144 128 0 196611 0 131076 1 1 1 1 0 0,FALSE, | 261 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/62,,Al1fullload-mcnt4-A8W8-11-nopertoken,,,3,3,3,1,1,1,512,320,1048,0,0,0,1,1,0,FLOAT8-E4M3,FLOAT8-E4M3,UINT64,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,8197,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 512 1048 320 128 144 128 0 196611 0 131076 1 1 1 1 0 0,FALSE, |
| 262 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/67,,Al1fullload-mcnt4-mxfp8,,,3,3,3,1,1,1,512,512,1024,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,512 1024 512 512 8388736 256 131072 65538 2097153 65537 65537 0 67592 514 0 0,FALSE, | 262 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/67,,Al1fullload-mcnt4-mxfp8,,,3,3,3,1,1,1,512,512,1024,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,512 1024 512 512 8388736 256 131072 65538 2097153 65537 65537 0 67592 514 0 0,FALSE, |
| 263 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/68,,Al1fullload-mcnt2-with-tail-mxfp8,,,3,3,3,1,1,1,88,1600,9120,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10756,88 9120 1600 1536 16777312 128 131072 65538 2097153 524289 65537 0 67592 516 0 0,FALSE, | 263 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/68,,Al1fullload-mcnt2-with-tail-mxfp8,,,3,3,3,1,1,1,88,1600,9120,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10756,88 9120 1600 1792 16777312 128 131072 65538 2097153 524289 65537 0 67592 516 0 0,FALSE, |
| 264 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/69,,Al1fullload-mcnt1-mxfp8,,,3,3,3,1,1,1,8,3072,1536,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,8 1536 3072 2560 3145744 640 262144 65540 2097153 65537 65537 0 67592 514 0 0,FALSE, | 264 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/69,,Al1fullload-mcnt1-mxfp8,,,3,3,3,1,1,1,8,3072,1536,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,8 1536 3072 5120 3145744 640 262144 65540 2097153 65537 65537 0 67592 514 0 0,FALSE, |
| 265 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/70,,Al1fullload-mncntless32-mxfp8,,,3,3,3,1,1,1,16,384,592,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,19,10500,16 592 384 384 2097168 384 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, | 265 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/70,,Al1fullload-mncntless32-mxfp8,,,3,3,3,1,1,1,16,384,592,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,19,10500,16 592 384 384 2097168 384 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| 266 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/72,,1971Compate-scale-bf16-bias-int32,,,2,2,2,0,0,0,103,9680,7672,0,0,1,0,1,0,INT8,INT8,BF16,FLOAT,INT32,BF16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 103 7672 9680 112 240 128 0 262152 0 131330 1 1 1 1 0 0,FALSE, | 266 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/72,,1971Compate-scale-bf16-bias-int32,,,2,2,2,0,0,0,103,9680,7672,0,0,1,0,1,0,INT8,INT8,BF16,FLOAT,INT32,BF16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 103 7672 9680 112 240 128 0 262152 0 131330 1 1 1 1 0 0,FALSE, |
| 267 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/73,,1971Compate-scale-bf16-bias-fp32,,,2,2,2,0,0,0,590,9696,4256,0,0,1,1,1,1,INT8,INT8,BF16,FLOAT,FLOAT,BF16,ND,ND,TRUE,32,517,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 590 4256 9696 9696 256 256 9696 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 267 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/73,,1971Compate-scale-bf16-bias-fp32,,,2,2,2,0,0,0,590,9696,4256,0,0,1,1,1,1,INT8,INT8,BF16,FLOAT,FLOAT,BF16,ND,ND,TRUE,32,517,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 590 4256 9696 9696 256 256 9696 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| @@ -292,10 +292,10 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/100,,1971CompatePe | |||
| 292 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/101,,1971CompatePertoken-scale-fp32-bias-fp32,,,2,2,2,0,0,0,2852,1520,2256,0,1,1,1,0,0,INT8,INT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,32,513,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 79 256 0 0 0 0 0 0 0 0 0 0 32 2852 2256 1520 1520 256 256 1520 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, | 292 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/101,,1971CompatePertoken-scale-fp32-bias-fp32,,,2,2,2,0,0,0,2852,1520,2256,0,1,1,1,0,0,INT8,INT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,32,513,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 79 256 0 0 0 0 0 0 0 0 0 0 32 2852 2256 1520 1520 256 256 1520 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, |
| 293 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/102,,1971CompatePertokenfp16-scale-fp32-bias-fp16,,,2,2,2,0,0,0,360,6992,1384,0,1,1,0,1,0,INT8,INT8,FLOAT,FLOAT,FLOAT16,FLOAT16,ND,ND,TRUE,32,516,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 48 176 0 0 0 1 0 0 0 0 0 0 32 360 1384 6992 6992 96 176 6992 96 176 128 20 10 1 1 1 0 0 0 0 0 0 0 0 0 0 10 5 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 293 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/102,,1971CompatePertokenfp16-scale-fp32-bias-fp16,,,2,2,2,0,0,0,360,6992,1384,0,1,1,0,1,0,INT8,INT8,FLOAT,FLOAT,FLOAT16,FLOAT16,ND,ND,TRUE,32,516,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 48 176 0 0 0 1 0 0 0 0 0 0 32 360 1384 6992 6992 96 176 6992 96 176 128 20 10 1 1 1 0 0 0 0 0 0 0 0 0 0 10 5 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 294 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/103,,1971CompatePertokenfp16-scale-fp32-bias-fp32,,,2,2,2,0,0,0,2852,1520,2256,0,1,1,1,0,1,INT8,INT8,FLOAT,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,513,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 0 0 0 0 0 0 0 32 2852 2256 1520 1520 256 256 1520 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, | 294 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/103,,1971CompatePertokenfp16-scale-fp32-bias-fp32,,,2,2,2,0,0,0,2852,1520,2256,0,1,1,1,0,1,INT8,INT8,FLOAT,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,32,513,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 0 0 0 0 0 0 0 32 2852 2256 1520 1520 256 256 1520 256 256 128 6 6 1 1 1 0 0 0 0 0 0 0 0 0 0 3 3 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, |
| 295 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/104,,mxfp8-pergroup-A_batch-B_no_batch,,,3,2,3,2,0,2,1206,8512,1048,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,8196,2 1 2 1 1 1 2 1 1 1 1 1 1 1 2 8 8 0 0 1 1 32 1206 1048 8512 256 256 128 7936 131074 2031648 65794 1 1 1 1 0 0,FALSE, | 295 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/104,,mxfp8-pergroup-A_batch-B_no_batch,,,3,2,3,2,0,2,1206,8512,1048,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,8196,2 1 2 1 1 1 2 1 1 1 1 1 1 1 2 8 8 0 0 1 1 32 1206 1048 8512 256 176 128 8704 131074 2228258 65794 1 1 1 1 0 0,FALSE, |
| 296 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/105,,int8_int8_int32,,,2,2,2,0,0,0,2906,128,1744,0,0,0,0,0,0,INT8,INT8,BF16,FLOAT,INT32,INT32,ND,ND,TRUE,32,8192,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 2906 1744 128 256 256 128 0 65537 0 65540 1 1 8 1 240 0,FALSE, | 296 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/105,,int8_int8_int32,,,2,2,2,0,0,0,2906,128,1744,0,0,0,0,0,0,INT8,INT8,BF16,FLOAT,INT32,INT32,ND,ND,TRUE,32,8192,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 2906 1744 128 256 256 128 0 65537 0 65540 1 1 8 1 240 0,FALSE, |
| 297 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/106,,mxfp8-pergroup-k-1024,,,2,2,2,0,0,0,10240,1024,2624,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,10240 2624 1024 1024 16777472 128 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, | 297 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/106,,mxfp8-pergroup-k-1024,,,2,2,2,0,0,0,10240,1024,2624,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,10240 2624 1024 1024 16777472 128 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE, |
| 298 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/107,,mxfp8-true-false-afullload-tailsplit,,,2,2,2,0,0,0,332,496,5320,0,1,0,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10753,332 5320 496 256 16777472 128 131072 65538 2097153 196609 65537 0 50333704 260 0 0,FALSE, | 298 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/107,,mxfp8-true-false-afullload-tailsplit,,,2,2,2,0,0,0,332,496,5320,0,1,0,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10497,332 5320 496 512 16777344 128 262144 65540 2097153 65537 65537 0 50333704 514 0 0,FALSE, |
| 299 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/0,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,0,0,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,29,512,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 29 52 7360 4632 4632 52 256 4632 64 256 128 30 6 1 1 1 0 0 0 0 0 0 0 0 0 0 15 3 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 299 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/0,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,0,0,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,29,512,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 29 52 7360 4632 4632 52 256 4632 64 256 128 30 6 1 1 1 0 0 0 0 0 0 0 0 0 0 15 3 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 300 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/1,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,0,1,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,31,516,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 31 52 7360 4632 4632 52 240 4632 64 240 128 24 8 1 1 1 0 0 0 0 0 0 0 0 0 0 12 4 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 300 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/1,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,0,1,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,31,516,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 31 52 7360 4632 4632 52 240 4632 64 240 128 24 8 1 1 1 0 0 0 0 0 0 0 0 0 0 12 4 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 301 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/2,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,1,1,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,31,517,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 31 52 7360 4632 4632 52 240 4632 128 240 128 8 8 1 1 1 0 0 0 0 0 0 0 0 0 0 4 4 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 301 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/2,,fanhua,,,2,2,2,0,0,0,52,4632,7360,0,0,1,1,1,1,INT8,INT8,BF16,BF16,BF16,BF16,ND,ND,TRUE,31,517,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 27 0 0 0 0 0 0 31 52 7360 4632 4632 52 240 4632 128 240 128 8 8 1 1 1 0 0 0 0 0 0 0 0 0 0 4 4 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| @@ -352,7 +352,7 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/55,,unalign,,,2,2,2 | |||
| 352 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/56,quant_batch_matmul_v3_perblock,unalign,,,3,2,3,17,0,17,81,690,109,0,1,0,0,0,3,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,17,5120,17 1 17 1 1 1 17 1 1 1 1 1 1 1 17 16 16 0 3 128 128 128 81 109 690 128 128 128 0 262148 0 131074 1 1 1 1 0 0,FALSE, | 352 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/56,quant_batch_matmul_v3_perblock,unalign,,,3,2,3,17,0,17,81,690,109,0,1,0,0,0,3,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,17,5120,17 1 17 1 1 1 17 1 1 1 1 1 1 1 17 16 16 0 3 128 128 128 81 109 690 128 128 128 0 262148 0 131074 1 1 1 1 0 0,FALSE, |
| 353 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/57,quant_batch_matmul_v3_perblock_dtype_error,quant_batch_matmul_v3_perblock_dtype_error,,,3,2,3,17,0,17,81,690,109,0,1,0,0,0,3,INT8,INT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,FALSE,16,1024,,FALSE, | 353 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/57,quant_batch_matmul_v3_perblock_dtype_error,quant_batch_matmul_v3_perblock_dtype_error,,,3,2,3,17,0,17,81,690,109,0,1,0,0,0,3,INT8,INT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,FALSE,16,1024,,FALSE, |
| 354 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/58,,unalign,,,2,2,2,0,0,0,6,74,9,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,1,10500,6 9 74 128 1048592 128 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, | 354 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/58,,unalign,,,2,2,2,0,0,0,6,74,9,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,1,10500,6 9 74 128 1048592 128 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| 355 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/59,,mxfp8-false-false,,,2,2,2,0,0,0,122,192,16,0,1,1,0,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,8,10496,122 16 192 256 2097280 128 131072 65538 2097153 65544 65537 0 67592 516 0 0,FALSE, | 355 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/59,,mxfp8-false-false,,,2,2,2,0,0,0,122,192,16,0,1,1,0,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,8,10496,122 16 192 256 2097168 128 131072 65538 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| 356 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/60,,mxfp8-true-true,,,2,2,2,0,0,0,254,64,640,0,1,1,1,1,2,FLOAT8-E4M3,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,28,10501,254 640 64 64 3145856 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, | 356 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/60,,mxfp8-true-true,,,2,2,2,0,0,0,254,64,640,0,1,1,1,1,2,FLOAT8-E4M3,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,28,10501,254 640 64 64 3145856 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| 357 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/61,,mxfp8-true-false,,,2,2,2,0,0,0,26,32,7232,0,1,1,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10497,26 7232 32 64 16777344 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, | 357 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/61,,mxfp8-true-false,,,2,2,2,0,0,0,26,32,7232,0,1,1,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10497,26 7232 32 64 16777344 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| 358 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/62,,950_coreNum_check_32_60_pass,32,60,2,2,2,0,0,0,26,32,7232,0,1,1,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10497,26 7232 32 64 16777344 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, | 358 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.kernelTest/62,,950_coreNum_check_32_60_pass,32,60,2,2,2,0,0,0,26,32,7232,0,1,1,1,0,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,29,10497,26 7232 32 64 16777344 64 65536 65537 2097153 65537 65537 0 67592 516 0 0,FALSE, |
| @@ -369,13 +369,13 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/72,,qbmm_int4_pert | |||
| 369 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/108,,full_load_tail_balance_qbmm_TT_tail_case0100,,,2,2,2,0,0,0,403,256,15616,0,0,0,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8452,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 403 15616 256 208 256 128 0 131074 0 65540 1 1 1 1 0 0,FALSE, | 369 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/108,,full_load_tail_balance_qbmm_TT_tail_case0100,,,2,2,2,0,0,0,403,256,15616,0,0,0,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8452,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 403 15616 256 208 256 128 0 131074 0 65540 1 1 1 1 0 0,FALSE, |
| 370 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/109,,full_load_tail_balance_qbmm_KC_tail_case0050,,,2,2,2,0,0,0,339,256,10496,0,1,0,0,1,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 339 10496 256 256 176 256 256 176 256 128 2 4 1 1 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 370 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/109,,full_load_tail_balance_qbmm_KC_tail_case0050,,,2,2,2,0,0,0,339,256,10496,0,1,0,0,1,1,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 339 10496 256 256 176 256 256 176 256 128 2 4 1 1 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 371 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/110,,full_load_tail_balance_qbmm_KT_tail_case0120,,,2,2,2,0,0,0,431,512,14336,0,1,0,0,1,0,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 431 14336 512 512 224 256 512 224 256 128 4 4 1 1 0 0 0 0 0 0 0 0 0 0 0 4 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, | 371 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/110,,full_load_tail_balance_qbmm_KT_tail_case0120,,,2,2,2,0,0,0,431,512,14336,0,1,0,0,1,0,INT8,INT8,FLOAT,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 79 256 0 0 0 3 0 0 0 0 0 0 32 431 14336 512 512 224 256 512 224 256 128 4 4 1 1 0 0 0 0 0 0 0 0 0 0 0 4 2 0 0 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0,FALSE, |
| 372 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/111,,full_load_tail_balance_qbmm_MXFP8_tail_case0073,,,2,2,2,0,0,0,366,512,13312,0,1,0,0,1,2,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10756,366 13312 512 512 16777408 128 131072 65538 2097153 262145 65537 0 2056 260 0 0,FALSE, | 372 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/111,,full_load_tail_balance_qbmm_MXFP8_tail_case0073,,,2,2,2,0,0,0,366,512,13312,0,1,0,0,1,2,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10756,366 13312 512 512 16777408 128 131072 65538 2097153 262145 65537 0 50333704 260 0 0,FALSE, |
| 373 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/112,,full_load_tail_balance_qbmm_MXFP4_tail_case0100,,,2,2,2,0,0,0,404,1024,13824,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10756,404 13824 1024 1024 16777424 256 131072 65538 2097153 131073 65537 0 2056 260 0 0,FALSE, | 373 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/112,,full_load_tail_balance_qbmm_MXFP4_tail_case0100,,,2,2,2,0,0,0,404,1024,13824,0,1,0,0,1,2,FLOAT4-E2M1,FLOAT4-E2M1,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT,ND,ND,TRUE,32,10756,404 13824 1024 1024 16777424 256 131072 65538 2097153 131073 65537 0 50333704 260 0 0,FALSE, |
| 374 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/113,,nd_k_not_128_qbmm_nd_TT_case0025,,,2,2,2,0,0,0,1817,257,1024,0,0,0,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 1817 1024 257 256 256 128 0 196611 0 65538 1 1 4 1 208 0,FALSE, | 374 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/113,,nd_k_not_128_qbmm_nd_TT_case0025,,,2,2,2,0,0,0,1817,257,1024,0,0,0,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 1817 1024 257 256 256 128 0 196611 0 65538 1 1 4 1 208 0,FALSE, |
| 375 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/114,,nd_k_not_128_qbmm_nd_TC_case0025,,,2,2,2,0,0,0,1817,319,2304,0,0,0,0,1,1,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 3 0 0 0 1817 2304 319 256 256 128 0 196611 0 65538 2 2 4 1 208 0,FALSE, | 375 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/114,,nd_k_not_128_qbmm_nd_TC_case0025,,,2,2,2,0,0,0,1817,319,2304,0,0,0,0,1,1,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8196,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 3 0 0 0 1817 2304 319 256 256 128 0 196611 0 65538 2 2 4 1 208 0,FALSE, |
| 376 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/115,,nd_k_not_128_qbmm_nd_MXFP8_case0026,,,2,2,2,0,0,0,1818,447,3840,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1818 3840 447 256 16777472 128 131072 65538 2097153 65537 65540 208 2056 258 0 0,FALSE, | 376 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/115,,nd_k_not_128_qbmm_nd_MXFP8_case0026,,,2,2,2,0,0,0,1818,447,3840,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1818 3840 447 512 16777472 128 131072 65538 2097153 65537 65540 208 50333704 258 0 0,FALSE, |
| 377 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/116,,nd_k_not_128_qbmm_nd_MXFP8_case0027,,,2,2,2,0,0,0,1819,510,4096,0,1,0,0,1,2,FLOAT8-E4M3,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1819 4096 510 256 16777472 128 131072 65538 2097153 65537 65540 208 2056 258 0 0,FALSE, | 377 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/116,,nd_k_not_128_qbmm_nd_MXFP8_case0027,,,2,2,2,0,0,0,1819,510,4096,0,1,0,0,1,2,FLOAT8-E4M3,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1819 4096 510 512 16777472 128 131072 65538 2097153 65537 65540 208 50333704 258 0 0,FALSE, |
| 378 | -Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/117,,nd_k_not_128_qbmm_nd_MXFP8_case0028,,,2,2,2,0,0,0,1820,575,4352,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1820 4352 575 512 16777472 128 131072 65538 2097153 131074 65540 208 2056 258 0 0,FALSE, | 378 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/117,,nd_k_not_128_qbmm_nd_MXFP8_case0028,,,2,2,2,0,0,0,1820,575,4352,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10500,1820 4352 575 768 16777472 128 131072 65538 2097153 131074 65540 208 50333704 258 0 0,FALSE, |
| 379 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/118,,fp8-kc-fp32-scale-bias-fp32,,,3,3,3,1,1,1,27,240,40,0,1,1,0,1,1,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT,ND,ND,TRUE,6,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 8 16 0 0 0 0 0 0 0 0 0 0 6 27 40 240 240 16 16 240 16 16 256 1 16 1 1 1 0 0 0 0 0 0 0 0 0 0 1 8 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 379 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/118,,fp8-kc-fp32-scale-bias-fp32,,,3,3,3,1,1,1,27,240,40,0,1,1,0,1,1,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT,ND,ND,TRUE,6,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 8 16 0 0 0 0 0 0 0 0 0 0 6 27 40 240 240 16 16 240 16 16 256 1 16 1 1 1 0 0 0 0 0 0 0 0 0 0 1 8 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 380 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/119,,fp8-kt-fp32-scale-bias-fp32,,,3,3,3,1,1,1,127,69,158,0,1,1,0,0,0,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,10,768,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 64 160 0 0 0 0 0 0 0 0 0 0 10 127 158 69 69 127 158 69 128 160 96 1 6 1 1 1 0 0 0 0 0 0 0 0 0 0 1 3 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 10 1 1 0 0,FALSE, | 380 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/119,,fp8-kt-fp32-scale-bias-fp32,,,3,3,3,1,1,1,127,69,158,0,1,1,0,0,0,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT16,ND,ND,TRUE,10,768,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 64 160 0 0 0 0 0 0 0 0 0 0 10 127 158 69 69 127 158 69 128 160 96 1 6 1 1 1 0 0 0 0 0 0 0 0 0 0 1 3 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 10 1 1 0 0,FALSE, |
| 381 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/120,,hifloat8-kc-fp32-scale-bias-fp32,,,3,3,3,1,1,1,10,112,104,0,1,1,0,1,1,HIFLOAT8,HIFLOAT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,7,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 5 16 0 0 0 0 0 0 0 0 0 0 7 10 104 112 112 10 16 112 16 16 128 1 32 1 1 1 0 0 0 0 0 0 0 0 0 0 1 16 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 381 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/120,,hifloat8-kc-fp32-scale-bias-fp32,,,3,3,3,1,1,1,10,112,104,0,1,1,0,1,1,HIFLOAT8,HIFLOAT8,FLOAT,FLOAT,FLOAT,BF16,ND,ND,TRUE,7,772,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 5 16 0 0 0 0 0 0 0 0 0 0 7 10 104 112 112 10 16 112 16 16 128 1 32 1 1 1 0 0 0 0 0 0 0 0 0 0 1 16 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| @@ -390,6 +390,11 @@ Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/128,,hifloat8-weig | |||
| 390 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/129,,hifloat8-weightnz-dtype-error-scale-float,,,3,3,3,1,1,1,10,112,104,0,0,1,0,1,0,HIFLOAT8,HIFLOAT8,FLOAT,FLOAT,FLOAT,BF16,ND,NZ,FALSE,32,0,,FALSE,hifloat8 weightnz scale must be UINT64/INT64 | 390 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/129,,hifloat8-weightnz-dtype-error-scale-float,,,3,3,3,1,1,1,10,112,104,0,0,1,0,1,0,HIFLOAT8,HIFLOAT8,FLOAT,FLOAT,FLOAT,BF16,ND,NZ,FALSE,32,0,,FALSE,hifloat8 weightnz scale must be UINT64/INT64 |
| 391 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/130,,fp8e4m3-weightnz-dtype-error-static-float-scale,,,3,3,3,1,1,1,127,69,158,0,0,1,0,0,0,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT16,ND,NZ,FALSE,32,0,,FALSE,fp8 e4m3 weightnz static scale must be UINT64/INT64 or mx E8M0 pair | 391 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/130,,fp8e4m3-weightnz-dtype-error-static-float-scale,,,3,3,3,1,1,1,127,69,158,0,0,1,0,0,0,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT,FLOAT,FLOAT,FLOAT16,ND,NZ,FALSE,32,0,,FALSE,fp8 e4m3 weightnz static scale must be UINT64/INT64 or mx E8M0 pair |
| 392 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/131,,fp8e4m3-weightnz-dtype-error-mx-invalid-scale,,,2,2,2,0,0,0,122,192,16,0,0,1,0,0,2,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT,FLOAT,FLOAT16,ND,NZ,FALSE,32,0,,FALSE,fp8 e4m3 weightnz mx requires both scales E8M0 | 392 | Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/131,,fp8e4m3-weightnz-dtype-error-mx-invalid-scale,,,2,2,2,0,0,0,122,192,16,0,0,1,0,0,2,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT,FLOAT,FLOAT16,ND,NZ,FALSE,32,0,,FALSE,fp8 e4m3 weightnz mx requires both scales E8M0 |
| 393 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/132,,opt_base_tail_load_balance,,,2,2,2,0,0,0,403,256,15616,0,0,0,0,1,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,ND,TRUE,32,8452,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 3 0 0 0 403 15616 256 208 256 128 0 131074 0 65540 1 1 1 1 0 0,FALSE,opt base block load balance tail | ||
| 394 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/133,,opt_mx_afull_l1_estimate,,,3,3,3,1,1,1,88,1600,9120,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10756,88 9120 1600 1792 16777312 128 131072 65538 2097153 524289 65537 0 67592 516 0 0,FALSE,opt MX A full load L1 estimate | ||
| 395 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/134,,opt_mx_full_cover_scaleK,,,2,2,2,0,0,0,10240,1024,2624,0,1,0,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,10240 2624 1024 1024 16777472 128 131072 65538 2097153 65537 65537 0 50333704 258 0 0,FALSE,opt MX full cover scaleKL1 | ||
| 396 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/135,,opt_mx_halfk_scaleKL1,,,3,3,3,1,1,1,8,3072,1536,0,1,1,0,1,2,FLOAT8-E5M2,FLOAT8-E5M2,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,BF16,ND,ND,TRUE,32,10500,8 1536 3072 5120 3145744 640 262144 65540 2097153 65537 65537 0 67592 514 0 0,FALSE,opt MX halfK fallback scaleKL1 | ||
| 397 | +Ascend950,QUANTMM950/TestQuantBatchMatmulV3Tiling.generalTest/136,,opt_mx_stepk2_four_buffer,,,2,2,2,0,0,0,366,512,13312,0,1,0,0,1,2,FLOAT8-E4M3,FLOAT8-E4M3,FLOAT8-E8M0,FLOAT8-E8M0,FLOAT,FLOAT16,ND,ND,TRUE,32,10756,366 13312 512 512 16777408 128 131072 65538 2097153 262145 65537 0 50333704 260 0 0,FALSE,opt MX stepK2 four buffer fallback | ||
| 393 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/0,,quant_batch_matmul_v3_iter_batch,,,3,3,3,8,8,8,32,32,32,0,0,0,0,0,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,NZ,TRUE,8,1536,8 8 8 1 1 1 8 1 1 1 8 1 1 1 8 0 1 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 8 32 32 32 32 32 32 32 32 32 32 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 1 32 1 1 32 1 32 1 1 32 1 32 1 1 32 1 0 0 0 0 0 0 0 0 0 1 1 0 0,FALSE, | 398 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/0,,quant_batch_matmul_v3_iter_batch,,,3,3,3,8,8,8,32,32,32,0,0,0,0,0,0,INT8,INT8,UINT64,FLOAT,INT32,FLOAT16,ND,NZ,TRUE,8,1536,8 8 8 1 1 1 8 1 1 1 8 1 1 1 8 0 1 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 8 32 32 32 32 32 32 32 32 32 32 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 1 32 1 1 32 1 32 1 1 32 1 32 1 1 32 1 0 0 0 0 0 0 0 0 0 1 1 0 0,FALSE, |
| 394 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/1,,quant_batch_matmul_v3_jicheng_x2nz_transB,8,,2,2,2,0,0,0,32,64,64,0,0,1,0,1,1,INT8,INT8,UINT64,FLOAT,INT32,INT8,ND,NZ,TRUE,2,1284,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 32 64 64 64 16 64 64 16 128 64 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 399 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/1,,quant_batch_matmul_v3_jicheng_x2nz_transB,8,,2,2,2,0,0,0,32,64,64,0,0,1,0,1,1,INT8,INT8,UINT64,FLOAT,INT32,INT8,ND,NZ,TRUE,2,1284,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 32 64 64 64 16 64 64 16 128 64 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
| 395 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/2,,quant_batch_matmul_v3_jicheng_x2nz_notransB,8,,2,2,2,0,0,0,32,64,64,0,0,1,0,0,1,INT8,INT8,UINT64,FLOAT,INT32,INT8,ND,NZ,TRUE,2,1280,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 32 64 64 64 16 64 64 16 128 64 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, | 400 | MC62CM12AA,QUANTMMMC62CM12AA/TestQuantBatchMatmulV3Tiling.generalTest/2,,quant_batch_matmul_v3_jicheng_x2nz_notransB,8,,2,2,2,0,0,0,32,64,64,0,0,1,0,0,1,INT8,INT8,UINT64,FLOAT,INT32,INT8,ND,NZ,TRUE,2,1280,1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 32 64 64 64 16 64 64 16 128 64 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0,FALSE, |
Mmatmul/quant_batch_matmul_v4/op_host/op_tiling/arch35/adaptive_sliding_window_basic_api_v4_tiling.h+0-1
| @@ -26,7 +26,6 @@ public: | |||
| 26 | : AdaptiveSlidingWindowPerblockBasicAPITiling(context) | 26 | : AdaptiveSlidingWindowPerblockBasicAPITiling(context) |
| 27 | { | 27 | { |
| 28 | inputParams_.Reset(); | 28 | inputParams_.Reset(); |
| 29 | - ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 30 | } | 29 | } |
| 31 | ~AdaptiveSlidingWindowBasicTilingV4() override = default; | 30 | ~AdaptiveSlidingWindowBasicTilingV4() override = default; |
| 32 | uint64_t GetTilingKey() const override; | 31 | uint64_t GetTilingKey() const override; |
| @@ -27,7 +27,6 @@ public: | |||
| 27 | explicit AdaptiveSlidingWindowTilingV4(gert::TilingContext *context) : AdaptiveSlidingWindowCubeTiling(context) | 27 | explicit AdaptiveSlidingWindowTilingV4(gert::TilingContext *context) : AdaptiveSlidingWindowCubeTiling(context) |
| 28 | { | 28 | { |
| 29 | inputParams_.Reset(); | 29 | inputParams_.Reset(); |
| 30 | - ResetAdaptiveSlidingWindowPlatformInfoCache(); | ||
| 31 | } | 30 | } |
| 32 | ~AdaptiveSlidingWindowTilingV4() override = default; | 31 | ~AdaptiveSlidingWindowTilingV4() override = default; |
| 33 | uint64_t GetTilingKey() const override; | 32 | uint64_t GetTilingKey() const override; |


需要加注释