attention Golden NPU Performance Report
2026/9/18 21:23:24 网站建设 项目流程

attention Golden NPU Performance Report

【免费下载链接】pypto-gymPyPTO-Gym 是基于 PyPTO 编程框架构建的算子与模型样例仓库项目地址: https://gitcode.com/cann/pypto-gym

  • Device: npu:0
  • Timestamp: 2026-06-09T10:00:00.000000+00:00
  • Iterations: 1

Performance Summary

caseInput ShapedtypeE2E (us)
perf_p0_small{q: (2, 8, 512, 64), k: (2, 8, 512, 64), v: (2, 8, 512, 64)}{q: torch.bfloat16, k: torch.bfloat16, v: torch.bfloat16}245.3us
perf_p0_large{q: (4, 16, 1024, 128), k: (4, 16, 1024, 128), v: (4, 16, 1024, 128)}{q: torch.bfloat16, k: torch.bfloat16, v: torch.bfloat16}1832.7us

Case: perf_p0_small

  • Input Shape: {q: (2, 8, 512, 64), k: (2, 8, 512, 64), v: (2, 8, 512, 64)}
  • dtype: {q: torch.bfloat16, k: torch.bfloat16, v: torch.bfloat16}
  • Profiling Data:prof/attention_golden/perf_p0_small/

E2E Performance

Total kernel duration: 245.3us (total - noise)

  • Cross-check (Σ per-op total): 245.3us

Op Performance

opcountmean_durationtotal
MatMulV2245.2us90.4us
SoftmaxV2132.1us32.1us
...

Notes

  • Data source:ASCEND_PROFILER_OUTPUT/kernel_details.csv
  • Noise ops (ReduceMax) filtered out
  • Each iteration: noise injection (480MB randn + max) → golden call → sync
### 14.7 故障排查 **⛔ 核心原则:profiling 必须成功。遇到崩溃时按以下流程排查,不得跳过或留空报告。** **Golden 函数崩溃(exit code 2)**——症状:`Golden function crashed on iteration 0. Random tensor values may violate semantic constraints...`

崩溃 → 读取错误信息中的异常类型 │ ├─ IndexError / out of range │ → 某个 tensor 用作索引,随机值越界 │ → 修复:该 tensor 必须用 randint(low=0, high=max_valid) 或手动构造 │ → 推荐:切换到 --factory 模式 │ ├─ RuntimeError (shape mismatch / size mismatch) │ → 多个 tensor 的 shape 之间有依赖关系,随机 shape 不匹配 │ → 修复:在 _make_inputs() 中从基础参数推导所有关联 shape │ → 推荐:切换到 --factory 模式 │ ├─ RuntimeError (CUDA/NPU error) │ → 可能是 dtype 不匹配或 device 不一致 │ → 修复:确保所有 tensor 使用相同 device,dtype 符合 golden 函数预期 │ ├─ ValueError / AssertionError(golden 内部校验失败) │ → 输入值不满足算子的前置条件 │ → 修复:阅读 golden 函数的前置检查逻辑,构造满足条件的输入 │ └─ 其他异常 → 阅读 golden 函数源码,理解输入约束 → 在 _make_inputs() 中构造合法输入 → 切换到 --factory 模式

**kernel_details.csv 未生成**——症状:`kernel_details.csv not found — report will have no data`

无 kernel_details.csv │ ├─ prof/ 目录下有多个 ASCEND_PROFILER_OUTPUT/ │ → _find_ascend_output 已自动选择最新的目录 │ → 检查最新目录中是否有 kernel_details.csv │ ├─ ASCEND_PROFILER_OUTPUT/ 中只有 operator_details.csv │ → CANN profiler 未生成设备侧 kernel 数据 │ → 可能原因:golden 函数在 CPU 上执行(无 NPU 硬件) │ → 检查:torch.npu.is_available() 和 device_count() │ └─ prof/ 目录为空 → profiler 未正常启动 → 检查 torch_npu 版本和 CANN 版本兼容性

**E2E 为 0 或异常小**——症状:报告生成但 E2E = 0.000us 或仅几个 us

E2E 异常 │ ├─ E2E = 0.000us │ → kernel_details.csv 中无有效数据 │ → 检查 CSV 的 Type 和 Duration(us) 列是否有值 │ → 可能所有 kernel 被归类为噪声(ReduceMax) │ ├─ E2E 异常小(远小于预期) │ → golden 函数可能走了短路分支(如 should_compress 始终为 False) │ → 修复:调整 _make_inputs() 中的参数,确保触发核心计算路径 │ → 例:start_pos_dy = [ratio - 2] 确保 (start_pos + i + 1) % ratio == 0 │ └─ E2E 双路径不匹配 → 检查是否有非 ReduceMax 的噪声 kernel → 在 profile_golden.py 的 NOISE_OPS 中添加额外噪声 op type

【免费下载链接】pypto-gymPyPTO-Gym 是基于 PyPTO 编程框架构建的算子与模型样例仓库项目地址: https://gitcode.com/cann/pypto-gym

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询