已合并
[fix]确定性计算strict模式放行910_93 #4485
weixin_47168537创建于 8月7日
[fix]确定性计算strict模式放行910_93 #4485
已合并
共 6 个文件变更+30-28
| @@ -55,22 +55,16 @@ typedef struct HcclCommConfigDef { | |||
| 55 | <!-- npu="950" id1 --> | 55 | <!-- npu="950" id1 --> |
| 56 | - Ascend 950PR/Ascend 950DT:不支持此配置,可通过HCCL_DETERMINISTIC环境变量配置全局确定性计算开关。 | 56 | - Ascend 950PR/Ascend 950DT:不支持此配置,可通过HCCL_DETERMINISTIC环境变量配置全局确定性计算开关。 |
| 57 | <!-- end id1 --> | 57 | <!-- end id1 --> |
| 58 | - <!-- npu="A3" id2 --> | ||
| 59 | - - Atlas A3 训练系列产品/Atlas A3 推理系列产品,支持的取值及含义如下: | ||
| 60 | - - 0(默认值):代表关闭确定性计算。 | ||
| 61 | - - 1:开启归约类通信算子的确定性计算,支持通信算子AllReduce和ReduceScatter。 | ||
| 62 | - - 2:单算子模式下配置为“2“时与配置为“1“的功能保持一致;静态图模式下暂不支持配置为“2”。 | ||
| 63 | - <!-- end id2 --> | ||
| 64 | 58 | ||
| 65 | - <!-- npu="910b" id3 --> | 59 | + <!-- npu="910b,A3" id2 --> |
| 66 | - - Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持的取值及含义如下: | 60 | + - Atlas A2 训练系列产品/Atlas A2 推理系列产品和Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持的取值及含义如下: |
| 67 | - 0(默认值):代表关闭确定性计算。 | 61 | - 0(默认值):代表关闭确定性计算。 |
| 68 | - 1:开启归约类通信算子的确定性计算,支持通信算子AllReduce、ReduceScatter、Reduce、ReduceScatterV。 | 62 | - 1:开启归约类通信算子的确定性计算,支持通信算子AllReduce、ReduceScatter、Reduce、ReduceScatterV。 |
| 69 | - 2:开启归约类通信算子的严格确定性计算,即保序功能(在确定性的基础上保证所有bit位的归约顺序均一致)。支持通信算子为AllReduce、ReduceScatter、ReduceScatterV,配置为该参数时需满足以下条件: | 63 | - 2:开启归约类通信算子的严格确定性计算,即保序功能(在确定性的基础上保证所有bit位的归约顺序均一致)。支持通信算子为AllReduce、ReduceScatter、ReduceScatterV,配置为该参数时需满足以下条件: |
| 70 | - 仅支持多机对称分布场景,不支持非对称分布的场景。 | 64 | - 仅支持多机对称分布场景,不支持非对称分布的场景。 |
| 71 | - 开启保序时,不支持饱和模式,仅支持INF/NaN模式。 | 65 | - 开启保序时,不支持饱和模式,仅支持INF/NaN模式。 |
| 72 | - 相较于确定性计算,开启保序功能后会产生一定的性能下降,建议在推理场景下使用该功能。 | 66 | - 相较于确定性计算,开启保序功能后会产生一定的性能下降,建议在推理场景下使用该功能。 |
| 73 | - <!-- end id3 --> | 67 | + <!-- end id2 --> |
| 74 | 68 | ||
| 75 | > [!NOTE]说明 | 69 | > [!NOTE]说明 |
| 76 | > 在不开启确定性计算的场景下,多次执行的结果可能不同。这个差异的来源,一般是因为在算子实现中存在异步的多线程执行,会导致浮点数累加的顺序变化。当开启确定性计算后,算子在相同的硬件和输入下,多次执行将产生相同的输出。 | 70 | > 在不开启确定性计算的场景下,多次执行的结果可能不同。这个差异的来源,一般是因为在算子实现中存在异步的多线程执行,会导致浮点数累加的顺序变化。当开启确定性计算后,算子在相同的硬件和输入下,多次执行将产生相同的输出。 |
| @@ -292,15 +292,15 @@ HcclResult CommConfig::SetConfigDeterministic(const CommConfigHandle& config) | |||
| 292 | if (config.deterministic == DETERMINISTIC_STRICT) { | 292 | if (config.deterministic == DETERMINISTIC_STRICT) { |
| 293 | DevType deviceType; | 293 | DevType deviceType; |
| 294 | CHK_RET(hrtGetDeviceType(deviceType)); | 294 | CHK_RET(hrtGetDeviceType(deviceType)); |
| 295 | - if (deviceType != DevType::DEV_TYPE_910B) { | 295 | + if (deviceType != DevType::DEV_TYPE_910B && deviceType != DevType::DEV_TYPE_910_93) { |
| 296 | RPT_INPUT_ERR( | 296 | RPT_INPUT_ERR( |
| 297 | true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}), | 297 | true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}), |
| 298 | std::vector<std::string>( | 298 | std::vector<std::string>( |
| 299 | {"HcclCommInitRootInfoConfig", std::to_string(config.deterministic), "hcclDeterministic", | 299 | {"HcclCommInitRootInfoConfig", std::to_string(config.deterministic), "hcclDeterministic", |
| 300 | - "set to 2(strict), only support A2."})); | 300 | + "set to 2(strict), only support A2/A3."})); |
| 301 | HCCL_ERROR( | 301 | HCCL_ERROR( |
| 302 | "[%s][%s] The configuration of hcclDeterministic[%u] is set to " | 302 | "[%s][%s] The configuration of hcclDeterministic[%u] is set to " |
| 303 | - "2(strict), and only support A2", | 303 | + "2(strict), and only support A2/A3", |
| 304 | LOG_KEYWORDS_TASK_EXEC.c_str(), LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), config.deterministic); | 304 | LOG_KEYWORDS_TASK_EXEC.c_str(), LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), config.deterministic); |
| 305 | return HCCL_E_PARA; | 305 | return HCCL_E_PARA; |
| 306 | } | 306 | } |
| @@ -2316,7 +2316,8 @@ HcclResult HcclSetConfig([[maybe_unused]] HcclConfig config, [[maybe_unused]] Hc | |||
| 2316 | } else { | 2316 | } else { |
| 2317 | DevType devType; | 2317 | DevType devType; |
| 2318 | CHK_RET(hrtGetDeviceType(devType)); | 2318 | CHK_RET(hrtGetDeviceType(devType)); |
| 2319 | - if (configValue.value == DETERMINISTIC_STRICT && devType != DevType::DEV_TYPE_910B) { | 2319 | + if (configValue.value == DETERMINISTIC_STRICT && devType != DevType::DEV_TYPE_910B |
| 2320 | + && devType != DevType::DEV_TYPE_910_93) { | ||
| 2320 | HCCL_ERROR( | 2321 | HCCL_ERROR( |
| 2321 | "[HcclSetConfig] configValue[%d], reduce order preservation is not supported for" | 2322 | "[HcclSetConfig] configValue[%d], reduce order preservation is not supported for" |
| 2322 | " devType[%d]", | 2323 | " devType[%d]", |
| @@ -51,7 +51,7 @@ TEST_F(HcclGetConfigTest, Ut_HcclGetConfig_When_SetFailed_Expect_ReturnValueIsDE | |||
| 51 | { | 51 | { |
| 52 | union HcclConfigValue hcclConfigValue; | 52 | union HcclConfigValue hcclConfigValue; |
| 53 | union HcclConfigValue hcclConfigValueRet; | 53 | union HcclConfigValue hcclConfigValueRet; |
| 54 | - DevType deviceType = DevType::DEV_TYPE_910_93; | 54 | + DevType deviceType = DevType::DEV_TYPE_910; |
| 55 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); | 55 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); |
| 56 | hcclConfigValue.value = 2; | 56 | hcclConfigValue.value = 2; |
| 57 | HcclResult ret = HcclSetConfig(HCCL_DETERMINISTIC, hcclConfigValue); | 57 | HcclResult ret = HcclSetConfig(HCCL_DETERMINISTIC, hcclConfigValue); |
| @@ -35,8 +35,18 @@ TEST_F(HcclSetConfigTest, Ut_HcclSetConfig_When_ConfigValueIsNotInDeterministicE | |||
| 35 | EXPECT_EQ(ret, HCCL_E_PARA); | 35 | EXPECT_EQ(ret, HCCL_E_PARA); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | -TEST_F( | 38 | +TEST_F(HcclSetConfigTest, Ut_HcclSetConfig_When_StrictButDevTypeNotSupport_Expect_ReturnIsHCCL_E_NOT_SUPPORT) |
| 39 | - HcclSetConfigTest, Ut_HcclSetConfig_When_ConfigValueIsSTRICTButDevTypeIsNot910B_Expect_ReturnIsHCCL_E_NOT_SUPPORT) | 39 | +{ |
| 40 | + HcclConfigValue value; | ||
| 41 | + value.value = DETERMINISTIC_STRICT; | ||
| 42 | + DevType deviceType = DevType::DEV_TYPE_910; | ||
| 43 | + MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); | ||
| 44 | + | ||
| 45 | + HcclResult ret = HcclSetConfig(HCCL_DETERMINISTIC, value); | ||
| 46 | + EXPECT_EQ(ret, HCCL_E_NOT_SUPPORT); | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +TEST_F(HcclSetConfigTest, Ut_HcclSetConfig_When_ConfigValueIsSTRICTAndDevTypeIs910_93_Expect_ReturnIsHCCL_SUCCESS) | ||
| 40 | { | 50 | { |
| 41 | HcclConfigValue value; | 51 | HcclConfigValue value; |
| 42 | value.value = DETERMINISTIC_STRICT; | 52 | value.value = DETERMINISTIC_STRICT; |
| @@ -44,7 +54,7 @@ TEST_F( | |||
| 44 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); | 54 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); |
| 45 | 55 | ||
| 46 | HcclResult ret = HcclSetConfig(HCCL_DETERMINISTIC, value); | 56 | HcclResult ret = HcclSetConfig(HCCL_DETERMINISTIC, value); |
| 47 | - EXPECT_EQ(ret, HCCL_E_NOT_SUPPORT); | 57 | + EXPECT_EQ(ret, HCCL_SUCCESS); |
| 48 | } | 58 | } |
| 49 | 59 | ||
| 50 | TEST_F(HcclSetConfigTest, Ut_HcclSetConfigTest_When_Normal_Expect_ReturnIsHCCL_SUCCESS) | 60 | TEST_F(HcclSetConfigTest, Ut_HcclSetConfigTest_When_Normal_Expect_ReturnIsHCCL_SUCCESS) |
| @@ -319,31 +319,28 @@ TEST_F(CommConfigTest, Ut_GetAicpuUnfoldConfig_When_SetConfigOpExpansionMode_Aic | |||
| 319 | GlobalMockObject::verify(); | 319 | GlobalMockObject::verify(); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | -#if 0 | 322 | +TEST_F(CommConfigTest, utCommConfig_deterministic_strcit_910_93_success) |
| 323 | - | ||
| 324 | -TEST_F(CommConfigTest, utCommConfig_deterministic_strcit_fail) | ||
| 325 | { | 323 | { |
| 326 | MOCKER(GetExternalInputCCLBuffSize) | 324 | MOCKER(GetExternalInputCCLBuffSize) |
| 327 | - .stubs() | 325 | + .stubs() |
| 328 | - .will(returnValue(static_cast<u64>(200 * HCCL_CCL_COMM_FIXED_CALC_BUFFER_SIZE))); | 326 | + .will(returnValue(static_cast<u64>(200 * HCCL_CCL_COMM_FIXED_CALC_BUFFER_SIZE))); |
| 329 | 327 | ||
| 330 | MOCKER(GetExternalInputHcclDeterministicV2).stubs().will(returnValue(0)); | 328 | MOCKER(GetExternalInputHcclDeterministicV2).stubs().will(returnValue(0)); |
| 331 | 329 | ||
| 332 | - // 确定性计算配置为规约保序仅支持A2场景 | 330 | + // 确定性计算配置为规约保序支持A2/A3场景 |
| 333 | DevType deviceType = DevType::DEV_TYPE_910_93; | 331 | DevType deviceType = DevType::DEV_TYPE_910_93; |
| 334 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); | 332 | MOCKER(hrtGetDeviceType).stubs().with(outBound(deviceType)).will(returnValue(HCCL_SUCCESS)); |
| 335 | 333 | ||
| 336 | CommConfig commConfig("comm_ID"); | 334 | CommConfig commConfig("comm_ID"); |
| 337 | - CommConfigInfo configInfo = { sizeof(CommConfigHandle), COMM_CONFIG_MAGIC_WORD, 1, { 0 } }; | 335 | + CommConfigInfo configInfo = {sizeof(CommConfigHandle), COMM_CONFIG_MAGIC_WORD, 1, {0}}; |
| 338 | - CommConfigHandle configHandle = { configInfo, 300, 2, "comm_ID", "should_not_be_loaded", 0, 132, 4}; | 336 | + CommConfigHandle configHandle = {configInfo, 300, 2, "comm_ID", "should_not_be_loaded", 0, 132, 4}; |
| 339 | 337 | ||
| 340 | HcclResult ret = commConfig.SetConfigByVersion(configHandle); | 338 | HcclResult ret = commConfig.SetConfigByVersion(configHandle); |
| 341 | - EXPECT_EQ(ret, HCCL_E_PARA); | 339 | + EXPECT_EQ(ret, HCCL_SUCCESS); |
| 340 | + EXPECT_EQ(commConfig.GetConfigDeterministic(), 2); | ||
| 342 | GlobalMockObject::verify(); | 341 | GlobalMockObject::verify(); |
| 343 | } | 342 | } |
| 344 | 343 | ||
| 345 | - | ||
| 346 | - | ||
| 347 | TEST_F(CommConfigTest, CheckRankIpFamily_ValidIPv4_Success) | 344 | TEST_F(CommConfigTest, CheckRankIpFamily_ValidIPv4_Success) |
| 348 | { | 345 | { |
| 349 | std::vector<RankInfo_t> rankList(2); | 346 | std::vector<RankInfo_t> rankList(2); |