已合并
[fix]all_reduce example添加 IsExampleEnabled() 守卫并补充绕过CMS验证方法 #3407
chenyizhuo创建于 22 天前
[fix]all_reduce example添加 IsExampleEnabled() 守卫并补充绕过CMS验证方法 #3407
已合并
共 4 个文件变更+133-20
| @@ -48,7 +48,7 @@ hccl/ # 仓库根 | |||
| 48 | │ ├── ops/op_common/algorithm/executor/registry/ | 48 | │ ├── ops/op_common/algorithm/executor/registry/ |
| 49 | │ │ └── coll_alg_v2_exec_registry.* # 执行器注册表:REGISTER_EXEC_V2 写入 / GetAlgExec 查找 | 49 | │ │ └── coll_alg_v2_exec_registry.* # 执行器注册表:REGISTER_EXEC_V2 写入 / GetAlgExec 查找 |
| 50 | │ ├── ops/all_reduce/ | 50 | │ ├── ops/all_reduce/ |
| 51 | -│ │ ├── algorithm/executor/ins_v2_all_reduce_sole_executor.cc # 主链路对照样例(注册 | 51 | +│ │ ├── algorithm/executor/ins_v2_all_reduce_sole_executor.cc # 主链路对照样例(注册 CcuMSAllReduceSoleMesh) |
| 52 | │ │ └── ... # 其余 executor/template/kernel 文件 | 52 | │ │ └── ... # 其余 executor/template/kernel 文件 |
| 53 | │ └── ... # 其余 src 子模块 | 53 | │ └── ... # 其余 src 子模块 |
| 54 | ├── include/ # 对外头文件(hccl.h / hccl_mc2.h 等) | 54 | ├── include/ # 对外头文件(hccl.h / hccl_mc2.h 等) |
| @@ -104,7 +104,7 @@ hccl/ # 仓库根 | |||
| 104 | - 数据类型:不支持 PROD(`op.isSupportProd = false`), | 104 | - 数据类型:不支持 PROD(`op.isSupportProd = false`), |
| 105 | `op.unsupportedDataTypes = {INT8, INT64, UINT64, FP64}`; | 105 | `op.unsupportedDataTypes = {INT8, INT64, UINT64, FP64}`; |
| 106 | - 就地运算:不支持 in place(`op.isSupportInplace = false`); | 106 | - 就地运算:不支持 in place(`op.isSupportInplace = false`); |
| 107 | -- 优先级:`op.opPriorityCheck` 回调在 `userRankSize == 2`(单机两卡)且满足第 4 节编译开关时 | 107 | +- 优先级:`op.opPriorityCheck` 回调在 `userRankSize == 2`(单机两卡)且满足第 4 节编译开关与运行期开关时 |
| 108 | 优先选中本算法(详见第 4 节)。 | 108 | 优先选中本算法(详见第 4 节)。 |
| 109 | - **运行时查找**:执行时按 selector 选出的算法名调用 `CollAlgExecRegistryV2::GetAlgExec` 取执行器; | 109 | - **运行时查找**:执行时按 selector 选出的算法名调用 `CollAlgExecRegistryV2::GetAlgExec` 取执行器; |
| 110 | 注册成功则返回非空执行器,注册缺失则返回 `nullptr`。 | 110 | 注册成功则返回非空执行器,注册缺失则返回 `nullptr`。 |
| @@ -280,12 +280,30 @@ REGISTER_ALG_ATTRS(algoName, ...) | |||
| 280 | | `opCustomCheck` | 定制算子过滤回调,返回 `true` 保留参与 cost 竞争 | `nullptr` | | 280 | | `opCustomCheck` | 定制算子过滤回调,返回 `true` 保留参与 cost 竞争 | `nullptr` | |
| 281 | | `opPriorityCheck` | 定制算子优先级回调,返回 `true` 表示优先选中 | `nullptr` | | 281 | | `opPriorityCheck` | 定制算子优先级回调,返回 `true` 表示优先选中 | `nullptr` | |
| 282 | 282 | ||
| 283 | +#### 运行期开关 | ||
| 284 | + | ||
| 285 | +`experimental/` 下的算法通过运行期开关控制是否生效,防止实验功能意外影响主干;命名与判定约定见 | ||
| 286 | +`experimental/README.md` 第 5 节:运行期开关为环境变量 `HCCL_EXPERIMENTAL_<NAME>=true`,并在项目入口提供 | ||
| 287 | +`IsXxxEnabled()` 函数,内部按「编译期常量 → 环境变量」顺序判定。本目录算法即按此约定实现其入口守卫: | ||
| 288 | + | ||
| 289 | +```cpp | ||
| 290 | +bool IsExampleEnabled() { | ||
| 291 | + constexpr bool exampleEnabled = false; // 编译期常量,见 experimental/README.md 第5节 | ||
| 292 | + if (!exampleEnabled) return false; | ||
| 293 | + const char* env = std::getenv("HCCL_EXPERIMENTAL_EXAMPLE"); | ||
| 294 | + return env && std::string(env) == "true"; | ||
| 295 | +} | ||
| 296 | +``` | ||
| 297 | + | ||
| 298 | +算法入口(如本目录 executor 的 `CalcCostCoeff`)以 `if (!IsExampleEnabled()) { return {}; }` 守卫,不满足时 | ||
| 299 | +selection 阶段返回空、算法被跳过。实现自定义算法时应提供配套的 `IsXxxEnabled()` 并声明 `HCCL_EXPERIMENTAL_<NAME>` | ||
| 300 | +环境变量。 | ||
| 301 | + | ||
| 283 | --- | 302 | --- |
| 284 | 303 | ||
| 285 | ## 3. 构建 | 304 | ## 3. 构建 |
| 286 | 305 | ||
| 287 | -仅改动 `hccl` 仓(本目录 + 本地临时的 selector 修改)时,用 `hccl_vm` 的编包链路,但注意 `build_pkg.sh` | 306 | +构建时可使用以下指令手动替换CANN包中的HCCL包并配置环境。hccl_vm 自动编包链路(`build_pkg.sh`)内部含无条件 sudo。不使用hccl-vm时可按以下步骤手动分步替换: |
| 288 | -内部有无条件 `sudo`(清除 python 的 `EXTERNALLY-MANAGED` 锁),无免密 `sudo` 的环境需手动分步: | ||
| 289 | 307 | ||
| 290 | ```bash | 308 | ```bash |
| 291 | cd /home/workspace/hccl | 309 | cd /home/workspace/hccl |
| @@ -298,8 +316,27 @@ bash build.sh --full --experimental | |||
| 298 | # 2. 安装 .run 包到 CANN(用户目录可免 root) | 316 | # 2. 安装 .run 包到 CANN(用户目录可免 root) |
| 299 | yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/home/workspace/Ascend | 317 | yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/home/workspace/Ascend |
| 300 | 318 | ||
| 319 | +# 3. (可选)如果使用时遇到CMS Verified Failed问题,可通过npu-smi工具来绕开CMS验证。绕开CMS验证可能带来安全问题,请谨慎操作。 | ||
| 320 | +for i in {0..7}; do | ||
| 321 | + # 使能自定义验签 | ||
| 322 | + npu-smi set -t custom-op-secverify-enable -i $i -d 1 | ||
| 323 | + # 设置成“关闭验签”模式 | ||
| 324 | + npu-smi set -t custom-op-secverify-mode -i $i -d 0 | ||
| 325 | +done | ||
| 326 | + | ||
| 301 | ``` | 327 | ``` |
| 302 | 328 | ||
| 329 | +其中: | ||
| 330 | + | ||
| 331 | +- `-i` 用于指定设备ID,即通过“npu-smi info -l”命令查出的NPU ID | ||
| 332 | +- `-d` 用于指定对应配置项的属性值 | ||
| 333 | + | ||
| 334 | +> **注意:** | ||
| 335 | +> 上述两条命令需以 **root** 用户在**物理机**上执行,且需配套 **Ascend HDK 25.5.T2.B001** 及以上版本的 npu-smi 工具。 | ||
| 336 | +> 关闭驱动安全验签机制存在一定的安全风险,需要用户自行确保自定义通信算子的安全可靠,防止恶意攻击行为。请仅在受控验证环境中临时使用,验证完成后应及时恢复验签。 | ||
| 337 | + | ||
| 338 | +> **说明:** 本目录样例算法属验证用途,绕过验签仅服务于该验证场景。 | ||
| 339 | + | ||
| 303 | --- | 340 | --- |
| 304 | 341 | ||
| 305 | ## 4. 用法 | 342 | ## 4. 用法 |
| @@ -309,8 +346,13 @@ yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/h | |||
| 309 | **编译开关 `--experimental`**(对应 `ENABLE_EXPERIMENTAL=ON`,统一控制 `experimental/` 文件夹是否参与 | 346 | **编译开关 `--experimental`**(对应 `ENABLE_EXPERIMENTAL=ON`,统一控制 `experimental/` 文件夹是否参与 |
| 310 | 编译;关闭时本目录不被编译、算法不注册)。 | 347 | 编译;关闭时本目录不被编译、算法不注册)。 |
| 311 | 348 | ||
| 312 | -参与算法选择时,单机两卡(`userRankSize == 2`)拓扑下,`REGISTER_ALG_ATTRS` 中为 `CcuMSAllReduceExperimentalSoleMesh` | 349 | +**运行期开关(`IsExampleEnabled` / `HCCL_EXPERIMENTAL_EXAMPLE`)**:除编译开关外,算法入口受 `IsExampleEnabled()` |
[MEDIUM] 新增运行期开关说明与既有「直接可测」等表述矛盾,关联小节未同步更新 问题分析:
本段新增的启用前提(需设置环境变量
另外 PR 描述「测试:本地checker测试通过」未说明测试时是否设置了 建议修复:
![]() ![]() | |||
| 313 | -配置的 `opPriorityCheck` 会优先选中本算法,无需额外改动,直接可测。 | 350 | +守卫,启用本算法需同时满足: |
| 351 | + | ||
| 352 | +- 编译期常量 `exampleEnabled` 为 `true`; | ||
| 353 | +- 设置环境变量 `HCCL_EXPERIMENTAL_EXAMPLE=true`。 | ||
| 354 | + | ||
| 355 | +设置环境变量 `HCCL_EXPERIMENTAL_EXAMPLE=true` 后,参与算法选择时,单机两卡(userRankSize == 2)拓扑下,REGISTER_ALG_ATTRS 中为 CcuMSAllReduceExperimentalSoleMesh 配置的 opPriorityCheck 会优先选中本算法,无需其他改动、直接可测。不设置时,selection 阶段 `CalcCostCoeff` 直接返回空,本算法会被跳过、不会被选中。实现说明见第 2.5 节「运行期开关」。 | ||
| 314 | 356 | ||
| 315 | --- | 357 | --- |
| 316 | 358 | ||
| @@ -329,13 +371,12 @@ yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/h | |||
| 329 | 371 | ||
| 330 | ## 6. 限制 | 372 | ## 6. 限制 |
| 331 | 373 | ||
| 332 | -1. **影响所有 `experimental/` 算法的选择(重要警告)**:本算法经 `REGISTER_EXEC_V2`/`REGISTER_ALG_ATTRS` 接入与主链路相同的注册表与选择器。在 `ENABLE_EXPERIMENTAL=ON` 下,其 `REGISTER_ALG_ATTRS` 声明的 `opPriorityCheck` 会在选择器扫描算法时**全局生效**,单机两卡场景优先选中本算法,从而可抢占/扰动 `experimental/` 下所有其他实验算法的选择结果、挤占其验证空间。验证其他 `experimental/` 算法时,必须裁剪本目录的编译/注册以确保本算法不被选中。 | 374 | +1. **不可上线**:本算法目的为测试当前最新算法注册方式及选择方式在experimental文件夹的可用性。不应作为线上算法 使用。 |
| 333 | -2. **不可上线**:本算法目的为测试当前最新算法注册方式及选择方式在experimental文件夹的可用性。不应作为线上算法 使用。 | 375 | +2. **类型/拓扑约束**:不支持 in place、保序(DETERMINISTIC_STRICT)、int8、PROD、INT64/UINT64/FP64 |
| 334 | -3. **类型/拓扑约束**:不支持 in place、保序(DETERMINISTIC_STRICT)、int8、PROD、INT64/UINT64/FP64 | ||
| 335 | (由 `SelectCcuMsAlgo`/`SelectMeshAlgo` 前置判断回退);模板依赖 `TopoMatchOneLevel` 与 mesh-1D 全互联 | 376 | (由 `SelectCcuMsAlgo`/`SelectMeshAlgo` 前置判断回退);模板依赖 `TopoMatchOneLevel` 与 mesh-1D 全互联 |
| 336 | 假设,kernel 要求 `channelCount >= rankSize-1`,`CalcRes` 校验 `templateRankSize_` 上限 | 377 | 假设,kernel 要求 `channelCount >= rankSize-1`,`CalcRes` 校验 `templateRankSize_` 上限 |
| 337 | `CCU_MAX_RANK_SIZE`(128)。 | 378 | `CCU_MAX_RANK_SIZE`(128)。 |
| 338 | -4. **版本依赖**:`REGISTER_EXEC_V2` / `REGISTER_ALG_ATTRS` 注册仅在 | 379 | +3. **版本依赖**:`REGISTER_EXEC_V2` / `REGISTER_ALG_ATTRS` 注册仅在 |
| 339 | `CANN_VERSION_NUM >= CANN_VERSION(9, 0, 0)`(CANN 9.0+)时生效,低版本 CANN 下本算法不会注册。 | 380 | `CANN_VERSION_NUM >= CANN_VERSION(9, 0, 0)`(CANN 9.0+)时生效,低版本 CANN 下本算法不会注册。 |
| 340 | -5. **原型级质量**:属 `experimental/` 实验代码,不承诺 API/ABI 稳定、不编入商用版本;代码风格与 | 381 | +4. **原型级质量**:属 `experimental/` 实验代码,不承诺 API/ABI 稳定、不编入商用版本;代码风格与 |
| 341 | 防御性检查以本次验证为目的,未做完整性能优化。 | 382 | 防御性检查以本次验证为目的,未做完整性能优化。 |
| @@ -92,8 +92,8 @@ hccl/ # Repository root | |||
| 92 | (see Section 4). | 92 | (see Section 4). |
| 93 | - **Runtime lookup**: At execution time, the executor is retrieved by calling `CollAlgExecRegistryV2::GetAlgExec` with the algorithm name selected by the selector; | 93 | - **Runtime lookup**: At execution time, the executor is retrieved by calling `CollAlgExecRegistryV2::GetAlgExec` with the algorithm name selected by the selector; |
| 94 | if registration succeeds, a non-null executor is returned; if registration is missing, `nullptr` is returned. | 94 | if registration succeeds, a non-null executor is returned; if registration is missing, `nullptr` is returned. |
| 95 | -- **Selection method**: When compiled into the package (`ENABLE_EXPERIMENTAL=ON`), this algorithm is preferentially | 95 | +- **Selection method**: When compiled into the package (`ENABLE_EXPERIMENTAL=ON`) and the runtime switch is satisfied, |
| 96 | - selected under the single-machine two-card scenario (see Section 4). | 96 | + this algorithm is preferentially selected under the single-machine two-card scenario (see Section 4). |
| 97 | 97 | ||
| 98 | ### 2.3 Build Integration | 98 | ### 2.3 Build Integration |
| 99 | 99 | ||
| @@ -261,11 +261,33 @@ It takes effect under `#ifndef AICPU_COMPILE`; under AICPU compilation the macro | |||
| 261 | | `opCustomCheck` | Custom operator filter callback; returning `true` keeps it for cost competition | `nullptr` | | 261 | | `opCustomCheck` | Custom operator filter callback; returning `true` keeps it for cost competition | `nullptr` | |
| 262 | | `opPriorityCheck` | Custom operator priority callback; returning `true` means prioritized | `nullptr` | | 262 | | `opPriorityCheck` | Custom operator priority callback; returning `true` means prioritized | `nullptr` | |
| 263 | 263 | ||
| 264 | +#### Runtime Switch | ||
| 265 | + | ||
| 266 | +Algorithms under `experimental/` are controlled at runtime by a switch to keep experimental features from | ||
| 267 | +inadvertently affecting the main stream; the naming and decision convention is described in `experimental/README.md` | ||
| 268 | +Section 5: the runtime switch is the environment variable `HCCL_EXPERIMENTAL_<NAME>=true`, and an `IsXxxEnabled()` | ||
| 269 | +function is provided at the project entry, which decides in the order "compile-time constant → environment variable". | ||
| 270 | +This directory's algorithm follows this convention for its entry guard: | ||
| 271 | + | ||
| 272 | +```cpp | ||
| 273 | +bool IsExampleEnabled() { | ||
| 274 | + constexpr bool exampleEnabled = false; // compile-time constant, see experimental/README.md Section 5 | ||
| 275 | + if (!exampleEnabled) return false; | ||
| 276 | + const char* env = std::getenv("HCCL_EXPERIMENTAL_EXAMPLE"); | ||
| 277 | + return env && std::string(env) == "true"; | ||
| 278 | +} | ||
| 279 | +``` | ||
| 280 | + | ||
| 281 | +The algorithm entry (such as `CalcCostCoeff` of this directory's executor) is guarded by | ||
| 282 | +`if (!IsExampleEnabled()) { return {}; }`; if not satisfied, it returns empty during the selection phase and the | ||
| 283 | +algorithm is skipped. When implementing a custom algorithm, provide a matching `IsXxxEnabled()` and declare the | ||
| 284 | +`HCCL_EXPERIMENTAL_<NAME>` environment variable. | ||
| 285 | + | ||
| 264 | --- | 286 | --- |
| 265 | 287 | ||
| 266 | ## 3. Build | 288 | ## 3. Build |
| 267 | 289 | ||
| 268 | -When only the `hccl` repository is modified (this directory + local temporary selector modifications), use the `hccl_vm` build pipeline, but note that `build_pkg.sh` contains an unconditional `sudo` (to clear Python's `EXTERNALLY-MANAGED` lock); environments without passwordless `sudo` require manual step-by-step execution: | 290 | +The following commands can be used to manually replace the HCCL package in the CANN package and configure the environment. The `hccl-vm` automatic build chain (`build_pkg.sh`) internally uses unconditional `sudo`. When not using `hccl-vm`, you can manually replace the package step by step using the following commands: |
| 269 | 291 | ||
| 270 | ```bash | 292 | ```bash |
| 271 | cd /home/workspace/hccl | 293 | cd /home/workspace/hccl |
| @@ -278,8 +300,27 @@ bash build.sh --full --experimental | |||
| 278 | # 2. Install the .run package to CANN (user directory, no root required) | 300 | # 2. Install the .run package to CANN (user directory, no root required) |
| 279 | yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/home/workspace/Ascend | 301 | yes y | bash build_out/cann-hccl_9.2.0_linux-x86_64.run --full --install-path=/home/workspace/Ascend |
| 280 | 302 | ||
| 303 | +# 3. (Optional) If a CMS Verified Failed problem is encountered at runtime, use the npu-smi tool to bypass CMS verification. Bypassing CMS verification may pose security risks; proceed with caution. | ||
| 304 | +for i in {0..7}; do | ||
| 305 | + # Enable custom signature verification | ||
| 306 | + npu-smi set -t custom-op-secverify-enable -i $i -d 1 | ||
| 307 | + # Switch "signature verification" off | ||
| 308 | + npu-smi set -t custom-op-secverify-mode -i $i -d 0 | ||
| 309 | +done | ||
| 310 | + | ||
| 281 | ``` | 311 | ``` |
| 282 | 312 | ||
| 313 | +Where: | ||
| 314 | + | ||
| 315 | +- `-i` specifies the device ID, that is, the NPU ID shown by the `npu-smi info -l` command | ||
| 316 | +- `-d` specifies the property value for the corresponding configuration item | ||
| 317 | + | ||
| 318 | +> **Note:** | ||
| 319 | +> The two commands above must be run as **root** on a **physical machine**, with an **Ascend HDK 25.5.T2.B001 or later** npu-smi tool. | ||
| 320 | +> Disabling the driver's security signature verification mechanism carries certain security risks. Users must ensure the safety and reliability of custom communication operators themselves to guard against malicious attacks. Use it only temporarily in a controlled verification environment, and restore signature verification promptly after verification. | ||
| 321 | + | ||
| 322 | +> **Note:** The sample algorithms in this directory are for verification purposes; bypassing signature verification serves that verification scenario only. | ||
| 323 | + | ||
| 283 | --- | 324 | --- |
| 284 | 325 | ||
| 285 | ## 4. Usage | 326 | ## 4. Usage |
| @@ -291,7 +332,16 @@ This algorithm can only be selected after being compiled into the package: | |||
| 291 | 332 | ||
| 292 | When participating in algorithm selection, under the single-machine two-card (`userRankSize == 2`) topology, the | 333 | When participating in algorithm selection, under the single-machine two-card (`userRankSize == 2`) topology, the |
| 293 | `opPriorityCheck` configured for `CcuMSAllReduceExperimentalSoleMesh` in `REGISTER_ALG_ATTRS` preferentially selects | 334 | `opPriorityCheck` configured for `CcuMSAllReduceExperimentalSoleMesh` in `REGISTER_ALG_ATTRS` preferentially selects |
| 294 | -this algorithm, so no extra modification is needed and it can be tested directly. | 335 | +this algorithm; with `HCCL_EXPERIMENTAL_EXAMPLE=true` set and no other modification, it can be tested directly. When it is not set, `CalcCostCoeff` returns empty during the selection phase and this algorithm is skipped and not selected. |
| 336 | + | ||
| 337 | +**Runtime switch (`IsExampleEnabled` / `HCCL_EXPERIMENTAL_EXAMPLE`)**: In addition to the compile switch, the | ||
| 338 | +algorithm entry is guarded by `IsExampleEnabled()`. Enabling this algorithm requires BOTH of the following: | ||
| 339 | + | ||
| 340 | +- The compile-time constant `exampleEnabled` is `true`; | ||
| 341 | +- The environment variable `HCCL_EXPERIMENTAL_EXAMPLE=true` is set. | ||
| 342 | + | ||
| 343 | +If not satisfied, `CalcCostCoeff` returns empty during the selection phase and this algorithm is skipped and not | ||
| 344 | +selected. For implementation details, see the "Runtime Switch" subsection in Section 2.5. | ||
| 295 | 345 | ||
| 296 | --- | 346 | --- |
| 297 | 347 | ||
| @@ -310,12 +360,11 @@ this algorithm, so no extra modification is needed and it can be tested directly | |||
| 310 | 360 | ||
| 311 | ## 6. Limitations | 361 | ## 6. Limitations |
| 312 | 362 | ||
| 313 | -1. **Affects the selection of all `experimental/` algorithms (important warning)**: This algorithm is registered via `REGISTER_EXEC_V2`/`REGISTER_ALG_ATTRS` into the same registry and selector as the main pathway. Under `ENABLE_EXPERIMENTAL=ON`, the `opPriorityCheck` declared in its `REGISTER_ALG_ATTRS` takes effect **globally** while the selector scans algorithms, and preferentially selects this algorithm under the single-machine dual-card scenario, potentially preempting or perturbing the selection results of all other `experimental/` algorithms and encroaching on their verification space. When verifying other `experimental/` algorithms, you must trim out this directory's compilation/registration to ensure this algorithm is not selected. | 363 | +1. **Not for production**: This algorithm is intended to test the usability of the latest algorithm registration and selection approaches under the experimental folder, and should not be used as a production algorithm. |
| 314 | -2. **Not for production**: This algorithm is intended to test the usability of the latest algorithm registration and selection approaches under the experimental folder, and should not be used as a production algorithm. | 364 | +2. **Type/topology constraints**: Does not support in place, ordering (DETERMINISTIC_STRICT), int8, PROD, INT64/UINT64/FP64 |
| 315 | -3. **Type/topology constraints**: Does not support in place, ordering (DETERMINISTIC_STRICT), int8, PROD, INT64/UINT64/FP64 | ||
| 316 | (falls back via `SelectCcuMsAlgo`/`SelectMeshAlgo` pre-checks); template depends on `TopoMatchOneLevel` and the mesh-1D full-mesh | 365 | (falls back via `SelectCcuMsAlgo`/`SelectMeshAlgo` pre-checks); template depends on `TopoMatchOneLevel` and the mesh-1D full-mesh |
| 317 | assumption, kernel requires `channelCount >= rankSize-1`, `CalcRes` validates `templateRankSize_` upper bound | 366 | assumption, kernel requires `channelCount >= rankSize-1`, `CalcRes` validates `templateRankSize_` upper bound |
| 318 | `CCU_MAX_RANK_SIZE` (128). | 367 | `CCU_MAX_RANK_SIZE` (128). |
| 319 | -4. **Version dependency**: `REGISTER_EXEC_V2` / `REGISTER_ALG_ATTRS` registration only takes effect when | 368 | +3. **Version dependency**: `REGISTER_EXEC_V2` / `REGISTER_ALG_ATTRS` registration only takes effect when |
| 320 | `CANN_VERSION_NUM >= CANN_VERSION(9, 0, 0)` (CANN 9.0+); under lower CANN versions, this algorithm will not be registered. | 369 | `CANN_VERSION_NUM >= CANN_VERSION(9, 0, 0)` (CANN 9.0+); under lower CANN versions, this algorithm will not be registered. |
| 321 | -5. **Prototype-level quality**: This is `experimental/` experimental code, with no guarantee of API/ABI stability, and is not compiled into the commercial version; code style and defensive checks are aimed at this verification, without full performance optimization. | 370 | +4. **Prototype-level quality**: This is `experimental/` experimental code, with no guarantee of API/ABI stability, and is not compiled into the commercial version; code style and defensive checks are aimed at this verification, without full performance optimization. |
| @@ -8,6 +8,9 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | +#include <cstdlib> | ||
| 12 | +#include <string> | ||
| 13 | + | ||
| 11 | #include "ins_v2_all_reduce_experimental_sole_executor.h" | 14 | #include "ins_v2_all_reduce_experimental_sole_executor.h" |
| 12 | #include "topo_match_one_level.h" | 15 | #include "topo_match_one_level.h" |
| 13 | #ifndef AICPU_COMPILE | 16 | #ifndef AICPU_COMPILE |
| @@ -39,6 +42,14 @@ template <typename AlgTopoMatch, typename InsAlgTemplate> | |||
| 39 | std::vector<CostModelParam> InsV2AllReduceExperimentalSoleExecutor<AlgTopoMatch, InsAlgTemplate>::CalcCostCoeff( | 42 | std::vector<CostModelParam> InsV2AllReduceExperimentalSoleExecutor<AlgTopoMatch, InsAlgTemplate>::CalcCostCoeff( |
| 40 | HcclComm comm, TopoInfoWithNetLayerDetails* topoInfo, const char* algName, const OpParam& param) | 43 | HcclComm comm, TopoInfoWithNetLayerDetails* topoInfo, const char* algName, const OpParam& param) |
| 41 | { | 44 | { |
| 45 | + if (!IsExampleEnabled()) { | ||
[MEDIUM] PR 未关联 Issue(描述中为 NA),不符合仓贡献流程要求 问题分析:
本 PR 除文档更新外还包含行为变更: 建议修复: 补充关联 Issue:若「实验特性必须加 IsXxxEnabled() 守卫」来自 experimental 目录的整改或检视要求,链接对应 Issue;若无现成 Issue,先创建一个简短 Issue 说明守卫诉求与 CMS 文档诉求,再在本 PR 描述中关联。 ![]() ![]() | |||
| 46 | + HCCL_INFO( | ||
| 47 | + "[InsV2AllReduceExperimentalSoleExecutor][CalcCostCoeff] Example is not enabled, algName=%s " | ||
| 48 | + "will be skipped in selection. Set env HCCL_EXPERIMENTAL_EXAMPLE=true to enable it.", | ||
| 49 | + algName); | ||
| 50 | + return {}; | ||
| 51 | + } | ||
| 52 | + | ||
| 42 | (void)comm; | 53 | (void)comm; |
| 43 | AlgHierarchyInfoForAllLevel algHierarchyInfo; | 54 | AlgHierarchyInfoForAllLevel algHierarchyInfo; |
| 44 | #ifndef AICPU_COMPILE | 55 | #ifndef AICPU_COMPILE |
| @@ -368,6 +379,16 @@ HcclResult InsV2AllReduceExperimentalSoleExecutor<AlgTopoMatch, InsAlgTemplate>: | |||
| 368 | } | 379 | } |
| 369 | #endif | 380 | #endif |
| 370 | 381 | ||
| 382 | +template <typename AlgTopoMatch, typename InsAlgTemplate> | ||
| 383 | +bool InsV2AllReduceExperimentalSoleExecutor<AlgTopoMatch, InsAlgTemplate>::IsExampleEnabled() | ||
| 384 | +{ | ||
| 385 | + constexpr bool exampleEnabled = false; | ||
| 386 | + if (!exampleEnabled) | ||
| 387 | + return false; | ||
| 388 | + const char* env = std::getenv("HCCL_EXPERIMENTAL_EXAMPLE"); | ||
| 389 | + return env && std::string(env) == "true"; | ||
| 390 | +} | ||
| 391 | + | ||
| 371 | } // namespace ops_hccl_experimental | 392 | } // namespace ops_hccl_experimental |
| 372 | 393 | ||
| 373 | namespace ops_hccl { | 394 | namespace ops_hccl { |
| @@ -56,6 +56,8 @@ private: | |||
| 56 | MatchTopo 因 algoTypes.size()!=1 直接判不支持。此处基于 base 补全 opType/engine/algoTypes。 */ | 56 | MatchTopo 因 algoTypes.size()!=1 直接判不支持。此处基于 base 补全 opType/engine/algoTypes。 */ |
| 57 | static AlgAttrs BuildExperimentalAlgAttrs(const AlgAttrs& base); | 57 | static AlgAttrs BuildExperimentalAlgAttrs(const AlgAttrs& base); |
| 58 | 58 | ||
| 59 | + static bool IsExampleEnabled(); | ||
| 60 | + | ||
| 59 | protected: | 61 | protected: |
| 60 | /* *************** 算法编排 *************** */ | 62 | /* *************** 算法编排 *************** */ |
| 61 | HcclResult OrchestrateLoop(const OpParam& param, const AlgResourceCtxSerializable& resCtx); | 63 | HcclResult OrchestrateLoop(const OpParam& param, const AlgResourceCtxSerializable& resCtx); |


[HIGH] README 中 被识别为未闭合 HTML 标签,staticcheck 拦截导致 CI 门禁失败
问题分析:
experimental/README.md第 5 节:运行期开关为环境变量HCCL_EXPERIMENTAL_<NAME>=true新增「运行期开关」小节中的
HCCL_EXPERIMENTAL_<NAME>写法被 staticcheck 的 Html 标签匹配检查识别为未闭合标签(行内代码的反引号不能豁免该检查),CI run#3009(CodeCheck_staticcheck Job)因此失败,当前 PR 处于 ci-pipeline-failed 状态,未满足 ci-pipeline-passed 门禁。共 4 处:README.md 第 286、299 行,README_en.md 第 268、284 行。建议修复: 两选一,四处同步修改后重新触发流水线:
HCCL_EXPERIMENTAL_\<NAME>(对应文档规范 FS-04 转义符规则);HCCL_EXPERIMENTAL_EXAMPLE,或改为文字描述「HCCL_EXPERIMENTAL_ 前缀 + 特性名」。若需保留泛化示意,也可将该示意放进块级代码块内并实测 staticcheck 是否放行。