SuperAPI AI Directory

npu-op-benchmark

Testing & quality

View repository

Updated 10-15 17:19

About this skill

NPU Operator Benchmark

This Skill is used to perform reproducible latency tests for a single operator in an Ascend NPU environment.

Execution policy

  1. When first collecting information from the user, explain in natural language what is needed; do not just throw a fixed template at them. The recommended wording is: I need server information (IP, account, password); version requirements (CANN and torch; you can omit them if not applicable); test environment (conda environment name, docker container name, CANN directory; you can omit them if not applicable); and the demo approach (I generate / I provide).
  2. If the user does not provide the server IP, account, or password, stop immediately and do not guess the environment.
  3. For the CANN check, prefer the CANN directory provided by the user; if it is not provided or is filled in as 无 , then search common paths according to cann and determine the current version layout:
    • CANN < 8.5 common paths:/usr/local/Ascend/ascend-toolkit/latest
    • CANN >= 8.5 common paths:/usr/local/Ascend/cann/latest
  4. If the user filled in a conda environment name, prioritize the conda approach according to conda .
  5. If the user filled in a docker container name, prioritize checking that container according to docker .
  6. If conda 环境名 and docker 容器名 are both 无, first check candidate conda environments; if the user does not accept conda, then check candidate container environments.
  7. Whether using conda or a container, you must first return the environment name, torch/torch_npu version, and CANN version to the user for confirmation before executing the benchmark.
  8. demo 方案 only accepts two values:我生成 or 我提供. If the user chooses 我提供, prioritize the demo or operator supplementary information provided by the user.
  9. The assets/config_template.yaml、scripts/bench_repeat_interleave.py and scripts/bench_op.py in the current repository where repeat_interleave related content is only an example and does not mean that this Skill only supports testing repeat_interleave。
  10. If the user does not provide additional use cases, the agent may design a demo on its own according to the performance testing principles of the target operator; after the design is completed, return it to the user first.
  11. When actually executing the benchmark, prioritize reusing the target environment's existing torch and torch_npu; do not reinstall them.
  12. If the current environment lacks the target CANN,torch_npu is unavailable, or the operator execution reports an environment error, stop immediately; do not fix the environment; directly ask the user to provide a new usable environment.
  13. Do not automatically install CANN, do not automatically repair conda or the container, and do not enable any fallback installation process.
  14. If files must be created during testing, put them all in an isolated test directory and delete them after finishing.
  15. After the benchmark ends, directly return the complete result information; do not additionally generate a report file.

Return results

The returned content must include at least:

  • CANN 版本
  • torch 版本
  • torch_npu 版本
  • 测试环境
  • 环境名称(conda 名或容器名)
  • 测试方法
  • 目标算子
  • tensor shape
  • demo 代码
  • 性能数据

If the environment does not meet requirements or the operator execution fails, return uniformly according to the template below:

环境不满足,已停止当前测试。请提供新的可用环境。

torch 版本:
<torch_version 或 unknown>

torch_npu 版本:
<torch_npu_version 或 unknown>

当前引用的 CANN 版本:
<根据用户提供目录或常见路径判断出的版本;若无法确定则写 unknown,并附 `latest` 布局和候选目录信息>

demo.py 内容:
<实际执行的 demo 代码;优先使用使用者提供的 demo,否则使用 AI 生成的 demo>

input/output tensor shape:
<实际测试使用的输入 shape,以及必要时的输出 shape>

执行失败报错:
<原始错误摘要或关键报错>

Entry

  • CANN detection:scripts/cann_detect.sh
  • Docker container check:scripts/find_docker_cann.sh
  • General operator benchmark:scripts/bench_op.py
  • repeat_interleave example wrapper script:scripts/bench_repeat_interleave.py

For more details see: