| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
docs: add batch consistency and determinism intro Co-authored-by: LiuZonggu<liuzonggu1@huawei.com> # message auto-generated for no-merge-commit merge: !100 merge docs/batch-consistency-determinism into master docs: add batch consistency and determinism intro Created-by: LiuZonggu Commit-by: LiuZonggu Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1. **Add feature introduction documents (Chinese and English)** - docs/zh/context/determinism_compute.md / docs/en/context/determinism_compute.md: introduce the background, notes, and usage of deterministic computation (for aclnn APIs, enable via aclrtSetSysParamOpt with ACL_OPT_DETERMINISTIC=1; for PyTorch APIs, enable via torch.use_deterministic_algorithms). - docs/zh/context/batch_consistency.md / docs/en/context/batch_consistency.md: introduce the background, notes (including version constraints: TorchNPU >= 26.2.0, CANN >= 9.2.0), and usage of Batch consistency (for aclnn APIs, enable via ACL_OPT_DETERMINISTIC=3; for PyTorch APIs, enable via torch_npu.npu.set_deterministic_level). 2. **Update the Basic Operator Concepts index**: add "Deterministic Computation" and "Batch Consistency" entries to docs/{zh,en}/context/basic_concept.md. 3. **Simplify the determinism note on the aclnn API list pages**: replace the long inline "determinism introduction" block in docs/{zh,en}/op_api_list.md with a [!NOTE] callout that directs readers to the Basic Operator Concepts page to learn about deterministic algorithms, Batch consistency, and common quantization modes. 4. **Add a badge row to the READMEs (Chinese and English)**: community operator list, project docs, license, contributing guide, and SIG badges. 5. **Update the English quick install guide**: replace the outdated WebIDE platform link (org/cann/discussions/54) with the [CANNLab guide](https://gitcode.com/cann/cann-learning-hub/blob/master/docs/CANNLab_env_experience_guide.md). ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> Related to https://gitcode.com/cann/ops-ras/issues/33 https://gitcode.com/cann/ops-ras/issues/34 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> Verified all added/modified Markdown internal links and relative paths; all resolve correctly. ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - Added: docs/zh/context/determinism_compute.md, docs/zh/context/batch_consistency.md, docs/en/context/determinism_compute.md, docs/en/context/batch_consistency.md - Modified: README.md, README_en.md, docs/zh/context/basic_concept.md, docs/en/context/basic_concept.md, docs/zh/op_api_list.md, docs/en/op_api_list.md, docs/en/install/quick_install.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-ras!100 | 1 个月前 | |
[L1] docs: 修复 op_debug_prof 中英文文档的 Simulator 链接失效(含中文锚点) Co-authored-by: eieiei<3901796952@qq.com> # message auto-generated for no-merge-commit merge: !112 merge fix-op-debug-prof-links into master [L1] docs: 修复 op_debug_prof 中英文文档的 Simulator 链接失效(含中文锚点) Created-by: wsnidie1 Commit-by: eieiei Merged-by: cann-robot Description: 关联 Issue: #42 ### Describe the current behavior / 问题描述 (Mandatory / 必填) docs/zh/debug/op_debug_prof.md 与 docs/en/debug/op_debug_prof.md 中指向 CANN Simulator 的 3 处链接失效: | # | 位置 | master 原文 | 问题 | |---|---|---|---| | 1 | docs/en/debug/op_debug_prof.md:170 | [CANN Simulator](./cann_simulator.md) | 文件名不存在(实际为 cann_sim.md) | | 2 | docs/en/debug/op_debug_prof.md:190 | ](./cann_simulator.md#simulation-result-analysis-instructions) | 同一文件名错(锚点本身正确) | | 3 | docs/zh/debug/op_debug_prof.md:187 | ](./cann_sim.md#仿真结果解析) | 锚点与标题 # 仿真结果解析说明 不匹配 | ### Steps to reproduce / 重现步骤 无需编译环境,静态可核对: 1. ls docs/en/debug/ docs/zh/debug/ —— 目录下只有 cann_sim.md,不存在 cann_simulator.md; 2. 点击文档中 3 处 Simulator 链接 → 404 / 锚点不跳转。 ### Describe the expected behavior / 预期结果 三处链接均可正常跳转:英文侧两处指向 ./cann_sim.md,中文侧锚点补全为 #仿真结果解析说明。 ### 根因原因 (Root Cause) 文档重命名(cann_simulator.md → cann_sim.md)与中文标题增补(「仿真结果解析」→「仿真结果解析说明」)时未同步更新引用处。 ### 修复方案 (Solution) - docs/en/debug/op_debug_prof.md L170/L190:./cann_simulator.md → ./cann_sim.md(锚点不变); - docs/zh/debug/op_debug_prof.md L187:锚点 #仿真结果解析 → #仿真结果解析说明。 ### 影响范围 纯文档链接修正(+3/−3),不影响任何代码与功能。 See merge request: cann/ops-ras!112 | 5 天前 | |
修改错误的arch版本 Co-authored-by: yue-ma<mayue54@huawei.com> # message auto-generated for no-merge-commit merge: !10 merge master into master 修改错误的arch版本 Created-by: yue-ma Commit-by: yue-ma Merged-by: cann-robot Description: ## 描述 增加readme和classify <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> https://gitcode.com/cann/ops-ras/issues/20 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> 不涉及 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> docs/en/develop/aicore_develop_guide.md ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-ras!10 | 1 个月前 | |
docs: add batch consistency and determinism intro Co-authored-by: LiuZonggu<liuzonggu1@huawei.com> # message auto-generated for no-merge-commit merge: !100 merge docs/batch-consistency-determinism into master docs: add batch consistency and determinism intro Created-by: LiuZonggu Commit-by: LiuZonggu Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 1. **Add feature introduction documents (Chinese and English)** - docs/zh/context/determinism_compute.md / docs/en/context/determinism_compute.md: introduce the background, notes, and usage of deterministic computation (for aclnn APIs, enable via aclrtSetSysParamOpt with ACL_OPT_DETERMINISTIC=1; for PyTorch APIs, enable via torch.use_deterministic_algorithms). - docs/zh/context/batch_consistency.md / docs/en/context/batch_consistency.md: introduce the background, notes (including version constraints: TorchNPU >= 26.2.0, CANN >= 9.2.0), and usage of Batch consistency (for aclnn APIs, enable via ACL_OPT_DETERMINISTIC=3; for PyTorch APIs, enable via torch_npu.npu.set_deterministic_level). 2. **Update the Basic Operator Concepts index**: add "Deterministic Computation" and "Batch Consistency" entries to docs/{zh,en}/context/basic_concept.md. 3. **Simplify the determinism note on the aclnn API list pages**: replace the long inline "determinism introduction" block in docs/{zh,en}/op_api_list.md with a [!NOTE] callout that directs readers to the Basic Operator Concepts page to learn about deterministic algorithms, Batch consistency, and common quantization modes. 4. **Add a badge row to the READMEs (Chinese and English)**: community operator list, project docs, license, contributing guide, and SIG badges. 5. **Update the English quick install guide**: replace the outdated WebIDE platform link (org/cann/discussions/54) with the [CANNLab guide](https://gitcode.com/cann/cann-learning-hub/blob/master/docs/CANNLab_env_experience_guide.md). ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> Related to https://gitcode.com/cann/ops-ras/issues/33 https://gitcode.com/cann/ops-ras/issues/34 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> Verified all added/modified Markdown internal links and relative paths; all resolve correctly. ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - Added: docs/zh/context/determinism_compute.md, docs/zh/context/batch_consistency.md, docs/en/context/determinism_compute.md, docs/en/context/batch_consistency.md - Modified: README.md, README_en.md, docs/zh/context/basic_concept.md, docs/en/context/basic_concept.md, docs/zh/op_api_list.md, docs/en/op_api_list.md, docs/en/install/quick_install.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-ras!100 | 1 个月前 | |
docs: 修复 QUICKSTART 易用性问题并补充构建 FAQ 与 _tiling 命名约束 Co-authored-by: LiuZonggu<liuzonggu1@huawei.com> # message auto-generated for no-merge-commit merge: !107 merge docs/install-guide-usability into master docs: 修复 QUICKSTART 易用性问题并补充构建 FAQ 与 _tiling 命名约束 Created-by: LiuZonggu Commit-by: LiuZonggu Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 完善本仓文档易用性(中英文版本同步修改): - **QUICKSTART.md / QUICKSTART_en.md**:运行样例命令统一补充 --soc 参数,并说明其取值须与编译算子包时一致,否则可能报 error 161001(如 aclnnXxxGetWorkspaceSize failed);章节开头整合多场景编译指引(单算子/整库/离线编译),链接《build参数说明》与《源码构建指南》。 - **docs/zh/install/compile.md / docs/en/install/compile.md**:新增 FAQ 章节,说明安装自定义 run 包报错权限不足的两种处理方式(推荐 --install-path 安装到用户可写路径并加载 set_env.bash;或使用 sudo -E 安装到系统 CANN 目录)。 - **CONTRIBUTING.md / CONTRIBUTING_en.md**:算子最小交付件树补充可选的子场景 Tiling 文件(${op_name}_tiling_${sub_case}.cpp/.h),增加指向项目目录结构文档的链接,并补充 _tiling 命名约束说明。 - **docs/zh/install/dir_structure.md / docs/en/install/dir_structure.md**:op_host 目录树补充 Tiling 交付件说明及 _tiling 命名约束。 根因说明:cmake/func.cmake 通过 file(GLOB ... *_tiling*.cpp) 收集 Tiling 源文件参与编译,不含 _tiling 的文件不会被 glob 命中,因而静默不编译,该约束此前未在文档中披露。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> https://gitcode.com/cann/ops-ras/issues/36 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/QUICKSTART.md - docs/zh/install/compile.md - CONTRIBUTING.md - docs/zh/install/dir_structure.md - docs/QUICKSTART_en.md - docs/en/install/compile.md - CONTRIBUTING_en.md - docs/en/install/dir_structure.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-ras!107 | 30 天前 | |
修改仓上格式语法问题 Co-authored-by: caiwenwen<caiwenwen6@h-partners.com> # message auto-generated for no-merge-commit merge: !75 merge master into master 修改仓上格式语法问题 Created-by: caiwenwen Commit-by: caiwenwen Merged-by: cann-robot Description: ## 描述 开源修改仓上的语法问题、产品支持情况格式,中英文空格 ## 关联的Issue 关联Issue [#7](https://gitcode.com/cann/ops-ras/issues/7) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-ras!75 | 2 个月前 | |
add new operator matmul_abft_verify Co-authored-by: kanboyi<2036465770@qq.com> # message auto-generated for no-merge-commit merge: !94 merge add_matmul_abft_verify into master add new operator matmul_abft_verify Created-by: starfican Commit-by: kanboyi Merged-by: cann-robot Description: ## 变更摘要 本次 PR 新增 MatmulFt 矩阵乘法外挂容错算子,代码位于 reliability/matmul_abft_verify。 该算子面向输出精度为 FLOAT32 的矩阵乘法算子。调用方提供输入矩阵 A、B 以及待检测的矩阵乘法结果 C,MatmulAbftVerify 基于方差估计 自适应门限算法(V-ABFT),对 C 执行分块 checksum 校验,以检测并定位矩阵乘法过程中产生的静默计算错误。 算子支持 BFLOAT16 和 FLOAT32 两种输入精度,支持 Atlas A2/A3 系列产品,并配套提供算子定义、shape/dtype 推导、 host tiling、kernel 实现、aclnn 接口文档以及 BF16 调用样例。 ## 主要改动 ### 新增 MatmulAbftVerify 外挂容错算子 - 接口功能:实现基于方差估计自适应门限算法(V-ABFT)的GEMM容错检测算子。算子接收矩阵A、B以及预先计算的矩阵乘结果C,对C进行分块ABFT校验,检测静默计算错误并输出逐行检测结果。 - 特点 - 自适应阈值: 该算子能够根据矩阵大小与值域自动确定用于比对的阈值,能够在保证检出率的同时避免误检。 - 自适应阈值算法与推导见https://gitee.com/yihenggao/v-abft的文档 - 计算量显著小于基于重新计算的容错方案。在矩阵维度m=n=k=a时,本算子只需8a^2次浮点计算,而重算则需要2a^3次浮点计算。且容错阈值也与该算法相匹配 - 计算公式: $$ C = A \times B, \quad A \in \mathbb{R}^{M \times K},\; B \in \mathbb{R}^{K \times N} $$ $$ C^r = C\times r, B^r=B\times r $$ 其中阈值$Threshold_i$由输入矩阵A、B的局部统计特征(均值、标准差)动态估计,无需依赖C矩阵输出结果。 - 算子功能说明: - 输入矩阵A、B和预先计算的C经过checksum编码、阈值估计和校验比对流程,输出压缩后的逐行故障检测结果张量 comp_row,1表示正确,0表示检测到错误。 ### 函数原型 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMatmulAbftVerifyGetWorkspaceSize”接口获取入参并根据计算流程计算所需workspace大小,再调用“aclnnMatmulAbftVerify”接口执行计算。 cpp aclnnStatus aclnnMatmulAbftVerifyGetWorkspaceSize( const aclTensor *a, const aclTensor *b, const aclTensor *c, const aclTensor *checksumWeight, double EMAX, const aclTensor *compRow, uint64_t *workspaceSize, aclOpExecutor **executor); cpp aclnnStatus aclnnMatmulAbftVerify( void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); ### aclnnMatmulAbftVerifyGetWorkspaceSize - **参数说明:** <table style="undefined;table-layout: fixed;width: 1540px"><colgroup> <col style="width: 170px"> <col style="width: 120px"> <col style="width: 300px"> <col style="width: 330px"> <col style="width: 212px"> <col style="width: 100px"> <col style="width: 190px"> <col style="width: 118px"> </colgroup> <thead> <tr> <th>参数名</th> <th style="white-space: nowrap">输入/输出</th> <th>描述</th> <th>使用说明</th> <th>数据类型</th> <th><a href="../../../docs/zh/context/数据格式.md" target="_blank">数据格式</a></th> <th style="white-space: nowrap">维度(shape)</th> <th><a href="../../../docs/zh/context/非连续的Tensor.md" target="_blank">非连续的Tensor</a></th> </tr> </thead> <tbody> <tr> <td>a(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入A。</td> <td> <ul> <li>维度为2,shape为[M, K]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[M, K]</td> <td>-</td> </tr> <tr> <td>b(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入B。</td> <td> <ul> <li>维度为2,shape为[K, N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[K, N]</td> <td>-</td> </tr> <tr> <td>c(aclTensor)</td> <td>输入</td> <td>预先计算的矩阵乘结果C = A × B,作为容错检测的数据输入。</td> <td> <ul> <li>维度为2,shape为[M, N]。</li> </ul> </td> <td>FLOAT32</td> <td>ND</td> <td>[M, N]</td> <td>-</td> </tr> <tr> <td>checksumWeight(aclTensor)</td> <td>输入</td> <td>列编码值向量,对应ABFT中的行校验和编码向量$r$(加权向量)。</td> <td> <ul> <li>维度为1,shape为[N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[N]</td> <td>-</td> </tr> <tr> <td>EMAX(double)</td> <td>输入</td> <td>误差阈值系数,控制故障检测的灵敏度。</td> <td> <ul> <li>默认值为0.001。</li> <li>A,B为BF16精度,推荐值:0.001</li> <li>A,B为FP32精度, 推荐值: 0.00002</li> <li>使用小于推荐值的EMAX会增大检出率,但是也可能会出现误检情况。</li> <li>在出现误报的时候,可以将EMAX调大。</li> </ul> </td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>compRow(aclTensor)</td> <td>输出</td> <td>压缩后的行方向故障检测位流输出。</td> <td> <ul> <li>每个bit表示一行一段的检测结果,1表示正确,0表示检测到错误。</li> </ul> </td> <td>UINT8</td> <td>ND</td> <td>[ceil(M/8) * splitN]</td> <td>-</td> </tr> <tr> <td>workspaceSize(uint64_t)</td> <td>输出</td> <td>返回需要在Device侧申请的workspace大小。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>executor(aclOpExecutor)</td> <td>输出</td> <td>返回op执行器,包含了算子计算流程。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> </tbody></table> 其中 $splitN = \lceil N / 256\rceil$。 ### 算子文档 新增 reliability/matmul_abft_verify/docs/MatmulAbftVerify.md ### BF16 调用样例 新增: reliability/matmul_abft_verify/examples/test_aclnn_matmul_abft_verify_bf16.cpp - ACL 运行环境初始化; - 输入、输出 Tensor 创建; - C 矩阵 Buffer 初始化; - workspace 查询与申请; - 算子调用; - 检测结果回拷和打印; - Device 资源释放。 由于前序矩阵乘法算子 aclnnGemm 暂时无法通过 ops-transformer 当前提供的脚本完成编译,仓库内样例仅展示 MatmulAbftVerify的调用方 式,没有在样例中串联实际的前序矩阵乘法,因此不构成完整的端到端容错演示。 包含前序矩阵乘法、多精度验证的完整样例可参考: https://gitee.com/kanby123/matmul_abft_verify ## 约束说明 - 确定性计算: - aclnnMatmulAbftVerify默认确定性实现。 - 输入矩阵a、b和c必须为2维,shape分别为[M, K]、[K, N]和[M, N],且a的第1维(K)与b的第0维(K)必须相等。 - 输入向量weight的shape必须为[N]。 - 支持的数据类型组合为: | a | b | c | checksumWeight | |:-------:|:-------:|:-------:|:-------:| | FLOAT16 | FLOAT16 | FLOAT32 | FLOAT16 | | BFLOAT16| BFLOAT16| FLOAT32 | BFLOAT16| | FLOAT32 | FLOAT32 | FLOAT32 | FLOAT32 | - 不支持的场景: - 不支持ND格式以外的数据格式。 - 不支持非连续的Tensor。 - 不支持a、b和c的维度不为2的场景。 ## Workspace使用设计 workspace由两部分组成: 1. 固定的16 MiB系统workspace。 2. user workspace,其中依次放置13个内部中间张量及FT内部临时区。 算子tiling阶段根据M、N、K和输入精度计算完整大小,并通过workspaceSize返回。调用者必须申请不少于该大小的连续device内存,不能只按compRow大小申请。所有中间张量的起始地址按32字节向上对齐。 定义: text splitN = ceil(N / 256) rowSplitLen = M * splitN bStatLen = ceil(splitN / 8) * 8 + 8 beLen = K * splitN align32(x) = ceil(x / 32) * 32 设W为user workspace首地址。在kernel内,W = AscendC::GetUserWorkspace(workspace);对于算子外部的device地址计算,当前实现等价于W = (uint8_t *)workspace + 16 MiB。 以下偏移均相对W。令S0 = 0,每个张量的起始偏移为Oi = align32(Si),结束位置为Si+1 = Oi + 元素数 × 元素字节数: | 顺序 | 中间结果 | 起始地址 | 元素类型 | 元素数 | |:--:|:--|:--|:--|--:| | 0 | z_row | W + O0 | FLOAT32 | rowSplitLen | | 1 | d_row | W + O1 | FLOAT32 | rowSplitLen | | 2 | threshold | W + O2 | FLOAT32 | rowSplitLen | | 3 | b_mean_abs | W + O3 | FLOAT32 | bStatLen | | 4 | b_mean_square | W + O4 | FLOAT32 | bStatLen | | 5 | b_var | W + O5 | FLOAT32 | bStatLen | | 6 | be | W + O6 | 与a相同 | beLen | | 7 | be_for_aiv | W + O7 | a为FLOAT16时是FLOAT16,否则是FLOAT32 | beLen | | 8 | b_max_slice | W + O8 | FLOAT32 | beLen | | 9 | b_min_slice | W + O9 | FLOAT32 | beLen | | 10 | a_max | W + O10 | FLOAT32 | M | | 11 | a_mean | W + O11 | FLOAT32 | M | | 12 | a_min | W + O12 | FLOAT32 | M | 其中FLOAT16和BFLOAT16元素占2字节,FLOAT32元素占4字节。第13段之后再次按32字节对齐,剩余区域是FT内部临时区,其逻辑大小为: text M * (splitN + 1) * sizeof(float) AMean计算使用的常量因子1/K不占用workspace。tiling阶段按输入精度生成该scalar,kernel在首次计算AMean时直接用它初始化FT的L1内部缓冲区,因此该因子不能作为workspace中间结果拷出。 如果需要调试并拷出某个中间结果,应在算子执行完成且workspace尚未释放或复用时,从上表对应的W + Oi开始执行device-to-host拷贝,拷贝字节数为“元素数 × 元素字节数”。对外读取workspace属于调试能力,不是稳定的公开输出接口;布局发生变更时,以[matmul_abft_verify.cpp](../op_kernel/matmul_abft_verify.cpp)中Workspace ABI注释下的地址切分代码为准,该代码也是偏移计算的示例实现。 ## 验证情况 ### 精度验证 - 算子编译及执行测试通过; - BF16 FP32 aclnn 接口调用测试通过; - 测试数据类型:BF16、FP32。 - 测试形状:矩阵乘形状按 (M, N, K) 表示,M/N/K 分别取 {1024, 2048, 4096, 8192},采用全组合覆盖,共 64 种形状/数据类 型,合计 128 个测试用例。 - 精度标杆:以 CPU 侧 Golden 计算结果为基准,校验 BMeanAbs、BMeanSquare、BVar、COMPRow、ZRow、BE/BEforAIV、DRow、 AMean、AMin、AMax 和 Thre 共 11 项中间结果及检测结果。阈值计算参数 e_max 为: - BF16:0.001 - FP32:0.00002 - 通过标准: - 所有输出元素必须为有限值; - 当累计计算量 computeNum < 2048 时,允许误差为 1/256 × max(1, |Golden|); - 当 computeNum ≥ 2048 时,允许误差为 1/128 × max(1, |Golden|); - COMPRow 要求与无错误标杆值 255 完全一致; - 任一校验项出现不满足条件的元素,该用例即判定失败。 - 测试结果:BF16 和 FP32 各 64/64 个形状全部执行成功;每个用例的 11 项 Golden 校验均为 PASSED,合计 128/128 个用例通 过,1408/1408 项校验通过,无失败项,通过率 100%。 结论:MatmulAbftVerify 算子在本次覆盖的 BF16、FP32 数据类型及全部 64 种矩阵形状下,精度测试全部通过。 - 完整的多精度测试见独立样例仓库。 ### FP32 C 错误注入实验 除无故障场景下的数值精度验证外,对待检测矩阵 \(C\) 进行了 bit-flip 错误注入,以验证算子对实际 SDC 的检测能力。 测试覆盖以下矩阵形状: text (M,K,N) = (2048,4096,4096) (2048,4096,8192) (4096,4096,4096) (4096,4096,8192) 并覆盖多种输入数据分布: text clamped_normal_0_1 normal_1_1 normal_1e-6_1 uniform_-1_1 对于 BF16 输入、FLOAT32 C 的实验,在 FP32 C 的 bit 27~29 注入错误时,四组矩阵 shape 的检出率基本保持稳定: * clamped_normal_0_1:约 **95.12%~95.27%** * normal_1_1:**100%** * normal_1e-6_1:约 **97.49%~97.60%** * uniform_-1_1:约 **92.51%~92.73%** 例如 \((M,K,N)=(4096,4096,8192)\) 时,bit 27~29 的检出率分别为约 95.20%、100%、97.60% 和 92.73%。 对于 FP32 输入,在测试的 bit 23~30 范围内,各数据分布的检出率整体保持在约 **90%~100%**。例如 \((4096,4096,4096)\) 时,bit 23~30 的检出率最低约为 90.04%,多项测试达到 100%。 与此同时,在上述错误注入测试对应的正常数据检测中,各测试 bit、矩阵 shape 和数据分布均未观察到误报,False-positive rate 为 **0%**。例如 FP32 \((4096,4096,8192)\) 的全部 bit 23~30 和四种数据分布误报率均为 0。 该结果说明,在当前错误注入覆盖范围内,自适应门限能够在保持零误报的同时,对会造成显著结果扰动的 bit-flip 错误维持较高检出率。 #### BF16 (M,K,N)=(2048,4096,4096) — Detection rate (%) | Bit | clamped_normal_0_1 | normal_1_1 | normal_1e-6_1 | uniform_-1_1 | |---:|---:|---:|---:|---:| | 23 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 24 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 25 | 7.360000 | 0.000000 | 0.000000 | 14.684000 | | 26 | 95.122000 | 0.000000 | 87.930000 | 92.506000 | | 27 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 28 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 29 | 95.122000 | 100.00 See merge request: cann/ops-ras!94 | 1 个月前 | |
add new operator matmul_abft_verify Co-authored-by: kanboyi<2036465770@qq.com> # message auto-generated for no-merge-commit merge: !94 merge add_matmul_abft_verify into master add new operator matmul_abft_verify Created-by: starfican Commit-by: kanboyi Merged-by: cann-robot Description: ## 变更摘要 本次 PR 新增 MatmulFt 矩阵乘法外挂容错算子,代码位于 reliability/matmul_abft_verify。 该算子面向输出精度为 FLOAT32 的矩阵乘法算子。调用方提供输入矩阵 A、B 以及待检测的矩阵乘法结果 C,MatmulAbftVerify 基于方差估计 自适应门限算法(V-ABFT),对 C 执行分块 checksum 校验,以检测并定位矩阵乘法过程中产生的静默计算错误。 算子支持 BFLOAT16 和 FLOAT32 两种输入精度,支持 Atlas A2/A3 系列产品,并配套提供算子定义、shape/dtype 推导、 host tiling、kernel 实现、aclnn 接口文档以及 BF16 调用样例。 ## 主要改动 ### 新增 MatmulAbftVerify 外挂容错算子 - 接口功能:实现基于方差估计自适应门限算法(V-ABFT)的GEMM容错检测算子。算子接收矩阵A、B以及预先计算的矩阵乘结果C,对C进行分块ABFT校验,检测静默计算错误并输出逐行检测结果。 - 特点 - 自适应阈值: 该算子能够根据矩阵大小与值域自动确定用于比对的阈值,能够在保证检出率的同时避免误检。 - 自适应阈值算法与推导见https://gitee.com/yihenggao/v-abft的文档 - 计算量显著小于基于重新计算的容错方案。在矩阵维度m=n=k=a时,本算子只需8a^2次浮点计算,而重算则需要2a^3次浮点计算。且容错阈值也与该算法相匹配 - 计算公式: $$ C = A \times B, \quad A \in \mathbb{R}^{M \times K},\; B \in \mathbb{R}^{K \times N} $$ $$ C^r = C\times r, B^r=B\times r $$ 其中阈值$Threshold_i$由输入矩阵A、B的局部统计特征(均值、标准差)动态估计,无需依赖C矩阵输出结果。 - 算子功能说明: - 输入矩阵A、B和预先计算的C经过checksum编码、阈值估计和校验比对流程,输出压缩后的逐行故障检测结果张量 comp_row,1表示正确,0表示检测到错误。 ### 函数原型 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMatmulAbftVerifyGetWorkspaceSize”接口获取入参并根据计算流程计算所需workspace大小,再调用“aclnnMatmulAbftVerify”接口执行计算。 cpp aclnnStatus aclnnMatmulAbftVerifyGetWorkspaceSize( const aclTensor *a, const aclTensor *b, const aclTensor *c, const aclTensor *checksumWeight, double EMAX, const aclTensor *compRow, uint64_t *workspaceSize, aclOpExecutor **executor); cpp aclnnStatus aclnnMatmulAbftVerify( void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); ### aclnnMatmulAbftVerifyGetWorkspaceSize - **参数说明:** <table style="undefined;table-layout: fixed;width: 1540px"><colgroup> <col style="width: 170px"> <col style="width: 120px"> <col style="width: 300px"> <col style="width: 330px"> <col style="width: 212px"> <col style="width: 100px"> <col style="width: 190px"> <col style="width: 118px"> </colgroup> <thead> <tr> <th>参数名</th> <th style="white-space: nowrap">输入/输出</th> <th>描述</th> <th>使用说明</th> <th>数据类型</th> <th><a href="../../../docs/zh/context/数据格式.md" target="_blank">数据格式</a></th> <th style="white-space: nowrap">维度(shape)</th> <th><a href="../../../docs/zh/context/非连续的Tensor.md" target="_blank">非连续的Tensor</a></th> </tr> </thead> <tbody> <tr> <td>a(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入A。</td> <td> <ul> <li>维度为2,shape为[M, K]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[M, K]</td> <td>-</td> </tr> <tr> <td>b(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入B。</td> <td> <ul> <li>维度为2,shape为[K, N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[K, N]</td> <td>-</td> </tr> <tr> <td>c(aclTensor)</td> <td>输入</td> <td>预先计算的矩阵乘结果C = A × B,作为容错检测的数据输入。</td> <td> <ul> <li>维度为2,shape为[M, N]。</li> </ul> </td> <td>FLOAT32</td> <td>ND</td> <td>[M, N]</td> <td>-</td> </tr> <tr> <td>checksumWeight(aclTensor)</td> <td>输入</td> <td>列编码值向量,对应ABFT中的行校验和编码向量$r$(加权向量)。</td> <td> <ul> <li>维度为1,shape为[N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[N]</td> <td>-</td> </tr> <tr> <td>EMAX(double)</td> <td>输入</td> <td>误差阈值系数,控制故障检测的灵敏度。</td> <td> <ul> <li>默认值为0.001。</li> <li>A,B为BF16精度,推荐值:0.001</li> <li>A,B为FP32精度, 推荐值: 0.00002</li> <li>使用小于推荐值的EMAX会增大检出率,但是也可能会出现误检情况。</li> <li>在出现误报的时候,可以将EMAX调大。</li> </ul> </td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>compRow(aclTensor)</td> <td>输出</td> <td>压缩后的行方向故障检测位流输出。</td> <td> <ul> <li>每个bit表示一行一段的检测结果,1表示正确,0表示检测到错误。</li> </ul> </td> <td>UINT8</td> <td>ND</td> <td>[ceil(M/8) * splitN]</td> <td>-</td> </tr> <tr> <td>workspaceSize(uint64_t)</td> <td>输出</td> <td>返回需要在Device侧申请的workspace大小。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>executor(aclOpExecutor)</td> <td>输出</td> <td>返回op执行器,包含了算子计算流程。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> </tbody></table> 其中 $splitN = \lceil N / 256\rceil$。 ### 算子文档 新增 reliability/matmul_abft_verify/docs/MatmulAbftVerify.md ### BF16 调用样例 新增: reliability/matmul_abft_verify/examples/test_aclnn_matmul_abft_verify_bf16.cpp - ACL 运行环境初始化; - 输入、输出 Tensor 创建; - C 矩阵 Buffer 初始化; - workspace 查询与申请; - 算子调用; - 检测结果回拷和打印; - Device 资源释放。 由于前序矩阵乘法算子 aclnnGemm 暂时无法通过 ops-transformer 当前提供的脚本完成编译,仓库内样例仅展示 MatmulAbftVerify的调用方 式,没有在样例中串联实际的前序矩阵乘法,因此不构成完整的端到端容错演示。 包含前序矩阵乘法、多精度验证的完整样例可参考: https://gitee.com/kanby123/matmul_abft_verify ## 约束说明 - 确定性计算: - aclnnMatmulAbftVerify默认确定性实现。 - 输入矩阵a、b和c必须为2维,shape分别为[M, K]、[K, N]和[M, N],且a的第1维(K)与b的第0维(K)必须相等。 - 输入向量weight的shape必须为[N]。 - 支持的数据类型组合为: | a | b | c | checksumWeight | |:-------:|:-------:|:-------:|:-------:| | FLOAT16 | FLOAT16 | FLOAT32 | FLOAT16 | | BFLOAT16| BFLOAT16| FLOAT32 | BFLOAT16| | FLOAT32 | FLOAT32 | FLOAT32 | FLOAT32 | - 不支持的场景: - 不支持ND格式以外的数据格式。 - 不支持非连续的Tensor。 - 不支持a、b和c的维度不为2的场景。 ## Workspace使用设计 workspace由两部分组成: 1. 固定的16 MiB系统workspace。 2. user workspace,其中依次放置13个内部中间张量及FT内部临时区。 算子tiling阶段根据M、N、K和输入精度计算完整大小,并通过workspaceSize返回。调用者必须申请不少于该大小的连续device内存,不能只按compRow大小申请。所有中间张量的起始地址按32字节向上对齐。 定义: text splitN = ceil(N / 256) rowSplitLen = M * splitN bStatLen = ceil(splitN / 8) * 8 + 8 beLen = K * splitN align32(x) = ceil(x / 32) * 32 设W为user workspace首地址。在kernel内,W = AscendC::GetUserWorkspace(workspace);对于算子外部的device地址计算,当前实现等价于W = (uint8_t *)workspace + 16 MiB。 以下偏移均相对W。令S0 = 0,每个张量的起始偏移为Oi = align32(Si),结束位置为Si+1 = Oi + 元素数 × 元素字节数: | 顺序 | 中间结果 | 起始地址 | 元素类型 | 元素数 | |:--:|:--|:--|:--|--:| | 0 | z_row | W + O0 | FLOAT32 | rowSplitLen | | 1 | d_row | W + O1 | FLOAT32 | rowSplitLen | | 2 | threshold | W + O2 | FLOAT32 | rowSplitLen | | 3 | b_mean_abs | W + O3 | FLOAT32 | bStatLen | | 4 | b_mean_square | W + O4 | FLOAT32 | bStatLen | | 5 | b_var | W + O5 | FLOAT32 | bStatLen | | 6 | be | W + O6 | 与a相同 | beLen | | 7 | be_for_aiv | W + O7 | a为FLOAT16时是FLOAT16,否则是FLOAT32 | beLen | | 8 | b_max_slice | W + O8 | FLOAT32 | beLen | | 9 | b_min_slice | W + O9 | FLOAT32 | beLen | | 10 | a_max | W + O10 | FLOAT32 | M | | 11 | a_mean | W + O11 | FLOAT32 | M | | 12 | a_min | W + O12 | FLOAT32 | M | 其中FLOAT16和BFLOAT16元素占2字节,FLOAT32元素占4字节。第13段之后再次按32字节对齐,剩余区域是FT内部临时区,其逻辑大小为: text M * (splitN + 1) * sizeof(float) AMean计算使用的常量因子1/K不占用workspace。tiling阶段按输入精度生成该scalar,kernel在首次计算AMean时直接用它初始化FT的L1内部缓冲区,因此该因子不能作为workspace中间结果拷出。 如果需要调试并拷出某个中间结果,应在算子执行完成且workspace尚未释放或复用时,从上表对应的W + Oi开始执行device-to-host拷贝,拷贝字节数为“元素数 × 元素字节数”。对外读取workspace属于调试能力,不是稳定的公开输出接口;布局发生变更时,以[matmul_abft_verify.cpp](../op_kernel/matmul_abft_verify.cpp)中Workspace ABI注释下的地址切分代码为准,该代码也是偏移计算的示例实现。 ## 验证情况 ### 精度验证 - 算子编译及执行测试通过; - BF16 FP32 aclnn 接口调用测试通过; - 测试数据类型:BF16、FP32。 - 测试形状:矩阵乘形状按 (M, N, K) 表示,M/N/K 分别取 {1024, 2048, 4096, 8192},采用全组合覆盖,共 64 种形状/数据类 型,合计 128 个测试用例。 - 精度标杆:以 CPU 侧 Golden 计算结果为基准,校验 BMeanAbs、BMeanSquare、BVar、COMPRow、ZRow、BE/BEforAIV、DRow、 AMean、AMin、AMax 和 Thre 共 11 项中间结果及检测结果。阈值计算参数 e_max 为: - BF16:0.001 - FP32:0.00002 - 通过标准: - 所有输出元素必须为有限值; - 当累计计算量 computeNum < 2048 时,允许误差为 1/256 × max(1, |Golden|); - 当 computeNum ≥ 2048 时,允许误差为 1/128 × max(1, |Golden|); - COMPRow 要求与无错误标杆值 255 完全一致; - 任一校验项出现不满足条件的元素,该用例即判定失败。 - 测试结果:BF16 和 FP32 各 64/64 个形状全部执行成功;每个用例的 11 项 Golden 校验均为 PASSED,合计 128/128 个用例通 过,1408/1408 项校验通过,无失败项,通过率 100%。 结论:MatmulAbftVerify 算子在本次覆盖的 BF16、FP32 数据类型及全部 64 种矩阵形状下,精度测试全部通过。 - 完整的多精度测试见独立样例仓库。 ### FP32 C 错误注入实验 除无故障场景下的数值精度验证外,对待检测矩阵 \(C\) 进行了 bit-flip 错误注入,以验证算子对实际 SDC 的检测能力。 测试覆盖以下矩阵形状: text (M,K,N) = (2048,4096,4096) (2048,4096,8192) (4096,4096,4096) (4096,4096,8192) 并覆盖多种输入数据分布: text clamped_normal_0_1 normal_1_1 normal_1e-6_1 uniform_-1_1 对于 BF16 输入、FLOAT32 C 的实验,在 FP32 C 的 bit 27~29 注入错误时,四组矩阵 shape 的检出率基本保持稳定: * clamped_normal_0_1:约 **95.12%~95.27%** * normal_1_1:**100%** * normal_1e-6_1:约 **97.49%~97.60%** * uniform_-1_1:约 **92.51%~92.73%** 例如 \((M,K,N)=(4096,4096,8192)\) 时,bit 27~29 的检出率分别为约 95.20%、100%、97.60% 和 92.73%。 对于 FP32 输入,在测试的 bit 23~30 范围内,各数据分布的检出率整体保持在约 **90%~100%**。例如 \((4096,4096,4096)\) 时,bit 23~30 的检出率最低约为 90.04%,多项测试达到 100%。 与此同时,在上述错误注入测试对应的正常数据检测中,各测试 bit、矩阵 shape 和数据分布均未观察到误报,False-positive rate 为 **0%**。例如 FP32 \((4096,4096,8192)\) 的全部 bit 23~30 和四种数据分布误报率均为 0。 该结果说明,在当前错误注入覆盖范围内,自适应门限能够在保持零误报的同时,对会造成显著结果扰动的 bit-flip 错误维持较高检出率。 #### BF16 (M,K,N)=(2048,4096,4096) — Detection rate (%) | Bit | clamped_normal_0_1 | normal_1_1 | normal_1e-6_1 | uniform_-1_1 | |---:|---:|---:|---:|---:| | 23 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 24 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 25 | 7.360000 | 0.000000 | 0.000000 | 14.684000 | | 26 | 95.122000 | 0.000000 | 87.930000 | 92.506000 | | 27 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 28 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 29 | 95.122000 | 100.00 See merge request: cann/ops-ras!94 | 1 个月前 | |
add new operator matmul_abft_verify Co-authored-by: kanboyi<2036465770@qq.com> # message auto-generated for no-merge-commit merge: !94 merge add_matmul_abft_verify into master add new operator matmul_abft_verify Created-by: starfican Commit-by: kanboyi Merged-by: cann-robot Description: ## 变更摘要 本次 PR 新增 MatmulFt 矩阵乘法外挂容错算子,代码位于 reliability/matmul_abft_verify。 该算子面向输出精度为 FLOAT32 的矩阵乘法算子。调用方提供输入矩阵 A、B 以及待检测的矩阵乘法结果 C,MatmulAbftVerify 基于方差估计 自适应门限算法(V-ABFT),对 C 执行分块 checksum 校验,以检测并定位矩阵乘法过程中产生的静默计算错误。 算子支持 BFLOAT16 和 FLOAT32 两种输入精度,支持 Atlas A2/A3 系列产品,并配套提供算子定义、shape/dtype 推导、 host tiling、kernel 实现、aclnn 接口文档以及 BF16 调用样例。 ## 主要改动 ### 新增 MatmulAbftVerify 外挂容错算子 - 接口功能:实现基于方差估计自适应门限算法(V-ABFT)的GEMM容错检测算子。算子接收矩阵A、B以及预先计算的矩阵乘结果C,对C进行分块ABFT校验,检测静默计算错误并输出逐行检测结果。 - 特点 - 自适应阈值: 该算子能够根据矩阵大小与值域自动确定用于比对的阈值,能够在保证检出率的同时避免误检。 - 自适应阈值算法与推导见https://gitee.com/yihenggao/v-abft的文档 - 计算量显著小于基于重新计算的容错方案。在矩阵维度m=n=k=a时,本算子只需8a^2次浮点计算,而重算则需要2a^3次浮点计算。且容错阈值也与该算法相匹配 - 计算公式: $$ C = A \times B, \quad A \in \mathbb{R}^{M \times K},\; B \in \mathbb{R}^{K \times N} $$ $$ C^r = C\times r, B^r=B\times r $$ 其中阈值$Threshold_i$由输入矩阵A、B的局部统计特征(均值、标准差)动态估计,无需依赖C矩阵输出结果。 - 算子功能说明: - 输入矩阵A、B和预先计算的C经过checksum编码、阈值估计和校验比对流程,输出压缩后的逐行故障检测结果张量 comp_row,1表示正确,0表示检测到错误。 ### 函数原型 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMatmulAbftVerifyGetWorkspaceSize”接口获取入参并根据计算流程计算所需workspace大小,再调用“aclnnMatmulAbftVerify”接口执行计算。 cpp aclnnStatus aclnnMatmulAbftVerifyGetWorkspaceSize( const aclTensor *a, const aclTensor *b, const aclTensor *c, const aclTensor *checksumWeight, double EMAX, const aclTensor *compRow, uint64_t *workspaceSize, aclOpExecutor **executor); cpp aclnnStatus aclnnMatmulAbftVerify( void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); ### aclnnMatmulAbftVerifyGetWorkspaceSize - **参数说明:** <table style="undefined;table-layout: fixed;width: 1540px"><colgroup> <col style="width: 170px"> <col style="width: 120px"> <col style="width: 300px"> <col style="width: 330px"> <col style="width: 212px"> <col style="width: 100px"> <col style="width: 190px"> <col style="width: 118px"> </colgroup> <thead> <tr> <th>参数名</th> <th style="white-space: nowrap">输入/输出</th> <th>描述</th> <th>使用说明</th> <th>数据类型</th> <th><a href="../../../docs/zh/context/数据格式.md" target="_blank">数据格式</a></th> <th style="white-space: nowrap">维度(shape)</th> <th><a href="../../../docs/zh/context/非连续的Tensor.md" target="_blank">非连续的Tensor</a></th> </tr> </thead> <tbody> <tr> <td>a(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入A。</td> <td> <ul> <li>维度为2,shape为[M, K]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[M, K]</td> <td>-</td> </tr> <tr> <td>b(aclTensor)</td> <td>输入</td> <td>矩阵乘法输入B。</td> <td> <ul> <li>维度为2,shape为[K, N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[K, N]</td> <td>-</td> </tr> <tr> <td>c(aclTensor)</td> <td>输入</td> <td>预先计算的矩阵乘结果C = A × B,作为容错检测的数据输入。</td> <td> <ul> <li>维度为2,shape为[M, N]。</li> </ul> </td> <td>FLOAT32</td> <td>ND</td> <td>[M, N]</td> <td>-</td> </tr> <tr> <td>checksumWeight(aclTensor)</td> <td>输入</td> <td>列编码值向量,对应ABFT中的行校验和编码向量$r$(加权向量)。</td> <td> <ul> <li>维度为1,shape为[N]。</li> </ul> </td> <td>FLOAT16、BFLOAT16、FLOAT32</td> <td>ND</td> <td>[N]</td> <td>-</td> </tr> <tr> <td>EMAX(double)</td> <td>输入</td> <td>误差阈值系数,控制故障检测的灵敏度。</td> <td> <ul> <li>默认值为0.001。</li> <li>A,B为BF16精度,推荐值:0.001</li> <li>A,B为FP32精度, 推荐值: 0.00002</li> <li>使用小于推荐值的EMAX会增大检出率,但是也可能会出现误检情况。</li> <li>在出现误报的时候,可以将EMAX调大。</li> </ul> </td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>compRow(aclTensor)</td> <td>输出</td> <td>压缩后的行方向故障检测位流输出。</td> <td> <ul> <li>每个bit表示一行一段的检测结果,1表示正确,0表示检测到错误。</li> </ul> </td> <td>UINT8</td> <td>ND</td> <td>[ceil(M/8) * splitN]</td> <td>-</td> </tr> <tr> <td>workspaceSize(uint64_t)</td> <td>输出</td> <td>返回需要在Device侧申请的workspace大小。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> <tr> <td>executor(aclOpExecutor)</td> <td>输出</td> <td>返回op执行器,包含了算子计算流程。</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> <td>-</td> </tr> </tbody></table> 其中 $splitN = \lceil N / 256\rceil$。 ### 算子文档 新增 reliability/matmul_abft_verify/docs/MatmulAbftVerify.md ### BF16 调用样例 新增: reliability/matmul_abft_verify/examples/test_aclnn_matmul_abft_verify_bf16.cpp - ACL 运行环境初始化; - 输入、输出 Tensor 创建; - C 矩阵 Buffer 初始化; - workspace 查询与申请; - 算子调用; - 检测结果回拷和打印; - Device 资源释放。 由于前序矩阵乘法算子 aclnnGemm 暂时无法通过 ops-transformer 当前提供的脚本完成编译,仓库内样例仅展示 MatmulAbftVerify的调用方 式,没有在样例中串联实际的前序矩阵乘法,因此不构成完整的端到端容错演示。 包含前序矩阵乘法、多精度验证的完整样例可参考: https://gitee.com/kanby123/matmul_abft_verify ## 约束说明 - 确定性计算: - aclnnMatmulAbftVerify默认确定性实现。 - 输入矩阵a、b和c必须为2维,shape分别为[M, K]、[K, N]和[M, N],且a的第1维(K)与b的第0维(K)必须相等。 - 输入向量weight的shape必须为[N]。 - 支持的数据类型组合为: | a | b | c | checksumWeight | |:-------:|:-------:|:-------:|:-------:| | FLOAT16 | FLOAT16 | FLOAT32 | FLOAT16 | | BFLOAT16| BFLOAT16| FLOAT32 | BFLOAT16| | FLOAT32 | FLOAT32 | FLOAT32 | FLOAT32 | - 不支持的场景: - 不支持ND格式以外的数据格式。 - 不支持非连续的Tensor。 - 不支持a、b和c的维度不为2的场景。 ## Workspace使用设计 workspace由两部分组成: 1. 固定的16 MiB系统workspace。 2. user workspace,其中依次放置13个内部中间张量及FT内部临时区。 算子tiling阶段根据M、N、K和输入精度计算完整大小,并通过workspaceSize返回。调用者必须申请不少于该大小的连续device内存,不能只按compRow大小申请。所有中间张量的起始地址按32字节向上对齐。 定义: text splitN = ceil(N / 256) rowSplitLen = M * splitN bStatLen = ceil(splitN / 8) * 8 + 8 beLen = K * splitN align32(x) = ceil(x / 32) * 32 设W为user workspace首地址。在kernel内,W = AscendC::GetUserWorkspace(workspace);对于算子外部的device地址计算,当前实现等价于W = (uint8_t *)workspace + 16 MiB。 以下偏移均相对W。令S0 = 0,每个张量的起始偏移为Oi = align32(Si),结束位置为Si+1 = Oi + 元素数 × 元素字节数: | 顺序 | 中间结果 | 起始地址 | 元素类型 | 元素数 | |:--:|:--|:--|:--|--:| | 0 | z_row | W + O0 | FLOAT32 | rowSplitLen | | 1 | d_row | W + O1 | FLOAT32 | rowSplitLen | | 2 | threshold | W + O2 | FLOAT32 | rowSplitLen | | 3 | b_mean_abs | W + O3 | FLOAT32 | bStatLen | | 4 | b_mean_square | W + O4 | FLOAT32 | bStatLen | | 5 | b_var | W + O5 | FLOAT32 | bStatLen | | 6 | be | W + O6 | 与a相同 | beLen | | 7 | be_for_aiv | W + O7 | a为FLOAT16时是FLOAT16,否则是FLOAT32 | beLen | | 8 | b_max_slice | W + O8 | FLOAT32 | beLen | | 9 | b_min_slice | W + O9 | FLOAT32 | beLen | | 10 | a_max | W + O10 | FLOAT32 | M | | 11 | a_mean | W + O11 | FLOAT32 | M | | 12 | a_min | W + O12 | FLOAT32 | M | 其中FLOAT16和BFLOAT16元素占2字节,FLOAT32元素占4字节。第13段之后再次按32字节对齐,剩余区域是FT内部临时区,其逻辑大小为: text M * (splitN + 1) * sizeof(float) AMean计算使用的常量因子1/K不占用workspace。tiling阶段按输入精度生成该scalar,kernel在首次计算AMean时直接用它初始化FT的L1内部缓冲区,因此该因子不能作为workspace中间结果拷出。 如果需要调试并拷出某个中间结果,应在算子执行完成且workspace尚未释放或复用时,从上表对应的W + Oi开始执行device-to-host拷贝,拷贝字节数为“元素数 × 元素字节数”。对外读取workspace属于调试能力,不是稳定的公开输出接口;布局发生变更时,以[matmul_abft_verify.cpp](../op_kernel/matmul_abft_verify.cpp)中Workspace ABI注释下的地址切分代码为准,该代码也是偏移计算的示例实现。 ## 验证情况 ### 精度验证 - 算子编译及执行测试通过; - BF16 FP32 aclnn 接口调用测试通过; - 测试数据类型:BF16、FP32。 - 测试形状:矩阵乘形状按 (M, N, K) 表示,M/N/K 分别取 {1024, 2048, 4096, 8192},采用全组合覆盖,共 64 种形状/数据类 型,合计 128 个测试用例。 - 精度标杆:以 CPU 侧 Golden 计算结果为基准,校验 BMeanAbs、BMeanSquare、BVar、COMPRow、ZRow、BE/BEforAIV、DRow、 AMean、AMin、AMax 和 Thre 共 11 项中间结果及检测结果。阈值计算参数 e_max 为: - BF16:0.001 - FP32:0.00002 - 通过标准: - 所有输出元素必须为有限值; - 当累计计算量 computeNum < 2048 时,允许误差为 1/256 × max(1, |Golden|); - 当 computeNum ≥ 2048 时,允许误差为 1/128 × max(1, |Golden|); - COMPRow 要求与无错误标杆值 255 完全一致; - 任一校验项出现不满足条件的元素,该用例即判定失败。 - 测试结果:BF16 和 FP32 各 64/64 个形状全部执行成功;每个用例的 11 项 Golden 校验均为 PASSED,合计 128/128 个用例通 过,1408/1408 项校验通过,无失败项,通过率 100%。 结论:MatmulAbftVerify 算子在本次覆盖的 BF16、FP32 数据类型及全部 64 种矩阵形状下,精度测试全部通过。 - 完整的多精度测试见独立样例仓库。 ### FP32 C 错误注入实验 除无故障场景下的数值精度验证外,对待检测矩阵 \(C\) 进行了 bit-flip 错误注入,以验证算子对实际 SDC 的检测能力。 测试覆盖以下矩阵形状: text (M,K,N) = (2048,4096,4096) (2048,4096,8192) (4096,4096,4096) (4096,4096,8192) 并覆盖多种输入数据分布: text clamped_normal_0_1 normal_1_1 normal_1e-6_1 uniform_-1_1 对于 BF16 输入、FLOAT32 C 的实验,在 FP32 C 的 bit 27~29 注入错误时,四组矩阵 shape 的检出率基本保持稳定: * clamped_normal_0_1:约 **95.12%~95.27%** * normal_1_1:**100%** * normal_1e-6_1:约 **97.49%~97.60%** * uniform_-1_1:约 **92.51%~92.73%** 例如 \((M,K,N)=(4096,4096,8192)\) 时,bit 27~29 的检出率分别为约 95.20%、100%、97.60% 和 92.73%。 对于 FP32 输入,在测试的 bit 23~30 范围内,各数据分布的检出率整体保持在约 **90%~100%**。例如 \((4096,4096,4096)\) 时,bit 23~30 的检出率最低约为 90.04%,多项测试达到 100%。 与此同时,在上述错误注入测试对应的正常数据检测中,各测试 bit、矩阵 shape 和数据分布均未观察到误报,False-positive rate 为 **0%**。例如 FP32 \((4096,4096,8192)\) 的全部 bit 23~30 和四种数据分布误报率均为 0。 该结果说明,在当前错误注入覆盖范围内,自适应门限能够在保持零误报的同时,对会造成显著结果扰动的 bit-flip 错误维持较高检出率。 #### BF16 (M,K,N)=(2048,4096,4096) — Detection rate (%) | Bit | clamped_normal_0_1 | normal_1_1 | normal_1e-6_1 | uniform_-1_1 | |---:|---:|---:|---:|---:| | 23 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 24 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | | 25 | 7.360000 | 0.000000 | 0.000000 | 14.684000 | | 26 | 95.122000 | 0.000000 | 87.930000 | 92.506000 | | 27 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 28 | 95.122000 | 100.000000 | 97.531000 | 92.506000 | | 29 | 95.122000 | 100.00 See merge request: cann/ops-ras!94 | 1 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 5 天前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 30 天前 | ||
| 2 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 |