TTK(Ops Test Tool Kit)是CANN算子库提供的全链路、自动化、批量化算子测试框架,帮助开发者快速完成算子批量功能验证、性能评估以及Golden值比对,提升算子开发质量和效率。
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
fix: pre-commit code Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !199 merge br_geir into master fix: pre-commit code Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 让全仓代码通过 pre-commit 全套 hook(ruff check + ruff format + codespell + trailing-whitespace / end-of-file-fixer / check-yaml 等基础 hook),共涉及 255 个文件(+9975/-7615)。 #### 修复内容分类 | 类别 | 规则 | 处理方式 | 数量 | |------|------|---------|------| | 真 bug | F821 | 字符串前向注解补 TYPE_CHECKING 导入;删死代码 del cas_mm | 13 | | | F811 | 删 testcase_op.py 被覆盖的重复 @property | 2 | | | B012 | profiling.py finally 内 return 重构为 try/except 后顺序执行 | 1 | | | hccl_cascade timeout | 主线笔误 timeout 未定义(10 处 F821),提取 _get_timeout() 为变量 | 10 | | 设计类豁免 | B027/B024 | 可选 hook / 抽象基类加 # noqa | 9 | | | E402 | backend 文件调换 docstring↔__future__ 顺序;延迟导入加 # noqa | 16 | | | F405/F403 | import * 展开为显式 import | 55 | | 异常处理 | E722 | 裸 except: → except Exception: | 37 | | | B904 | raise X → raise X from e(链式)/ from None(有意屏蔽) | 9 | | 未用代码 | F401 | re-export 导入加冗余别名 import x as x(不改 import * 行为) | 35 | | | F841 | 删确未使用的局部变量赋值 | 25 | | | B007 | 未用循环变量 → _ | 15 | | 格式化 | UP031 | % 格式化 → f-string(用 float()/str() 强转保留 printf 语义) | 88 | | | E712/E741/E731/B005 等 | != True→~、模糊名 l→ci、lambda→def、rstrip 多字符精确化 | 6 | | | trailing-ws / eof | 自动修复 | 23 | #### codespell 修复 - .gitcode/ISSUE_TEMPLATE/feature-request.yml:Backgroud → Background(真错字) - codespell 忽略列表加 dOut(数据术语 derivative output,误报) ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes # ### 希望检视人员了解: - **非纯格式化**:除格式化外混入了 37 处 except:→except Exception: + 9 处 from e/from None 的异常处理变更(E722/B904,ruff 无自动修复,手动逐处确认语义安全),以及 10 处 hccl_cascade timeout bug 修复。 - **F841/B007 为 unsafe fix**:项目 pre-commit 配置未启用 --unsafe-fixes,这些删除/改名是手动执行并逐一确认变量确实未使用。 - **printf→f-string 保语义**:%-14.18f → {float(x):<14.18f}(加 float() 强转,因为 ml_dtypes.int4 的 printf 会强转但 f-string :f 不会),输出逐字节一致。 - **re-export 用冗余别名**:11 个 __init__.py / shim 模块的 F401 修复用 import x as x 而非 __all__,完全不改 from module import * 行为。 ## 测试 - pre-commit 9 hook 全 Passed - ruff check / ruff format 全绿 - 1321 个非设备测试通过(0 失败,20 skip 为预存在的 torch_npu/tf 冲突) - ttk 全模块 walk-import 冒烟通过(唯一失败 executor_main 为预存在的运行时依赖) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码质量清理 / lint 规范化 See merge request: cann/ops-test-kit!199 | 9 天前 | |
feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Co-authored-by: dengguojie<dengguojie@huawei.com> # message auto-generated for no-merge-commit merge: !6 merge master into master feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Created-by: dengguojie Commit-by: dengguojie Merged-by: cann-robot Description: ## 描述 1. cext_loader: 提取 C 扩展在线编译+加载公共逻辑(per-target flock + atomic marker) 2. error_manager_cleaner: 清理 ErrorManager 残留错误,防止跨用例污染 tiling 判定 3. op_registry_accessor: split API(Find + Invoke gen_simplifiedkey),支持 simplifiedKeyMode=2 算子 4. platform: 兼容新旧 CANN 目录结构(vendors/ built-in/op_impl vs op_impl/built-in),fallback 无 config.ini 时走 custom 路径 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!6 | 3 个月前 | |
feat: support xpu complex32 Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !226 merge br_geir into master feat: support xpu complex32 Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 1. xpu支持complex32 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes # ### 希望检视人员了解: ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!226 | 20 小时前 | |
fix: data_range 值域分布 Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !205 merge br_bugfix into master fix: data_range 值域分布 Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 修复 issue #135:全值域数据生成(如 [[-3.3895313892515355e+38, 3.3895313892515355e+38]])当前使用 uniform 均匀分布,在极大区间下生成的几乎全是大数据(97% 落在 1e37~1e38 量级),经过计算极其容易溢出,不符合区间语义。 **根因**:浮点数可表示值中大值区间的"体积"远大于小值区间,线性 uniform 采样会让大值占绝对多数,小数几乎无法生成。 **修复方案**:对齐 ATK 的指数分布法(尾数 × 10^随机指数),使各量级概率均等: 1. 新增 _is_full_value_range(dtype, low, high):判定浮点类型且 low/high 覆盖到该 dtype 完整值域(相对容差 99%、跨零对称)。[-inf, inf] 与 [-3.389e+38, 3.389e+38](bf16 max) 均命中。 2. 新增 _gen_exponential_data(dtype, shape):复刻 ATK data_torch.py:41-58 —— 尾数 uniform(-1,1) × 10^randint(log10(tiny), log10(max)),各量级概率均等。 3. 在 _random 的 default 分支接入:仅 distribution=="uniform" 且命中全值域时走指数法;其余(小范围、normal、hifloat4、float64、torch 大张量路径)行为不变。 4. 边界值由既有 _mix_expect_data 自动混入 ±max/±0,补上 ATK 不碰边界的短板。 **生成效果对比**(fp16, shape=720, range=[-65504, 65504]): - 修改前 uniform:量级 e2~e4(仅3档),85% 的值 >1e4,小数 0 个 - 修改后 指数法:量级 e-5~e4 共 10 档均匀分布,小数 142 个,无 inf/nan ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes #135 ### 希望检视人员了解: - 改动仅影响"浮点全值域 + uniform 分布"这一支,小范围区间(如 [-1,1])、normal 分布、int 类型等行为不变 - 顺带修了 CI 门禁卡的两个既有 lint 违规(S307: eval→int、C410: 冗余 list() 调用),均为等价替换 ## 测试 - 新增 3 组回归测试(tests/utilities/test_data.py):全值域 fp32/fp16 覆盖多量级且无 inf、显式 bf16 max 触发指数法、小范围不误触发 - 全量回归:tests/utilities/ + tests/core_modules/manual_data/ + tests/core_modules/npu/test_custom_input_ori_sync.py 共 160 项通过 - ruff 零新增违规 ## 文档更新 无 ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!205 | 7 天前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
feat: support xpu complex32 Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !226 merge br_geir into master feat: support xpu complex32 Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 1. xpu支持complex32 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes # ### 希望检视人员了解: ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!226 | 20 小时前 | |
fix: geir msprof csv read | 19 小时前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
feat: add excel support Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !185 merge br_aclnn into master feat: add excel support Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: ### 当前PR是否有AI参与: [ ] 否 [x] 是 1. AI Agent 平台: opencode 2. AI 模型: glm-5.2 3. Prompt上下文: TTK 4 通路 Excel 用例输入适配 ### PR功能描述 / 为什么需要这个合入**: 为 4 条测试通路(Kernel/GEIR/ACLNN/E2E)增加 Excel(.xlsx/.xlsm) 用例输入支持,与 CSV 等价、可互换。 - 新增表格读取层 ttk/utilities/table_reader.py(read_table/read_csv_rows/resolved_sheet),CSV 走标准库、XLSX 走 openpyxl,单元格统一 str+strip 对齐 CSV 行为。 - UniversalTestcaseFactory 新增 from_path(path, sheet),4 通路共用,模式自动识别与字段解析零改动。 - CLI 新增 --sheet(默认首个工作表,CSV 忽略);_detect_framework 改用 read_table 兼容 xlsx。 - InstanceBase 按后缀路由 xlsx(避免误入 zip);默认输出名嵌入实际 sheet 名(如 cases_T2_result.csv),多 sheet 互不覆盖;输出仍为 CSV。 - SWITCHES 新增 sheet 字段;新增 openpyxl>=3.1 依赖。 - 新增每通路多 sheet xlsx 示例及各 Case Writing / Test Guide / Task_Execution / Test_Case_Generation / AGENTS 文档说明。 - 顺手清理 instance_base / testcase_manager / testcase_aclnn / classes / utilities.__init__ 既有 ruff 告警(E722/B904/UP031/F841/F821/F401/F403/B007)。 ### 该PR关联的issue fixes #127 ### 希望检视人员了解: - xlsx 单元格一律按文本处理(None→""、str()+strip),与 CSV 一致;数值列建议在 Excel 中预设为文本格式,避免 01→1、1e-8→浮点等类型推断。 - 同一 xlsx 用 --sheet 跑不同 sheet,输出名各异、互不覆盖。 - dOut 从 ACLNN backward 排除名移除(代码 + 文档一致)。 ## 测试 - 4 通路 --validate 全过(kernel 4 / geir 2 / aclnn 2 / e2e 4 用例均 valid)。 - kernel 端到端 ttk kernel -i examples/case_store/kernel/add.xlsx --sheet T2:编译 SUCC、精度 PASS、4/4 PASS。 ## 文档更新 - docs/Task_Execution.md:通用参数表新增 --sheet,--input 说明改 csv/xlsx。 - docs/Test_Case_Generation.md:新增「输入文件格式(CSV / Excel)」小节。 - docs/Operator_Test_Guides/*_Test_Guide.md:各通路「常用场景示例」补 xlsx 多 sheet 命令。 - docs/Operator_Test_Guides/*_Case_Writing.md:各通路「参考用例」表补每个 csv 的验证特性与关键列。 - AGENTS.md / examples/case_store/README.md:xlsx 说明。 ## 类型标签 - [x] 新特性 - [ ] Bug修复 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他 See merge request: cann/ops-test-kit!185 | 12 天前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
fix: golden use tensorflow error Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !72 merge br_aclnn into master fix: golden use tensorflow error Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [ ] 否 [x] 是 __1. AI Agent 平台: opencode __2. AI 模型: glm5.2 __3. Prompt上下文 : 补充issue:https://gitcode.com/cann/ops-test-kit/issues/15 缺失的文档,识别issue:https://gitcode.com/cann/ops-test-kit/issues/53的问题 ### PR功能描述 / 为什么需要这个合入**: 1. 修复tensorflow和tbe内部protobuf版本冲突导致的tf的golden失败的问题 2. 修复issue中的文档缺失 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#15](https://gitcode.com/cann/ops-test-kit/issues/15) https://gitcode.com/cann/ops-test-kit/issues/53 ### 希望检视人员了解: ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!72 | 1 个月前 | |
feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Co-authored-by: dengguojie<dengguojie@huawei.com> # message auto-generated for no-merge-commit merge: !6 merge master into master feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Created-by: dengguojie Commit-by: dengguojie Merged-by: cann-robot Description: ## 描述 1. cext_loader: 提取 C 扩展在线编译+加载公共逻辑(per-target flock + atomic marker) 2. error_manager_cleaner: 清理 ErrorManager 残留错误,防止跨用例污染 tiling 判定 3. op_registry_accessor: split API(Find + Invoke gen_simplifiedkey),支持 simplifiedKeyMode=2 算子 4. platform: 兼容新旧 CANN 目录结构(vendors/ built-in/op_impl vs op_impl/built-in),fallback 无 config.ini 时走 custom 路径 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!6 | 3 个月前 | |
fix: cross_check 传输层改用非压缩 npz,端到端提速 2.7x(issue #146) Co-authored-by: dengguojie<dengguojie@huawei.com> # message auto-generated for no-merge-commit merge: !215 merge 0904 into master fix: cross_check 传输层改用非压缩 npz,端到端提速 2.7x(issue #146) Created-by: dengguojie Commit-by: dengguojie Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 是 __1. AI Agent 平台: OpenCode __2. AI 模型: GLM __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: cross_check 传输层以 np.savez_compressed(zlib/DEFLATE)序列化随机测试张量。 随机数据对DEFLATE近不可压缩(实测压缩比0.913),压缩吞吐仅~38MB/s--localhost/同机房部署下, 压缩耗时远大于省下的9%传输量,成为XPU三方执行所段(占总耗时77%)的最大瓶颈。 改为 np savez (ZIP_STORED)后端到端提速2.7x(162.5s→60.6s,21条月用例),精度结果21/21 PASS不变。 附带: - dispatcher/executor 补 CANN-2.0 License 头(两文件为存量缺失,进入 扫描集后需合规) - 清理两文件 ruff 存量告警(SIM115/RET505/PLR5501/SIM102 等价重构), PLR0911 沿用项目对 PLR0912/0913/0915 的豁免惯例加入 ignore ### 该PR关联的issue #146 ### 希望检视人员了解: 1. CS分离部署的版本偏斜安全性:npz是ZIP容器,每个条目头自带compression method标记(ZIP_STORED=0 / ZIP_DEFLATE=8), np.load 读头自适应解压--"用什么方式还原"由报文自描述,无需双方约定。因此新C发STORED报文旧S 可正常读取(双向实测验证),分离部署各自升级窗口内无兼容风险。 2. 不是HTTP自动适配:本链路未使用 Content-Encoding传渝层压缩机制;HTTP仅按动态Content-Length裸传字节流,npz压缩发生在应用层序列化时,与HTTP编码协商正交 3. 代价:报文体积+~10%;sync通道10GB上限(xpu_serverr.py:375)场景需自行评估余量。 4. dry-run假数据路径(xpu_server.py:674)同步改为 npsavez,保持序列化方式全仓一致, 不留混用尾巴。 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [x] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!215 | 5 天前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
feat:生态算子开源精度标准 Co-authored-by: chenqianyu<chenqianyu1@h-partners.com> # message auto-generated for no-merge-commit merge: !214 merge mix_tol into master feat:生态算子开源精度标准 Created-by: FishPotatoChen Commit-by: chenqianyu Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 引入生态算子开源精度标准(混合容差 mix_tolerance),并作为浮点输出的默认精度比对方法,替换原默认的统计相对误差 stat_rel_err。 **主要改动:** 1. **新增 mix_tolerance 比对判据**(ttk/core_modules/comparison/mix_tolerance.py) - 逐元素通过条件:|a - g| <= atol + rtol * |g|(atol 兜底小值场景,天然避免除零;rtol 保证大值相对精度) - 整体通过条件:matched_ratio >= required_matched_ratio(0.99) 且 max_abs_error <= max_abs_error_limit(硬上限拦灾难性离群点) - NaN/Inf 特殊处理:双方同 NaN / 同号 Inf 视为一致;NaN/Inf 位置不一致视为无界误差,直接 FAIL 2. **按 dtype 的阈值表**(ttk/core_modules/comparison/resolve.py) - 覆盖 float16 / bfloat16 / float32 / hifloat32 / float8_e4m3fn / float8_e5m2,max_abs_error_limit 取 1e-X 与 32*ULP 满足任一;表外浮点 dtype(如 float64)回落 float32 档 - Spec.tolerance 中可按 dtype 覆盖 rtol / atol / required_matched_ratio / max_abs_error_limit 3. **默认路由切换**:未指定 --compare 且无 Spec.tolerance 时,普通浮点输出从 stat_rel_err 切换到 mix_tolerance;float8_e5m2/float8_e4m3fn 不再默认走 requant(requant 自动路由收窄至 hifloat8),可通过 --compare requant / --compare stat_rel_err 显式回退 4. **配置冲突护栏**:Spec.tolerance 只配 threshold(stat_rel_err 专属参数)而实际解析到 mix_tolerance 时,当场报错而非静默丢弃阈值,避免宽松阈值误报 / 严格阈值漏报 5. **CLI / Spec 接入**:--compare 新增 mix_tolerance 取值;Spec.tolerance 的 standard 字段新增 mix_tolerance 为官方标准 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#144](https://gitcode.com/cann/ops-test-kit/issues/144) ### 希望检视人员了解: - **行为变更**:默认精度判据由 stat_rel_err 变为 mix_tolerance,已有用例若未显式指定比对方法,精度结果可能发生变化;需要旧行为请显式 --compare stat_rel_err - CSV 的 precision_tolerances / absolute_precision 为 legacy 字段,仅 close/cosine 读取;默认 mix_tolerance 的容差调整需在 TestSpec tolerance 中覆盖(需 --plugin) - resolve.py 仍是容差解析唯一入口,比对类不查表,只消费解析好的最终值 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 新增单元测试 tests/core_modules/comparison/test_mix_tolerance.py:覆盖逐元素通过条件、atol/rtol 各自兜底场景、matched_ratio 边界、max_abs_error 硬上限、NaN/Inf 真值表、size 不一致 - 扩展 tests/core_modules/comparison/test_resolve_tolerance.py:默认路由切换(float32/float8 → mix_tolerance)、多输出混合 dtype 路由、阈值表默认值、表外 dtype 回落、Spec 覆盖、threshold 与 mix_tolerance 冲突报错护栏 - 更新 test_compare_integration.py / test_validator_tolerance.py 适配新默认值 - 全量单测通过(pytest tests/) ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - docs/Precision_Comparison.md:新增混合容差章节(公式、dtype 阈值表、NaN/Inf 处理、使能方式),全文方法编号与默认值说明更新 - docs/FAQ/faq_guide.md:精度方法推荐表、容差调整说明(含 legacy CSV 字段生效范围提示) - ttk/test_spec/README.md:tolerance standard 表新增 mix_tolerance 及可覆盖参数说明 - README.md / README-EN.md / CLAUDE.md / .claude/skills/* / docs/NPUSim/* / docs/Task_Execution.md / docs/Test_Case_Generation.md / docs/XPU_Cross_Check.md:默认比对方法描述同步更新 - ttk/test_spec/examples/04_golden_tolerance_compare.py / 05_pre_compare_customize_inputs.py:示例同步 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!214 | 1 天前 | |
fix: golden use tensorflow error Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !72 merge br_aclnn into master fix: golden use tensorflow error Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [ ] 否 [x] 是 __1. AI Agent 平台: opencode __2. AI 模型: glm5.2 __3. Prompt上下文 : 补充issue:https://gitcode.com/cann/ops-test-kit/issues/15 缺失的文档,识别issue:https://gitcode.com/cann/ops-test-kit/issues/53的问题 ### PR功能描述 / 为什么需要这个合入**: 1. 修复tensorflow和tbe内部protobuf版本冲突导致的tf的golden失败的问题 2. 修复issue中的文档缺失 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes [#15](https://gitcode.com/cann/ops-test-kit/issues/15) https://gitcode.com/cann/ops-test-kit/issues/53 ### 希望检视人员了解: ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!72 | 1 个月前 | |
feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Co-authored-by: dengguojie<dengguojie@huawei.com> # message auto-generated for no-merge-commit merge: !6 merge master into master feat: registry_accessor + error_manager_cleaner + cext_loader 公共能力 Created-by: dengguojie Commit-by: dengguojie Merged-by: cann-robot Description: ## 描述 1. cext_loader: 提取 C 扩展在线编译+加载公共逻辑(per-target flock + atomic marker) 2. error_manager_cleaner: 清理 ErrorManager 残留错误,防止跨用例污染 tiling 判定 3. op_registry_accessor: split API(Find + Invoke gen_simplifiedkey),支持 simplifiedKeyMode=2 算子 4. platform: 兼容新旧 CANN 目录结构(vendors/ built-in/op_impl vs op_impl/built-in),fallback 无 config.ini 时走 custom 路径 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!6 | 3 个月前 | |
fix: tf eager no need import torch_npu Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !218 merge br_bugfix into master fix: tf eager no need import torch_npu Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 否 [ ] 是 __1. AI Agent 平台: __2. AI 模型: __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: 修复 E2E TF NPU 通路下的 4 个缺陷(以 tf.image.combined_non_max_suppression 用例验证暴露): **1. TF eager 路径误 import torch_npu** _execute_eager 被 torch/TF 两框架共用,原先 if backend.is_npu(): import torch_npu; torch_npu.npu.set_device(dev_id)——NpuTfBackend.is_npu() 同样为 True,导致纯 TF 环境(装 npu_device 未装 torch_npu)eager 必挂。修复:设备设定下沉为 Backend.set_device(dev_id) 钩子,NpuTorchBackend 内做 torch_npu.npu.set_device,NpuTfBackend 内做 npu_device.open + as_default,torch/TF 统一语义、统一时机(_do_profile 输入生成前)。 **2. 父进程 open npu_device 导致 fork worker 段错误(-11)** FrameworkApiInstance.__init__ 创建 backend 时即 npu_device.open(),此后 worker 经 fork 拉起:C++ GE 线程不随 fork 存活,子进程继承坏句柄,MsProfiler 的 aclprofStart 段错误(faulthandler 定位 msprof/profiler.py:240)。修复:open 延迟到 set_device(fork 之后、首个 tf.Tensor 创建之前),父进程只做元数据查询。 **3. 0-D 标量被提升为 shape [1]** np.ascontiguousarray() 会把 0-D 数组提升为 (1,)(numpy 规定返回 ndim≥1)。TfBackend.from_numpy / CpuTfBackend.from_numpy / np_to_tf_inputs 三处中招,TF 0-D 参数校验报 max_size_per_class must be 0-D, got shape [1]。修复:0-D 跳过连续化(0-D 本就 C-contiguous)。 **4. TF 图模式丢失必填标量参数** TfGraphWrapper._build_kw_function 只透传 input_signature 覆盖的前 N 个参数,走 attributes 的必填标量(如 max_output_size_per_class)被截断,报 Missing required positional argument。修复:构造时将标量值烘焙进闭包,tf.function 追踪为 Const 节点(同时满足 GE infershape 对 const 输入的要求)。 **附**:TF 图编译(GE)要求此类算子的标量输入必须是 const 数据,对应用例需将标量参数放 attributes 而非 tensor_view_shapes(见 PR 内 combine.csv 调整)。 ### 该PR关联的issue *(格式为fixes #<issue号>, 或者resolves #<issue号>)*: fixes #152 ### 希望检视人员了解: - set_device 是唯一 open/set 点(带 dev_id);to_device/inputs_from_numpy/device_scope/from_numpy/wrap_eager_callable 均不再持有设备初始化职责 - npu_device 的 as_default() 为进程级一次性副作用,必须先于进程内首个 tf.convert_to_tensor,否则 TF context 冻结在 CPU、算子静默跑 CPU(假绿) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> 用例:tf.image.combined_non_max_suppression(56,73,108,4 / fp32,标量走 attributes) | 模式 | 结果 | |------|------| | e2e eager NPU | PASS(4 输出 mere/mare=0,device_perf ~14ms) | | e2e eager CPU | PASS | | e2e 静态图 -c | PASS | | e2e 动态图 -d | 不适用(GE 算子约束 boxes 尾维必须为常量 4,非本 PR 范围) | 单测:tests/core_modules/framework_api/ 47 passed;ruff 无新增告警。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 无 ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!218 | 4 天前 | |
fix: cross_check 传输层改用非压缩 npz,端到端提速 2.7x(issue #146) Co-authored-by: dengguojie<dengguojie@huawei.com> # message auto-generated for no-merge-commit merge: !215 merge 0904 into master fix: cross_check 传输层改用非压缩 npz,端到端提速 2.7x(issue #146) Created-by: dengguojie Commit-by: dengguojie Merged-by: cann-robot Description: <!-- 感谢您的合入申请! --> ### 当前PR是否有AI参与: [x] 是 __1. AI Agent 平台: OpenCode __2. AI 模型: GLM __3. Prompt上下文 : ### PR功能描述 / 为什么需要这个合入**: cross_check 传输层以 np.savez_compressed(zlib/DEFLATE)序列化随机测试张量。 随机数据对DEFLATE近不可压缩(实测压缩比0.913),压缩吞吐仅~38MB/s--localhost/同机房部署下, 压缩耗时远大于省下的9%传输量,成为XPU三方执行所段(占总耗时77%)的最大瓶颈。 改为 np savez (ZIP_STORED)后端到端提速2.7x(162.5s→60.6s,21条月用例),精度结果21/21 PASS不变。 附带: - dispatcher/executor 补 CANN-2.0 License 头(两文件为存量缺失,进入 扫描集后需合规) - 清理两文件 ruff 存量告警(SIM115/RET505/PLR5501/SIM102 等价重构), PLR0911 沿用项目对 PLR0912/0913/0915 的豁免惯例加入 ignore ### 该PR关联的issue #146 ### 希望检视人员了解: 1. CS分离部署的版本偏斜安全性:npz是ZIP容器,每个条目头自带compression method标记(ZIP_STORED=0 / ZIP_DEFLATE=8), np.load 读头自适应解压--"用什么方式还原"由报文自描述,无需双方约定。因此新C发STORED报文旧S 可正常读取(双向实测验证),分离部署各自升级窗口内无兼容风险。 2. 不是HTTP自动适配:本链路未使用 Content-Encoding传渝层压缩机制;HTTP仅按动态Content-Length裸传字节流,npz压缩发生在应用层序列化时,与HTTP编码协商正交 3. 代价:报文体积+~10%;sync通道10GB上限(xpu_serverr.py:375)场景需自行评估余量。 4. dry-run假数据路径(xpu_server.py:674)同步改为 npsavez,保持序列化方式全仓一致, 不留混用尾巴。 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [x] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-test-kit!215 | 5 天前 | |
feat: add excel support Co-authored-by: wangrui<wangrui124@huawei.com> # message auto-generated for no-merge-commit merge: !185 merge br_aclnn into master feat: add excel support Created-by: wangrui_ Commit-by: wangrui Merged-by: cann-robot Description: ### 当前PR是否有AI参与: [ ] 否 [x] 是 1. AI Agent 平台: opencode 2. AI 模型: glm-5.2 3. Prompt上下文: TTK 4 通路 Excel 用例输入适配 ### PR功能描述 / 为什么需要这个合入**: 为 4 条测试通路(Kernel/GEIR/ACLNN/E2E)增加 Excel(.xlsx/.xlsm) 用例输入支持,与 CSV 等价、可互换。 - 新增表格读取层 ttk/utilities/table_reader.py(read_table/read_csv_rows/resolved_sheet),CSV 走标准库、XLSX 走 openpyxl,单元格统一 str+strip 对齐 CSV 行为。 - UniversalTestcaseFactory 新增 from_path(path, sheet),4 通路共用,模式自动识别与字段解析零改动。 - CLI 新增 --sheet(默认首个工作表,CSV 忽略);_detect_framework 改用 read_table 兼容 xlsx。 - InstanceBase 按后缀路由 xlsx(避免误入 zip);默认输出名嵌入实际 sheet 名(如 cases_T2_result.csv),多 sheet 互不覆盖;输出仍为 CSV。 - SWITCHES 新增 sheet 字段;新增 openpyxl>=3.1 依赖。 - 新增每通路多 sheet xlsx 示例及各 Case Writing / Test Guide / Task_Execution / Test_Case_Generation / AGENTS 文档说明。 - 顺手清理 instance_base / testcase_manager / testcase_aclnn / classes / utilities.__init__ 既有 ruff 告警(E722/B904/UP031/F841/F821/F401/F403/B007)。 ### 该PR关联的issue fixes #127 ### 希望检视人员了解: - xlsx 单元格一律按文本处理(None→""、str()+strip),与 CSV 一致;数值列建议在 Excel 中预设为文本格式,避免 01→1、1e-8→浮点等类型推断。 - 同一 xlsx 用 --sheet 跑不同 sheet,输出名各异、互不覆盖。 - dOut 从 ACLNN backward 排除名移除(代码 + 文档一致)。 ## 测试 - 4 通路 --validate 全过(kernel 4 / geir 2 / aclnn 2 / e2e 4 用例均 valid)。 - kernel 端到端 ttk kernel -i examples/case_store/kernel/add.xlsx --sheet T2:编译 SUCC、精度 PASS、4/4 PASS。 ## 文档更新 - docs/Task_Execution.md:通用参数表新增 --sheet,--input 说明改 csv/xlsx。 - docs/Test_Case_Generation.md:新增「输入文件格式(CSV / Excel)」小节。 - docs/Operator_Test_Guides/*_Test_Guide.md:各通路「常用场景示例」补 xlsx 多 sheet 命令。 - docs/Operator_Test_Guides/*_Case_Writing.md:各通路「参考用例」表补每个 csv 的验证特性与关键列。 - AGENTS.md / examples/case_store/README.md:xlsx 说明。 ## 类型标签 - [x] 新特性 - [ ] Bug修复 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他 See merge request: cann/ops-test-kit!185 | 12 天前 | |
TTK init repo | 3 个月前 |
🚀 TTK —— 算子测试工具
TTK(ops Test Tool Kit)是CANN算子库提供的全链路、自动化、批量化算子测试框架,帮助开发者快速完成算子批量功能验证、性能评估以及Golden值比对,提升算子开发质量和效率。
文档中出现的硬件厂商名仅作示例,TTK 通过配置驱动支持任意符合接口的硬件加速器。
- 全栈测试通路:Kernel(AscendC)/ GEIR(GE图)/ ACLNN(aclnn* C API)/ E2E(torch/torch_npu),覆盖算子到框架各层
- 多设备 + 仿真:真实设备支持 NPU / MLU / CPU;仿真模式基于 CPU 模拟 NPU 行为,无需真实硬件即可开发调试
- 多卡并行:多 NPU 设备并行测试
- 多种精度对比:混合容差(生态算子开源精度标准,默认)、统计相对误差、余弦相似度、二进制精确、重量化、三方交叉校验
- 可扩展插件:自定义 Golden / 输入生成,Kernel 与 ACLNN/E2E 独立命名空间
🏗️ 架构层级与测试覆盖
┌──────────────────────────────────────────────────┐
│ 应用框架层 ✅ Torch · TensorFlow · ... │ ← E2E(端到端,覆盖全链路)
├──────────────────────────────────────────────────┤
│ 引擎层 ✅ GEIR · GE · ✅ ACLNN │ ← GEIR(GE图编译+执行)/ ACLNN(引擎 API)
├──────────────────────────────────────────────────┤
│ 算子层 ✅ AiCore · AiCpu │ ← Kernel(算子内核,覆盖编译+执行)
└──────────────────────────────────────────────────┘
🛠️ 环境准备
- 按照昇腾社区安装CANN环境:官方链接
- Python版本建议选择3.8及以上
git clone https://gitcode.com/cann/ops-test-kit.git
cd ops-test-kit
pip install -r requirements.txt
🚀 快速开始
通过 CSV 文件定义测试用例(字段说明详见用例生成),一条命令批量运行:
# 查看设备信息
python3 -m ttk info
# Kernel:编译 + 执行 + 精度比对
python3 -m ttk kernel -i examples/case_store/kernel/add.csv
# GEIR:GE 图编译 + 执行
python3 -m ttk geir -i examples/case_store/kernel/add.csv
# ACLNN:aclnn* C API
python3 -m ttk aclnn -i examples/case_store/aclnn/aclnn_cat.csv
# E2E:框架端到端(--cpu 强制 CPU 后端)
python3 -m ttk e2e -i examples/case_store/e2e/torch_add.csv
运行后终端输出每个用例的精度状态和整体通过率,加 -o 可输出结果 CSV。参数帮助执行 python3 -m ttk kernel --help。
📚 使用文档
通用
测试通路
四条测试通路对应昇腾技术栈不同层级,详见各通路指南。
| 通路 | 覆盖层级 | 指南 |
|---|---|---|
| Kernel | 算子层(AiCore/AiCpu),覆盖编译+执行 | Kernel算子测试指南 |
| GEIR | 引擎层,GE 图编译+执行 | GEIR算子测试指南 |
| ACLNN | 引擎层,aclnn* C API | ACLNN算子测试指南 |
| E2E | 应用框架层(torch/torch_npu),端到端 | E2E算子测试指南 |
高阶使用场景
离线数据准备、XPU 三方交叉校验、确定性计算、Dump 调试、NPUSim 仿真等多参数组合场景,详见任务执行 - 高阶使用场景。
工具适配
- mssanitizer 适配方法 — 内存/竞争/同步检测
- msopprof 适配方法 — 算子性能 Profiling
- msdebug 适配方法 — 算子源码级调试
FAQ
- FAQ一本通 — 常见问题与自定位
🤖 AI 辅助
TTK 配备 Agent Skills,为 CLI 类 AI 编程助手(Claude Code、OpenCode 等)提供 TTK 使用指导。详见 AGENTS.md。
注意:执行
python3 -m ttk命令需要在 ops-test-kit 目录下运行。