Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "all_reduce_operator.h"
12 : #include "device_capacity.h"
13 : #include "coll_alg_utils.h"
14 : #include "hccl_aiv.h"
15 : #include "coll_alg_op_registry.h"
16 :
17 : namespace hccl {
18 :
19 17 : AllReduceOperator::AllReduceOperator(AlgConfigurator* algConfigurator, CCLBufferManager &cclBufferManager,
20 17 : HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher> &topoMatcher)
21 17 : : CollAlgOperator(algConfigurator, cclBufferManager, dispatcher, topoMatcher, HcclCMDType::HCCL_CMD_ALLREDUCE)
22 : {
23 19 : }
24 :
25 40 : AllReduceOperator::~AllReduceOperator()
26 : {
27 40 : }
28 :
29 : // 如果逻辑有修改,需同步修改GetAllReduceScratchMemSize()
30 0 : HcclDataCountType AllReduceOperator::GetCountTypeForDeterAllReduce(const u64 count, const HcclDataType dataType)
31 : {
32 0 : u64 dataSize = SIZE_TABLE[dataType] * count;
33 0 : if ((GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OPS_KERNEL_INFO_LIB)) {
34 0 : if (dataSize <= HCCL_SMALL_COUNT_GRAPH_64_KB) {
35 0 : return HcclDataCountType::HCCL_COUNT_SMALL;
36 0 : } else if ((dataSize <= HCCL_MEDIUM_COUNT_GRAPH_4_MB) && (deviceNumPerAggregation_ == DEVICE_EIGHT)) {
37 0 : return HcclDataCountType::HCCL_COUNT_MEDIUM;
38 : } else {
39 0 : return HcclDataCountType::HCCL_COUNT_HUGE;
40 : }
41 : } else {
42 0 : if (dataSize <= HCCL_SMALL_COUNT_128_KB) {
43 0 : return HcclDataCountType::HCCL_COUNT_SMALL;
44 : } else {
45 0 : if (deviceNumPerAggregation_ == DEVICE_EIGHT) {
46 0 : return HcclDataCountType::HCCL_COUNT_MEDIUM;
47 : } else {
48 0 : return HcclDataCountType::HCCL_COUNT_HUGE;
49 : }
50 : }
51 : }
52 : }
53 :
54 : // 如果逻辑有修改,需同步修改GetAllReduceScratchMemSize()
55 0 : HcclResult AllReduceOperator::GetScratchSizeForDeterAllReduce(const u64 count, const HcclDataType dataType,
56 : const u32 rankSize, u64 &outScratchSize)
57 : {
58 : // 两卡不需要申请额外内存
59 0 : if (rankSize == DEVICE_TWO) {
60 0 : outScratchSize = 0;
61 0 : return HCCL_SUCCESS;
62 : }
63 :
64 0 : HcclDataCountType countType = GetCountTypeForDeterAllReduce(count, dataType);
65 0 : u64 memSize = SIZE_TABLE[dataType] * count;
66 0 : switch (countType) {
67 0 : case HcclDataCountType::HCCL_COUNT_SMALL:
68 : // 小数据量下,八卡选择HD算法、非八卡选择Reduce-Bcast算法
69 0 : if (rankSize == DEVICE_EIGHT) {
70 : // one shot HD算法,需要额外的(log2(N)-1)倍内存避免读写冲突
71 0 : outScratchSize = 0;
72 : } else {
73 : // Reduce-Bcast算法,需要N-1倍内存来暂存来自其他卡的数据(先收集数据,再本地Reduce到目的内存上)
74 0 : outScratchSize = memSize * (rankSize - 1);
75 : }
76 0 : break;
77 0 : case HcclDataCountType::HCCL_COUNT_MEDIUM:
78 : // 中数据量下,八卡选择Local Reduce算法,非八卡选择MeshChunk算法,都不要额外内存
79 0 : outScratchSize = 0;
80 0 : break;
81 0 : case HcclDataCountType::HCCL_COUNT_HUGE:
82 : // 大数据量下,统一选择MeshChunk算法,不需要额外内存
83 0 : outScratchSize = 0;
84 0 : break;
85 0 : default:
86 0 : return HCCL_E_NOT_SUPPORT;
87 : }
88 :
89 0 : HCCL_DEBUG("[GetScratchSizeForDeterAllReduce] countType=%u, rankSize=%u, memSize=%llu, outScratchSize=%llu",
90 : countType, rankSize, memSize, outScratchSize);
91 0 : return HCCL_SUCCESS;
92 : }
93 :
94 0 : HcclResult AllReduceOperator::GetAllReduceScratchSize(const u64 count, const HcclDataType dataType, u64 &scratchSize)
95 : {
96 : // 针对 单机、910B、确定性计算、图模式 的特殊优化
97 0 : if (algConfigurator_->SupportDeterministicOptim()) {
98 0 : CHK_RET(GetScratchSizeForDeterAllReduce(count, dataType, deviceNumPerAggregation_, scratchSize));
99 : } else {
100 0 : u64 reservedSize = (userRankSize_ + 1) * (userRankSize_ + 1) * SIZE_TABLE[dataType];
101 :
102 0 : scratchSize = count * SIZE_TABLE[dataType] * DEVICE_TWO + reservedSize;
103 : }
104 :
105 0 : HCCL_INFO("[AllReduceOperator][GetAllReduceScratchSize] scratchSize %llu, count %llu", scratchSize, count);
106 0 : return HCCL_SUCCESS;
107 : }
108 :
109 20 : HcclResult AllReduceOperator::SelectAlg(const std::string& tag, const OpParam& param, std::string& algName,
110 : std::string& newTag)
111 : {
112 20 : if (userRankSize_ == 1) {
113 0 : algName = "AllReduceSingleExecutor";
114 0 : HCCL_INFO("[SelectAlg] AllReduce SelectAlg is algName [%s]", algName.c_str());
115 0 : return HCCL_SUCCESS;
116 : }
117 : HcclResult ret;
118 20 : if (isDiffDeviceType_) {
119 0 : ret = SelectAlgforMix(param, algName);
120 20 : } else if (Is310P3Common(isHaveCpuRank_, deviceType_)) {
121 0 : if (is310PDuoCard_) {
122 0 : ret = SelectAlgfor310P3DUO(param, algName);
123 : } else {
124 0 : ret = SelectAlgfor310P3(param, algName);
125 : }
126 20 : } else if (Is310PDevice()) {
127 0 : ret = SelectAlgfor310PHelper(param, algName);
128 20 : } else if (deviceType_ == DevType::DEV_TYPE_910) {
129 0 : ret = SelectAlgfor910A(param, algName);
130 20 : } else if (deviceType_ == DevType::DEV_TYPE_910B) {
131 4 : ret = SelectAlgfor910B(param, algName);
132 16 : } else if (deviceType_ == DevType::DEV_TYPE_910_93) {
133 16 : ret = SelectAlgfor91093(param, algName);
134 : } else {
135 0 : HCCL_ERROR("[AllReduceOperator][SelectAlg] device type[%d] is out of range for selector.", deviceType_);
136 0 : return HCCL_E_NOT_SUPPORT;
137 : }
138 20 : CHK_PRT_RET(ret != HCCL_SUCCESS,
139 : HCCL_ERROR("[AllReduceSelector][SelectAlg]tag[%s], AllReduce failed, return[%d]", tag.c_str(), ret), ret);
140 :
141 20 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
142 5 : if (Is310P3Common(isHaveCpuRank_, deviceType_)) {
143 0 : newTag = tag + algName;
144 : } else {
145 5 : AlgTypeLevel1 algType1 = algType_.algoLevel1;
146 5 : auto level1Iter = HCCL_ALGO_LEVEL1_NAME_MAP.find(algType1);
147 5 : CHK_PRT_RET(level1Iter == HCCL_ALGO_LEVEL1_NAME_MAP.end(), HCCL_ERROR("level1: algType1[%u] is invalid.",
148 : algType1), HCCL_E_INTERNAL);
149 5 : newTag = tag + level1Iter->second + algName;
150 : }
151 :
152 5 : bool isInlineReduce = IsSupportSDMAReduce(cclBufferManager_.GetInCCLbuffer().ptr(),
153 5 : cclBufferManager_.GetOutCCLbuffer().ptr(), param.DataDes.dataType, param.reduceType);
154 5 : bool isRdmaReduce = IsSupportRDMAReduce(param.DataDes.dataType, param.reduceType);
155 5 : const std::string ALL_REDUCE_NO_INLINE = "_no_inline";
156 10 : newTag = (!isDiffDeviceType_ || (isDiffDeviceType_ && isInlineReduce && isRdmaReduce)) ?
157 5 : newTag : newTag + ALL_REDUCE_NO_INLINE;
158 5 : } else {
159 15 : newTag = tag;
160 : }
161 20 : if (algName == "AllReduceARSFor91093Executor") {
162 0 : u32 ringSize = CalcOptimalIntraRingsize(param.DataDes.count, param.DataDes.dataType, HcclCMDType::HCCL_CMD_ALLREDUCE);
163 0 : newTag += std::to_string(ringSize);
164 : }
165 20 : newTag += (param.aicpuUnfoldMode ? "_device" : "_host");
166 20 : return ret;
167 : }
168 :
169 0 : HcclResult AllReduceOperator::SelectAlgforMix(const OpParam& param, std::string& algName)
170 : {
171 : (void) param;
172 :
173 : // 混合组网场景不支持规约保序
174 0 : if (IsNeedStrictMode(param)) {
175 0 : HCCL_ERROR("[AllReduceOperator][SelectAlgforMix] not support DETERMINISTIC_STRICT mode.");
176 0 : return HCCL_E_NOT_SUPPORT;
177 : }
178 :
179 0 : if (gcdDeviceNumPerAggregation_ > 1) {
180 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_NHR;
181 0 : HCCL_WARNING("[AllReduceOperator][SelectAlgforMix] only support NHR in AlgoLevel1 yet, "\
182 : "default is algType=NHR.");
183 0 : algName = "AllReduceMixExecutor";
184 : } else {
185 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_RING;;
186 0 : HCCL_WARNING("[AllReduceOperator][SelectAlgforMix] only support ring in AlgoComm yet, "\
187 : "default is algType=ring.");
188 0 : algName = "AllReduceComm";
189 : }
190 :
191 0 : HCCL_INFO("[SelectAlgforMix] AllReduce SelectAlgforMix is algName [%s]", algName.c_str());
192 0 : return HCCL_SUCCESS;
193 : }
194 :
195 0 : HcclResult AllReduceOperator::SelectAlgfor310P3DUO(const OpParam& param, std::string& algName)
196 : {
197 : bool isInlineReduce =
198 0 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
199 0 : u64 dataSize = SIZE_TABLE[param.DataDes.dataType] * param.DataDes.count;
200 :
201 0 : bool isPowOfTwo = ((userRankSize_ - 1) & userRankSize_) == 0;
202 0 : const u32 RANK_SIZE_TWO = 2;
203 0 : const u32 RANK_SIZE_EIGHT = 8;
204 :
205 0 : if (isInlineReduce) {
206 0 : if ((dataSize <= HCCL_SMALL_COUNT_256_KB && isPowOfTwo && userRankSize_ <= RANK_SIZE_EIGHT) ||
207 0 : userRankSize_ == RANK_SIZE_TWO)
208 : {
209 0 : algType_.algoLevel0 = AlgTypeLevel0::ALG_LEVEL0_NP_HD;
210 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_HD;
211 0 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
212 0 : algName = "AllReduceDoublingDirect";
213 : } else {
214 0 : algName = "AllReduceDoubling";
215 : }
216 : }
217 : }
218 0 : if (algName.empty()) {
219 0 : algType_.algoLevel0 = AlgTypeLevel0::ALG_LEVEL0_WHOLE_RING;
220 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_WHOLE_RING;
221 0 : algName = "AllReduceRing";
222 : }
223 0 : HCCL_INFO("[SelectAlgfor310P3DUO] AllReduce SelectAlgfor310P3DUO is algName [%s].", algName.c_str());
224 0 : return HCCL_SUCCESS;
225 : }
226 :
227 0 : HcclResult AllReduceOperator::SelectAlgfor310P3(const OpParam& param, std::string& algName)
228 : {
229 0 : bool isPowOfTwo = ((userRankSize_ - 1) & userRankSize_) == 0;
230 0 : u64 dataSize = SIZE_TABLE[param.DataDes.dataType] * param.DataDes.count;
231 :
232 : bool isInlineReduce =
233 0 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
234 0 : if (isInlineReduce) {
235 0 : if (dataSize <= HCCL_SMALL_COUNT_256_KB && isPowOfTwo) {
236 0 : algType_.algoLevel0 = AlgTypeLevel0::ALG_LEVEL0_NP_HD;
237 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_HD;
238 0 : algName = "AllReduceDoubling";
239 : }
240 : }
241 0 : if (algName.empty()) {
242 0 : algType_.algoLevel0 = AlgTypeLevel0::ALG_LEVEL0_WHOLE_RING;
243 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_WHOLE_RING;
244 0 : algName = "AllReduceRing";
245 : }
246 0 : HCCL_INFO("[SelectAlgfor310P3] AllReduce SelectAlgfor310P3 is algName [%s].", algName.c_str());
247 0 : return HCCL_SUCCESS;
248 : }
249 :
250 0 : HcclResult AllReduceOperator::SelectAlgfor310PHelper(const OpParam& param, std::string& algName)
251 : {
252 : (void) param;
253 0 : algName = "AllReduceReducePlusBcast";
254 0 : HCCL_INFO("[SelectAlgfor310PHelper] AllReduce SelectAlgfor310PHelper is algName [%s]", algName.c_str());
255 0 : return HCCL_SUCCESS;
256 : }
257 :
258 0 : HcclResult AllReduceOperator::SelectAlgfor910A(const OpParam& param, std::string& algName)
259 : {
260 0 : const u32 RANK_SIZE_FOUR = 4;
261 0 : const u32 RANK_SIZE_EIGHT = 8;
262 0 : u64 dataSize = SIZE_TABLE[param.DataDes.dataType] * param.DataDes.count;
263 0 : bool isOpbase = GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
264 : bool isInlineReduce =
265 0 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
266 0 : bool isMeshTopo = topoType_ == TopoType::TOPO_TYPE_4P_MESH || topoType_ == TopoType::TOPO_TYPE_2P_MESH;
267 0 : bool isRingTopo = topoType_ == TopoType::TOPO_TYPE_NP_SINGLE_RING || topoType_ == TopoType::TOPO_TYPE_8P_RING;
268 :
269 0 : if (isOpbase && serverNum_ == 1 && dataSize <= HCCL_SMALL_COUNT_1_MB
270 0 : && (userRankSize_ == RANK_SIZE_FOUR || userRankSize_ == RANK_SIZE_EIGHT)) {
271 0 : algType_.algoLevel0 = AlgTypeLevel0::ALG_LEVEL0_NP_HD;
272 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_HD;
273 0 : if (isInlineReduce && userRankSize_ == RANK_SIZE_FOUR) {
274 0 : algName = "AllReduceDoublingDirect";
275 0 : } else if (isInlineReduce && userRankSize_ == RANK_SIZE_EIGHT) {
276 0 : algName = "AllReduceDoubling";
277 : } else {
278 0 : algName = "AllReduceSmallCountFor910";
279 : }
280 0 : } else if (isMeshTopo) {
281 0 : algName = "AllReduceMeshExecutor";
282 0 : } else if (isRingTopo) {
283 0 : algName = "AllReduceRingExecutor";
284 : } else {
285 0 : algName = "AllReduceComm";
286 : }
287 0 : HCCL_INFO("[SelectAlgfor910A] AllReduce SelectAlgfor910A is algName [%s]", algName.c_str());
288 0 : return HCCL_SUCCESS;
289 : }
290 :
291 3 : HcclResult AllReduceOperator::SelectAlgfor910B(const OpParam& param, std::string& algName)
292 : {
293 3 : HcclResult ret = HCCL_SUCCESS;
294 3 : u32 unitSize = SIZE_TABLE[param.DataDes.dataType];
295 :
296 3 : bool isOnlyAiv = topoMatcher_->GetIsOnlyAivConfig();
297 : bool isInlineReduce =
298 4 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
299 4 : bool isRdmaReduce = IsSupportRDMAReduce(param.DataDes.dataType, param.reduceType);
300 :
301 0 : bool isMeshTopo = topoType_ == TopoType::TOPO_TYPE_NP_MESH || topoType_ == TopoType::TOPO_TYPE_4P_MESH ||
302 4 : topoType_ == TopoType::TOPO_TYPE_2P_MESH || topoType_ == TopoType::TOPO_TYPE_1P_MESH;
303 4 : bool isRingTopo = topoType_ == TopoType::TOPO_TYPE_NP_SINGLE_RING;
304 :
305 4 : u64 dataSize = param.DataDes.count * unitSize; // 单位:字节
306 :
307 4 : void *commInputPtr = nullptr;
308 4 : void *commOutputPtr = nullptr;
309 4 : u64 commInputSize = 0;
310 4 : u64 commOutputSize = 0;
311 :
312 4 : CHK_RET(cclBufferManager_.GetInCCLbuffer(commInputPtr, commInputSize));
313 3 : CHK_RET(cclBufferManager_.GetOutCCLbuffer(commOutputPtr, commOutputSize));
314 :
315 : // aiv场景单独判断逻辑,满足AIV模式打开+支持AIVReduce+非确定性场景+外层为mesh+(单机/跨机小数据/跨机中数据)时进入分支
316 3 : bool isOpbase = (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
317 3 : bool isMesh = IsAlgTypeLevel0Mesh(algType_.algoLevel0);
318 3 : u64 rankCountSize = dataSize / deviceNumPerAggregation_;
319 3 : bool isServNumPowOfTwo = (serverNum_ > 0) && ((serverNum_ & (serverNum_ - 1)) == 0);
320 :
321 6 : bool isSupportAivRdmaSmallCount = !isSingleMeshAggregation_
322 0 : && !multiModuleDiffDeviceNumMode_
323 0 : && isServNumPowOfTwo
324 3 : && ((rankCountSize <= HCCL_SMALL_COUNT_190_KB || isOnlyAiv));
325 :
326 6 : bool isSupportAivRdmaMidCount = !isSingleMeshAggregation_
327 0 : && !multiModuleDiffDeviceNumMode_
328 3 : && (dataSize <= HCCL_MID_COUNT_16_MB);
329 :
330 3 : bool isSupportAivDeter = isSingleMeshAggregation_
331 3 : && (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_ENABLE)
332 5 : && (dataSize <= HCCL_SMALL_COUNT_8_MB);
333 :
334 2 : bool isCCLBufferGE16M = !isOpbase ||
335 0 : (commInputSize >= HCCL_MID_COUNT_16_MB && commOutputSize >= HCCL_MID_COUNT_16_MB);
336 :
337 2 : bool isBarrierOp = param.syncMode == SyncMode::UNLIMITED_TIMEWAITSYNCMODE; // Barrier算子不使能AIV
338 2 : bool isAivMode = (topoMatcher_->GetAivModeConfig() && !isBarrierOp)
339 0 : && IsSupportAIVReduce(param.DataDes.dataType, param.reduceType)
340 0 : && isMesh
341 0 : && isCCLBufferGE16M
342 0 : && (isSingleMeshAggregation_ || isSupportAivRdmaSmallCount || isSupportAivRdmaMidCount)
343 2 : && (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_DISABLE || isSupportAivDeter);
344 2 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
345 0 : std::string algTypeLevel1Tag;
346 0 : CHK_RET(AutoSelectAlgTypeLevel1(
347 : HcclCMDType::HCCL_CMD_ALLREDUCE, dataSize, commInputSize,
348 : algTypeLevel1Tag, isInlineReduce, isRdmaReduce, isAivMode));
349 0 : if (GetExternalInputHcclEnableEntryLog() && param.opBaseAtraceInfo != nullptr) {
350 0 : CHK_RET(param.opBaseAtraceInfo->SavealgtypeTraceInfo(algTypeLevel1Tag, param.tag));
351 : }
352 0 : }
353 :
354 : // AHC 算法选择逻辑
355 2 : if (((algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC) ||
356 2 : (algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC_BROKE))) {
357 0 : CHK_RET(SelectAlgforAHC(dataSize, AHCOpType::AHC_OP_TYPE_ALLREDUCE));
358 : }
359 :
360 : // pipeline算法task数量多,如果超出FFTS子图限制,则重定向到HD算法
361 : // 图模式不会重定向到HD算法
362 2 : if (algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_PIPELINE &&
363 0 : GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
364 0 : u32 contextNum = CalcContextNumForPipeline(HcclCMDType::HCCL_CMD_ALLREDUCE);
365 0 : if (contextNum > HCCL_FFTS_CAPACITY) {
366 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_HD;
367 0 : HCCL_WARNING("[AllReduceOperator][SelectAlgfor910B] context num[%u] is out of capacity of FFTS+ graph[%u], "
368 : "reset algorithm to HD.", contextNum, HCCL_FFTS_CAPACITY);
369 : }
370 : }
371 :
372 2 : if (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_STRICT && multiModuleDiffDeviceNumMode_) {
373 : // 保序规约场景(多batch一致),当前不支持非对称场景
374 0 : HCCL_ERROR("[SelectAlgfor910B] reduce order preservation only support Symmetry("
375 : "multiModuleDiffDeviceNumMode_[%d]).", multiModuleDiffDeviceNumMode_);
376 0 : return HCCL_E_NOT_SUPPORT;
377 : }
378 :
379 2 : if (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_STRICT &&
380 0 : (param.DataDes.dataType == HCCL_DATA_TYPE_FP16 || param.DataDes.dataType == HCCL_DATA_TYPE_FP32 ||
381 0 : param.DataDes.dataType == HCCL_DATA_TYPE_BFP16)) {
382 0 : if (param.aicpuUnfoldMode || (topoMatcher_->GetAivModeConfig() && !isBarrierOp)) {
383 : // AIV / AICPU场景,规约保序优先级更高
384 0 : HCCL_WARNING("[SelectAlgfor910B]aicpuMode[%d], AivModeConfig[%d], "
385 : "the Aiv/AICPU mode does not support when the reduce order preservation is enabled.",
386 : param.aicpuUnfoldMode, topoMatcher_->GetAivModeConfig());
387 : }
388 : // 只有浮点数存在多batch不一致的可能,整数天然一致
389 0 : algName = "AllReduceOrderPreservedExecutor";
390 2 : } else if (isAivMode) {
391 0 : if (isSupportAivDeter) {
392 0 : if (dataSize <= HCCL_SMALL_COUNT_8_MB){
393 0 : algName = "AllReduceAivDeterSmallExecutor";
394 : }else{
395 0 : algName = "AllReduceAivDeterExecutor";
396 : }
397 0 : HCCL_INFO("[SelectAlgfor910B] AllReduce SelectAlgfor910B is algName [%s].", algName.c_str());
398 0 : return HCCL_SUCCESS;
399 : }
400 0 : bool isOpbaseBigCount = isOpbase && (dataSize >= AIV_ALL_REDUCE_BIG_SIZE);
401 0 : HCCL_INFO("[SelectAlgfor910B] Select AivMode Alg: DataSize[%llu], RankCountSize[%llu], DeviceNumPerAgg [%u]",
402 : dataSize, rankCountSize, deviceNumPerAggregation_);
403 0 : if (isSupportAivRdmaSmallCount) {
404 0 : algName = "AllReduceSmallCountAivRdmaExecutor"; // 多server,满足二次幂,小数据量(单卡190K以内)
405 0 : } else if (isSupportAivRdmaMidCount) {
406 0 : algName = "AllReduceMidCountAivRdmaExecutor"; // 多server,中小数据量(总数据量16M以内)
407 0 : } else if (isOpbaseBigCount || !isOpbase) {
408 0 : algName = "AllReduceMeshAivExecutor"; // 单server,单算子AIV模式大数据 和 图模式AIV 共用一个Executor
409 : } else {
410 0 : algName = "AllReduceMeshAivSmallCountExecutor"; // 单server,单算子AIV模式小数据单独一个Executor
411 : }
412 : // 小于等于两卡场景单独判断逻辑
413 2 : } else if (deviceNumPerAggregation_ <= DEVICE_TWO) {
414 : // 动态图算子融合场景?
415 0 : if ((param.inputPtr == commInputPtr) && (param.outputPtr == commOutputPtr &&
416 0 : GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) && isMeshTopo) {
417 0 : algName = "AllReduceMeshExecutor";
418 : // 两卡不存在确定性问题 server内
419 0 : } else if (SingleMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType)) {
420 0 : ret = MeshTopoSelector(algName, dataSize);
421 0 : CHK_PRT_RET(ret != HCCL_SUCCESS,
422 : HCCL_ERROR("[SelectAlgfor910B] AllReduce MeshTopoSelector failed, return[%d]", ret), ret);
423 : // 标卡场景(只有2p)
424 0 : } else if (Is2U2PInfer()) {
425 0 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE && isInlineReduce) {
426 0 : algName = "AllReduceMeshOneshotLoopExecutor";
427 : } else {
428 0 : algName = "AllReduceRingExecutor";
429 : }
430 : // 多机单卡/两卡 pipeline需单独做判断(pipeline无确定性算法,并只支持单算子模式)
431 0 : } else if (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_DISABLE &&
432 0 : algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_PIPELINE &&
433 0 : IsMultiMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType)) {
434 0 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
435 0 : algName = "AllReduceMeshOpbasePipelineExecutor";
436 : } else {
437 0 : algName = "AllReduceMeshGraphPipelineExecutor";
438 : }
439 : // 常规910B为mesh拓扑
440 0 : } else if (isMeshTopo) {
441 0 : algName = "AllReduceMeshExecutor";
442 : // 多机单卡topo为ring
443 0 : } else if (isRingTopo) {
444 0 : algName = "AllReduceRingExecutor";
445 : // 通信域打平场景
446 : } else {
447 0 : algName = "AllReduceComm";
448 : }
449 : // 多卡场景
450 : } else {
451 2 : if (isMeshTopo) {
452 2 : if ((param.inputPtr == commInputPtr) && (param.outputPtr == commOutputPtr &&
453 0 : GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE)) {
454 0 : algName = "AllReduceMeshExecutor";
455 : // 非确定性算法
456 2 : } else if (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_DISABLE) {
457 2 : ret = NonDeterministicSelector(param, algName, dataSize);
458 : // 确定性算法
459 : } else {
460 0 : ret = DeterministicSelector(param, algName);
461 : }
462 3 : CHK_PRT_RET(ret != HCCL_SUCCESS,
463 : HCCL_ERROR("[SelectAlgfor910B] AllReduce SelectAlgfor910B failed, return[%d]", ret), ret);
464 3 : if (algName.empty()) {
465 3 : algName = "AllReduceMeshExecutor";
466 : }
467 : } else {
468 0 : algName = "AllReduceComm";
469 : }
470 : }
471 : // 如果配置了aiv only,但是实际没有选择aiv算法,需要通过DFX打印出具体原因
472 4 : if (isOnlyAiv && !isAivMode) {
473 0 : HCCL_ERROR("The current conditions do not meet the aiv only execution criteria because:");
474 0 : CHK_PRT_RET(!IsSupportAIVReduce(param.DataDes.dataType, param.reduceType), HCCL_ERROR("current data type[%s] or reduceType[%s] not supported, "\
475 : "data type support range:[int8, int16, int32, float16, float32, bfloat16] reduce type support range:[sum, max, min]",
476 : GetDataTypeEnumStr(param.DataDes.dataType).c_str(), GetReduceOpEnumStr(param.reduceType).c_str()), HCCL_E_NOT_SUPPORT);
477 :
478 0 : CHK_PRT_RET(!isMesh, HCCL_ERROR("current algoLevel0Mesh[%d] not supported", algType_.algoLevel0), HCCL_E_NOT_SUPPORT);
479 :
480 0 : CHK_PRT_RET(!isCCLBufferGE16M, HCCL_ERROR("current isOpbase[%d] or commInputSize[%llu] or commOutputSize[%llu] not supported",
481 : isOpbase, commInputSize, commOutputSize), HCCL_E_NOT_SUPPORT);
482 :
483 0 : CHK_PRT_RET(!isSingleMeshAggregation_ && multiModuleDiffDeviceNumMode_,
484 : HCCL_ERROR("The number of cards between servers in a multi-server setup must be consistent. "\
485 : "isSingleMeshAggregation_[%d] multiModuleDiffDeviceNumMode_[%d]",
486 : isSingleMeshAggregation_, multiModuleDiffDeviceNumMode_), HCCL_E_NOT_SUPPORT);
487 :
488 0 : CHK_PRT_RET(!isServNumPowOfTwo, HCCL_ERROR("server num[%u] is pow of two.", serverNum_), HCCL_E_NOT_SUPPORT);
489 :
490 0 : CHK_PRT_RET(!isSupportAivRdmaMidCount, HCCL_ERROR("current data size[%llu] not support aiv rdma mid count.", dataSize), HCCL_E_NOT_SUPPORT);
491 :
492 0 : CHK_PRT_RET(!isSupportAivDeter, HCCL_ERROR("is not support aiv deter.isSingleMeshAggregation_[%d] isOpbase[%d] deterministic config[%u], dataSize[%llu]",
493 : isSingleMeshAggregation_, isOpbase, topoMatcher_->GetDeterministicConfig(), dataSize), HCCL_E_NOT_SUPPORT);
494 0 : return HCCL_E_NOT_SUPPORT;
495 : }
496 4 : HCCL_INFO("[SelectAlgfor910B] AllReduce SelectAlgfor910B is algName [%s].", algName.c_str());
497 4 : return HCCL_SUCCESS;
498 : }
499 :
500 0 : HcclResult AllReduceOperator::MeshTopoSelector(std::string& algName, u64 unitSize)
501 : {
502 : // 单算子选择逻辑
503 0 : if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
504 0 : if (unitSize <= HCCL_SMALL_COUNT_256_KB) {
505 0 : algName = "AllReduceMeshSmallCountExecutor";
506 : } else {
507 0 : algName = "AllReduceMeshOpbaseLoopExecutor";
508 : }
509 : // 图模式选择逻辑
510 : } else {
511 0 : if (unitSize <= HCCL_SMALL_COUNT_GRAPH_64_KB) {
512 0 : algName = "AllReduceMeshSmallCountExecutor";
513 : } else {
514 0 : algName = "AllReduceMeshExecutor";
515 : }
516 : }
517 0 : return HCCL_SUCCESS;
518 : }
519 :
520 3 : HcclResult AllReduceOperator::NonDeterministicSelector(const OpParam& param, std::string& algName, u64 dataSize)
521 : {
522 3 : const bool isOpbase = GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
523 3 : if (isOpbase) {
524 0 : if (IsMultiMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType) &&
525 0 : algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_PIPELINE) {
526 0 : algName = "AllReduceMeshOpbasePipelineExecutor";
527 0 : } else if (SingleMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType)) {
528 0 : if (dataSize <= HCCL_SMALL_COUNT_256_KB) {
529 0 : algName = "AllReduceMeshSmallCountExecutor";
530 : } else {
531 0 : algName = "AllReduceMeshOpbaseLoopExecutor";
532 : }
533 : }
534 3 : } else if (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OPS_KERNEL_INFO_LIB &&
535 3 : IsMultiMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType) &&
536 0 : algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_PIPELINE) {
537 0 : algName = "AllReduceMeshGraphPipelineExecutor";
538 : }
539 3 : if (!algName.empty() || !isOpbase) {
540 3 : return HCCL_SUCCESS;
541 : }
542 : const bool isInlineReduce =
543 0 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
544 : // 单算子 + 数据量小于512kB
545 0 : if (dataSize < HCCL_SMALL_COUNT_512_KB && !isSingleMeshAggregation_ && isInlineReduce) {
546 0 : algName = "AllReduceMeshOpbaseSmallCountDeterministicExecutor";
547 : }
548 0 : return HCCL_SUCCESS;
549 : }
550 :
551 0 : HcclResult AllReduceOperator::DeterministicSelector(const OpParam& param, std::string& algName)
552 : {
553 : // 确定性图和单算子归一流程
554 0 : HcclDataCountType countType = GetCountTypeForDeterAllReduce(param.DataDes.count, param.DataDes.dataType);
555 0 : const bool isOpbase = GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
556 : const bool isInlineReduce =
557 0 : IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
558 :
559 0 : if (isOpbase && algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_PIPELINE && deviceNumPerAggregation_ > DEVICE_TWO) {
560 0 : u64 dataSize = param.DataDes.count * SIZE_TABLE[param.DataDes.dataType];
561 0 : if (dataSize >= deviceNumPerAggregation_ * HCCL_MIN_SLICE_ALIGN) {
562 0 : algName = "AllReduceDeterPipelineExecutor";
563 0 : return HCCL_SUCCESS;
564 : }
565 : }
566 0 : if (SingleMeshInlineReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType)) {
567 0 : if (countType == HcclDataCountType::HCCL_COUNT_SMALL) {
568 0 : algName = "AllReduceMeshSmallCountExecutor";
569 0 : } else if (countType == HcclDataCountType::HCCL_COUNT_MEDIUM) {
570 0 : algName = "AllReduceMeshMidCountLoopExecutor";
571 : } else {
572 0 : algName = "AllReduceMeshOneshotLoopExecutor";
573 : }
574 : } else {
575 0 : u64 dataSize = param.DataDes.count * SIZE_TABLE[param.DataDes.dataType];
576 0 : if (isOpbase && !isSingleMeshAggregation_ && isInlineReduce) {
577 0 : if (dataSize <= HCCL_SMALL_COUNT_512_KB) {
578 : // 单算子 + 确定性 + 数据量小于512kB
579 0 : algName = "AllReduceMeshOpbaseSmallCountDeterministicExecutor";
580 : } else {
581 0 : algName = "AllReduceMeshOpbaseMidCountDeterministicExecutor";
582 : }
583 : }
584 : }
585 0 : return HCCL_SUCCESS;
586 : }
587 :
588 16 : HcclResult AllReduceOperator::SelectAlgfor91093(const OpParam& param, std::string& algName)
589 : {
590 16 : u32 unitSize = SIZE_TABLE[param.DataDes.dataType];
591 16 : u64 dataSize = param.DataDes.count * unitSize; // 单位:字节
592 16 : if (dataSize >= cclBufferManager_.GetInCCLbufferSize()) {
593 16 : HCCL_WARNING("The current inCCLbufferSize is [%llu] bytes, change the HCCL_BUFFSIZE environment variable "\
594 : "to be greater than the current data volume[%llu] bytes to improve the performance of the 91093 environment.",
595 : cclBufferManager_.GetInCCLbufferSize(), dataSize);
596 : }
597 :
598 16 : u64 dataSizePerRank = dataSize / deviceNumPerAggregation_;
599 16 : bool isOpbase = workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
600 16 : bool isOnlyAiv = topoMatcher_->GetIsOnlyAivConfig();
601 : // A3 AIV确定性 超节点内(单机与跨机) 支持单算子与图模式 限制单卡数据量8MB
602 16 : bool isBarrierOp = param.syncMode == SyncMode::UNLIMITED_TIMEWAITSYNCMODE; // Barrier算子不使能AIV
603 16 : bool isSupportAivDeter = (superPodNum_ == 1)
604 0 : && (topoMatcher_->GetAivModeConfig() && !isBarrierOp)
605 0 : && IsSupportAIVReduce(param.DataDes.dataType, param.reduceType)
606 0 : && ((topoMatcher_->GetDeterministicConfig() != DETERMINISTIC_DISABLE) || (serverNum_ > 1))
607 0 : && ((userRankSize_ > DEVICE_EIGHT && dataSize < HCCL_SMALL_COUNT_8_MB) ||
608 0 : (userRankSize_ <= DEVICE_EIGHT && dataSize <= HCCL_SMALL_COUNT_512_KB) || isOnlyAiv)
609 0 : && (!retryEnable_)
610 0 : && userRankSize_ > 1
611 16 : && !multiModuleDiffDeviceNumMode_;
612 :
613 16 : bool isAivMode = (topoMatcher_->GetAivModeConfig() && !isBarrierOp)
614 0 : && IsSupportAIVReduce(param.DataDes.dataType, param.reduceType)
615 0 : && serverNum_ == 1
616 0 : && ((isOpbase && (dataSizePerRank <= AIV_ALL_REDUCE_A3_ENTRY_SIZE || isOnlyAiv))
617 0 : || (!isOpbase && (dataSizePerRank <= AIV_ALL_REDUCE_A3_GRAPH_ENTRY_SIZE || isOnlyAiv)))
618 0 : && (topoMatcher_->GetDeterministicConfig() == DETERMINISTIC_DISABLE)
619 0 : && (!retryEnable_)
620 16 : && !multiModuleDiffDeviceNumMode_;
621 :
622 16 : if (isSupportAivDeter) {
623 0 : algName = "AllReduceMeshAivFor91093Executor";
624 0 : HCCL_INFO("[SelectAlgfor91093] allreduce SelectAlgfor91093 algName [%s].", algName.c_str());
625 0 : return HCCL_SUCCESS;
626 : }
627 :
628 16 : if (IsNeedStrictMode(param)) {
629 0 : CHK_PRT_RET(!CheckStrictCondition(param),
630 : HCCL_ERROR("[AllReduceOperator][SelectAlgfor91093] not support DETERMINISTIC_STRICT mode."),
631 : HCCL_E_NOT_SUPPORT);
632 :
633 0 : algName = "AllReduceOrderPreservedFor91093Executor";
634 0 : HCCL_INFO("[SelectAlgfor91093] allreduce SelectAlgfor91093 algName [%s].", algName.c_str());
635 0 : return HCCL_SUCCESS;
636 : }
637 :
638 16 : if (isAivMode) {
639 0 : HCCL_INFO("[SelectAlgfor91093] dataSize[%llu], dataSizePerRank[%llu], deviceNumPerAggregation[%u]",
640 : dataSize, dataSizePerRank, deviceNumPerAggregation_);
641 0 : if ((isOpbase && dataSize < AIV_ALL_REDUCE_BIG_SIZE) ||
642 0 : (!isOpbase && dataSize <= AIV_A3_ALL_REDUCE_GRAPH_GUIYI_SIZE)) {
643 0 : algName = "AllReduceMeshAivSmallCountExecutor"; // 单server小数据
644 : } else {
645 0 : algName = "AllReduceMeshAivExecutor"; // 单server大数据
646 : }
647 0 : HCCL_INFO("[SelectAlgfor91093] AllReduce SelectAlgfor91093 is algName [%s].", algName.c_str());
648 0 : return HCCL_SUCCESS;
649 : }
650 : // ARS 算法选择
651 16 : bool isARSAlgo = multiModuleDiffDeviceNumMode_ && !multiSuperPodDiffDeviceNumMode_;
652 16 : if (isARSAlgo) {
653 0 : if (!(algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_NB || algType_.algoLevel1 ==
654 : AlgTypeLevel1::ALG_LEVEL1_RING)) {
655 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_NHR;
656 0 : HCCL_WARNING("[AllReduceOperator][SelectAlgfor91093] ARS only support NHR or RING in AlgoLevel1 "\
657 : "yet, default is NHR.");
658 : }
659 : }
660 : // AHC 算法选择逻辑
661 16 : if ((algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC) ||
662 8 : (algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_AHC_BROKE)) {
663 9 : CHK_RET(SelectAlgforAHC(dataSize, AHCOpType::AHC_OP_TYPE_ALLREDUCE));
664 : }
665 16 : void *commInputPtr = nullptr;
666 16 : u64 commInputSize = 0;
667 16 : CHK_RET(cclBufferManager_.GetInCCLbuffer(commInputPtr, commInputSize));
668 21 : bool cclLimit = (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) &&
669 5 : (param.DataDes.count * SIZE_TABLE[param.DataDes.dataType] > (commInputSize / HCCL_MEMSIZE_HD_FACTOR));
670 :
671 16 : bool isSupportInlineReduce = IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.DataDes.dataType, param.reduceType);
672 16 : bool smallCountOptimSingleServer =
673 32 : (!retryEnable_) &&
674 16 : (serverNum_ == 1) &&
675 1 : ((workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) ||
676 1 : (workflowMode_ != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE && !param.aicpuUnfoldMode)) &&
677 1 : isSupportInlineReduce &&
678 1 : (deviceNumPerAggregation_ > HCCL_DEVICE_NUM_TWO) &&
679 33 : (param.DataDes.count * SIZE_TABLE[param.DataDes.dataType] <= HCCL_SMALL_COUNT_512_KB * userRankSize_) &&
680 1 : !cclLimit;
681 16 : bool smallCountOptimMultiServer =
682 16 : (deviceNumPerAggregation_ > HCCL_DEVICE_NUM_TWO) && (serverNum_ != 1) && (superPodNum_ == 1) &&
683 0 : (param.DataDes.count * SIZE_TABLE[param.DataDes.dataType] <= HCCL_SMALL_COUNT_1_MB * deviceNumPerAggregation_);
684 17 : bool useHostComm = !isSupportInlineReduce && ((serverNum_ != 1 && superPodNum_ == 1 && !GetExternalInputInterHccsDisable())
685 1 : || ((superPodNum_ > 1 || GetExternalInputInterHccsDisable()) && !retryEnable_
686 0 : && param.DataDes.count * SIZE_TABLE[param.DataDes.dataType] <= HCCL_SMALL_COUNT_4_MB * deviceNumPerAggregation_));
687 16 : bool is2Pod2ServerTopo = (superPodNum_ == 2 && serverNum_ == 2);// 针对 A3背靠背机型
688 16 : bool smallCountOptimMultiPod = (superPodNum_ > 1 || (GetExternalInputInterHccsDisable() && serverNum_ > 1)) && !is2Pod2ServerTopo &&
689 32 : (param.DataDes.count * unitSize <= HCCL_SMALL_COUNT_16_KB * deviceNumPerAggregation_) && !retryEnable_; // 涉及ROCE平面
690 : // 多超节点 的中等数据量
691 11 : bool midCountOptimMultiPod = (superPodNum_ > 1 ) && isOpbase && !multiSuperPodDiffDeviceNumMode_ && !multiModuleDiffDeviceNumMode_ &&
692 27 : (param.DataDes.count * unitSize <= HCCL_SMALL_COUNT_256_KB) && !retryEnable_; // 涉及ROCE平面
693 :
694 16 : if (multiModuleDiffDeviceNumMode_ && multiSuperPodDiffDeviceNumMode_) {
695 0 : algName = "AllReduceComm";
696 16 : } else if (multiModuleDiffDeviceNumMode_ && !multiSuperPodDiffDeviceNumMode_) {
697 0 : algName = "AllReduceARSFor91093Executor";
698 16 : } else if (midCountOptimMultiPod) {
699 1 : algName = "AllReduceMidCountFor91093Executor";
700 15 : } else if (useHostComm || smallCountOptimMultiServer || smallCountOptimMultiPod) {
701 10 : algName = "AllReduceComm";
702 10 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_NHR;
703 5 : } else if (smallCountOptimSingleServer) {
704 0 : algName = "AllReduceMeshSmallCountExecutor";
705 5 : } else if ((param.supportSymmetricMemory || param.supportZeroCopy) &&
706 0 : (topoType_ == TopoType::TOPO_TYPE_NP_DOUBLE_RING || param.DataDes.count * unitSize > HCCL_MID_COUNT_16_MB * serverNum_)) {
707 0 : algName = "AllReduceRingZerocopyExecutor";
708 : } else {
709 5 : if (algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_HD) {
710 0 : algType_.algoLevel1 = AlgTypeLevel1::ALG_LEVEL1_NHR;
711 0 : HCCL_WARNING("[AllReduceOperator][SelectAlgfor91093] only support ring, NB and NHR in AlgoLevel1 yet, "\
712 : "default is algType=NHR.");
713 : }
714 5 : if (topoType_ == TopoType::TOPO_TYPE_NP_DOUBLE_RING) {
715 4 : algName = "AllReduceFastDoubleRingFor91093Executor";
716 1 : } else if (topoType_ == TopoType::TOPO_TYPE_NP_SINGLE_RING) {
717 1 : algName = "AllReduceRingFor91093Executor";
718 : } else {
719 0 : algName = "AllReduceComm"; // 支持91093全通信域
720 : }
721 : }
722 : // 如果配置了aiv only,但是实际没有选择aiv算法,需要通过DFX打印出具体原因
723 16 : if (isOnlyAiv && !isAivMode && !isSupportAivDeter) {
724 0 : HCCL_ERROR("The current conditions do not meet the aiv only execution criteria because:");
725 0 : CHK_PRT_RET(!IsSupportAIVReduce(param.DataDes.dataType, param.reduceType), HCCL_ERROR("current data type[%s] or reduceType[%s] not supported, "\
726 : "data type support range:[int8, int16, int32, float16, float32, bfloat16] reduce type support range:[sum, max, min]",
727 : GetDataTypeEnumStr(param.DataDes.dataType).c_str(), GetReduceOpEnumStr(param.reduceType).c_str()), HCCL_E_NOT_SUPPORT);
728 :
729 0 : CHK_PRT_RET(retryEnable_, HCCL_ERROR("retryEnable [%d] not supported", retryEnable_), HCCL_E_NOT_SUPPORT);
730 :
731 0 : CHK_PRT_RET(superPodNum_ != 1, HCCL_ERROR("multi superpod [%u] not supported", superPodNum_), HCCL_E_NOT_SUPPORT);
732 :
733 0 : CHK_PRT_RET(multiModuleDiffDeviceNumMode_, HCCL_ERROR("multiModuleDiffDeviceNumMode [%d] not supported", multiModuleDiffDeviceNumMode_), HCCL_E_NOT_SUPPORT);
734 0 : return HCCL_E_NOT_SUPPORT;
735 : }
736 16 : HCCL_INFO("[SelectAlgfor91093] AllReduce SelectAlgfor91093 is algName [%s].", algName.c_str());
737 16 : return HCCL_SUCCESS;
738 : }
739 :
740 : REGISTER_OP(HcclCMDType::HCCL_CMD_ALLREDUCE, AllReduce, AllReduceOperator);
741 :
742 : }
|