| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
Add GLM5 profiling op replay tools Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !215 merge pr/glm5-op-replay-tools into develop Add GLM5 profiling op replay tools Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [x] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [x] Other(其他) ## 🔍 Motivation / 变更动机 This PR adds missing microbench replay tools for GLM5 profiling database backfill. Generated profiling CSV rows are only useful after they can be replayed and filled by tools/perf_data_collection/start_microbench.py. Several GLM5-related operators did not have replay scripts, especially grouped MoE, LightningIndexer, TransposeBatchMatMul, SparseFlashAttention, and MoE token routing operators. The goal of this PR is to make these operators replayable so missing profiling shapes can be collected on the target NPU server environment. ------ ## 📝 Modification / 修改内容 This PR modifies only profiling data collection tools under: - tools/perf_data_collection/op_replay/ Added replay scripts: - BatchMatMulV2_run.py - GroupedMatmul_run.py - GroupedMatmulSwigluQuant_run.py - LightningIndexer_run.py - MoeTokenPermute_run.py - MoeTokenUnpermute_run.py - ScatterNdUpdate_run.py - SparseFlashAttention_run.py - TransposeBatchMatMul_run.py Updated common replay utilities: - common.py Main changes: - Add replay entrypoints for missing GLM5 profiling operators. - Preserve CSV input slot layout for grouped operators. - Build valid grouped matmul group_list, scale, per-token scale, and output dtype metadata. - Handle batched/restored FRACTAL_NZ shapes. - Restore WeightNZ layout for GroupedMatmulSwigluQuant. - Add shape validation for TransposeBatchMatMul replay. ------ ## 📐 Associated Test Results / 关联测试结果 These tools target NPU microbench replay and require the server environment with torch_npu/CANN support. Validated during GLM5 profiling database backfill workflow: text GroupedMatmul replay issues were fixed: - Tensor vs List[Tensor] weight argument mismatch. - Invalid group_list. - Quant scale dimension/dtype mismatch. - FRACTAL_NZ shape restoration. GroupedMatmulSwigluQuant replay issues were fixed: - Unsupported batched FRACTAL_NZ shape. - WeightNZ logical shape mismatch. Subsequent microbench run completed with: - Success: 7 - Failed: 0 - Missing shapes: 0 ------ ## 🌟 Use cases (Optional) / 使用案例(可选) Example usage: bash python tools/perf_data_collection/start_microbench.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated Single-op replay example: bash python tools/perf_data_collection/op_replay/GroupedMatmul_run.py \ --database-path tensor_cast/performance_model/profiling_database/data/ATLAS_800_A3_752T_128G_DIE/vllm_ascend/vllm0.18.0_torch2.9.0_cann8.5_shape_generated \ --repeat-count 1 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!215 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
完善 GLM5 shape grid 生成与 microbench 回填支持 Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !252 merge codex/debug-shape-grid-generation into develop 完善 GLM5 shape grid 生成与 microbench 回填支持 Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: ## Summary - improve GLM5 shape grid generation and EP32 DFC replay coverage - normalize shape matching and dedupe behavior - extend microbench update/replay tooling and related tests ## Validation - Not run locally because pytest is not installed for the available Python interpreter. See merge request: Ascend/msmodeling!252 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
feat: profiling data collection toolchain Co-authored-by: Horacehxw<horacehxw@gmail.com> # message auto-generated for no-merge-commit merge: !124 merge pr/perf-db-b into develop feat: profiling data collection toolchain Created-by: Horacehxw Commit-by: Horacehxw Merged-by: ascend-robot Description: **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 实测算子性能估算系统(见 [PR-A: feat: profiling-based empirical performance model with CSV data source](https://gitcode.com/Ascend/msmodeling/pull/123) )依赖 NPU Profiling 数据(per-kernel CSV + HCCL 通信基准)。这些数据需要从 NPU 设备上采集、解析、验证后才能使用。 本 PR 提供完整的**离线数据采集工具链**,覆盖从 Profiling 原始数据解析到微基准测试、shape 变异、通信基准、M6 E2E 精度计算的全流程。 > 📌 本 PR 与 [PR-A](https://gitcode.com/Ascend/msmodeling/pull/123)(核心功能)**无代码依赖**——tools/ 不 import tensor_cast,可独立 review 和合入。 ------ ## 📝 Modification / 修改内容 所有新增文件位于 tools/perf_data_collection/ 和 tests/tools/。 ### 1. 数据解析与转换 | 工具 | 行数 | 说明 | |------|:----:|------| | parse_kernel_details.py | 698 | 解析 NPU kernel_details.csv → 按 kernel type 拆分为独立 CSV(MatMulV2.csv、SwiGlu.csv 等),支持 FRACTAL_NZ format 转换、shape 归一化 | | build_comm_csv.py | — | HCCL benchmark 结果 → 通信 CSV 构建 | | fia_common.py + fill_fia_runtime_metadata.py | 1,544 | FusedInferAttentionScore 运行时元数据推断与回填 | ### 2. 微基准测试 | 工具 | 行数 | 说明 | |------|:----:|------| | start_microbench.py | 771 | 自动化微基准运行入口:读取 op_mapping.yaml → 按 kernel type 选择 replay 脚本 → msprof 采集 → 解析结果回写 CSV | | op_replay/*.py (25+ scripts) | 5,258 | 每个 NPU kernel 一个回放脚本(MatMulV2、SwiGlu、FusedInferAttentionScore、QuantBatchMatmulV3、DispatchFFNCombine 等),使用 torch_npu API 构造输入并调用 | | generate_shape_grid.py | 2,075 | 从现有 CSV 数据出发,通过 shape mutation(维度缩放、block padding 变体、量化变体等)生成更多 shape 组合,扩大覆盖面 | ### 3. 通信基准 | 工具 | 行数 | 说明 | |------|:----:|------| | generate_comm_microbench.py | — | 生成 HCCL 通信基准测试脚本(allReduce、allGather、allToAll、reduceScatter) | | validate_comm_alignment.py | 345 | HCCL 微基准 CSV vs CommAnalyticModel 对齐验证 | | run_comm_bench.sh | 204 | HCCL benchmark 运行脚本 | ### 4. 精度评估 | 工具 | 行数 | 说明 | |------|:----:|------| | compute_m6.py | — | M6(E2E Ratio)离线计算:TC 预测总时间 / 真实 per-forward 时间,使用 ArgMaxV2 作为 anchor kernel 切分 forward passes | ------ ## 📐 Associated Test Results / 关联测试结果 $ pytest tests/tools/ -q --ignore=tests/tools/test_fia_parser_backfill.py 63 passed, 2 failed in 0.11s 2 个失败为预期行为(profile_and_update_db.py 尚未实现,测试先于代码)。 ### Import 隔离验证 python # 确认 tools/ 不依赖 tensor_cast import ast, sys, pathlib for f in pathlib.Path('tools/perf_data_collection').rglob('*.py'): tree = ast.parse(f.read_text()) for node in ast.walk(tree): if isinstance(node, (ast.Import, ast.ImportFrom)): mod = getattr(node, 'module', '') or '' if 'tensor_cast' in mod: print(f'ERROR: {f}:{node.lineno}') sys.exit(1) # → OK: no tensor_cast imports in tools/ ------ ## 🌟 Use cases (Optional) / 使用案例(可选) bash # 1. 从 NPU profiling 原始数据生成 per-kernel CSV python tools/perf_data_collection/parse_kernel_details.py \ --input <kernel_details.csv> --output-dir <data_dir> # 2. 运行微基准测试(需要 NPU 设备) python tools/perf_data_collection/start_microbench.py \ --data-dir <data_dir> --device ATLAS_800_A3_752T_128G_DIE # 3. 生成 shape 变异矩阵扩大覆盖 python tools/perf_data_collection/generate_shape_grid.py \ --csv-dir <data_dir> --output-dir <output_dir> # 4. 计算 M6 E2E 精度 python tools/perf_data_collection/compute_m6.py \ --tc-report results/metrics.json \ --profiler-output <profiling_trace_dir> # 5. HCCL 通信基准 bash tools/perf_data_collection/run_comm_bench.sh ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] [Linting tools](https://gitcode.com/Ascend/msmodeling/blob/develop/tensor_cast/README.md#coding-style) are used to fix the potential lint issues. - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. - [x] Please ensure code files contain no Chinese comments. See merge request: Ascend/msmodeling!124 | 1 个月前 | |
【FEAT】MindStudio CLI 统一 stderr Logo Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !307 merge feat-logo into develop 【FEAT】MindStudio CLI 统一 stderr Logo Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 MindStudio Modeling 各 Python CLI 启动时缺少统一品牌标识,用户在仿真、吞吐寻优、适配与 profiling 工具间切换时难以从终端首屏确认产品归属。本 PR 在 parse_args 成功后向 stderr 输出固定四行 MindStudio Logo,并支持 TTY/TERM 降级与 Windows colorama 控制台初始化。 --- ## 修改内容 - 新增共享模块 cli/logo.py:render_logo / print_logo,65 列块 + 终端居中 + ANSI/纯文本降级 - 在 11 个 Python 入口(cli/inference/*、serving_cast/main.py、tools/perf_data_collection 驱动脚本)于 parse_args 后调用 print_logo();--help 路径不输出 Logo - 依赖: - **运行时** colorama>=0.4.6 — 写入 [project] dependencies 与 requirements.txt,Windows 上调用 just_fix_windows_console() 启用控制台 VT/ANSI 输出 - **CI 静态检查** types-colorama>=0.4.15 — 写入 [dependency-groups] ci,见下方说明 - 详设文档:docs/design/mindstudio-brand-logo-design.md(本仓仅 Python 范围) - 测试:tests/regression/cli/test_logo.py(14 条模块 UT)+ tests/regression/cli/test_logo_cli_hooks.py(help 抑制与入口 hook 回归,in-process run_module_main) ### 为何需要 types-colorama(CI 组,非运行时) cli/logo.py 在 Windows 路径下会调用 colorama.just_fix_windows_console()。colorama 包本身未提供完整的 inline 类型注解,mypy / 仓库 type_check 在无 stub 时会报 *Cannot find implementation or library stub for module named "colorama"*,或将其视为 untyped 调用。 types-colorama 是社区维护的 **PEP 561 stub 包**(.pyi),仅用于开发态与 CI 的类型检查,**不会**随默认 uv sync 进入用户仿真运行时环境(位于 dependency-groups.ci,与 pytest-cov 等工具同属 CI 组)。 加入该依赖的目的: 1. 让 uv sync --group ci + mypy 能正确解析 colorama API,满足本 PR 静态检查门禁,**无需**在业务代码中使用 # type: ignore 绕过规范 2. 与项目现有做法一致:第三方库缺类型时,在 ci 组补 types-* stub,而非放宽 mypy 配置 若仅安装运行时依赖(uv sync / pip install -r requirements.txt),**不需要**也**不会**安装 types-colorama;Logo 功能仅依赖运行时 colorama。 --- ## 自验证 ### Logo 四行块渲染(纯文本 / 80 列居中) 目的:确认固定四行布局、品牌行与 Slogan 居中、无前置空行。 步骤: 1. 在仓库根目录执行: bash uv run python -c "from cli.logo import render_logo; print(render_logo(color=False, terminal_cols=80))" 结果:  ### Logo 模块 + CLI hook 回归测试 目的:满足 CI Gate 对新增 print_logo 路径的覆盖;确认 --help 不泄漏 Logo,正常 parse_args 后 stderr 含品牌块。 步骤: 1. 在仓库根目录执行: bash uv run pytest tests/regression/cli/test_logo.py tests/regression/cli/test_logo_cli_hooks.py -v --tb=no 结果:  ### --help 不输出 Logo 目的:确认 argparse 在 print_logo 之前退出,help 路径保持干净。 步骤: 1. 执行: bash uv run python -m cli.inference.text_generate --help 2>&1 | head -5 结果:  ### 端到端  See merge request: Ascend/msmodeling!307 | 27 天前 | |
完善 GLM5 shape grid 生成与 microbench 回填支持 Co-authored-by: Secluded_Ocean<tangchuxiao0709@qq.com> # message auto-generated for no-merge-commit merge: !252 merge codex/debug-shape-grid-generation into develop 完善 GLM5 shape grid 生成与 microbench 回填支持 Created-by: Secluded_Ocean Commit-by: Secluded_Ocean Merged-by: ascend-robot Description: ## Summary - improve GLM5 shape grid generation and EP32 DFC replay coverage - normalize shape matching and dedupe behavior - extend microbench update/replay tooling and related tests ## Validation - Not run locally because pytest is not installed for the available Python interpreter. See merge request: Ascend/msmodeling!252 | 1 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 27 天前 | ||
| 1 个月前 |