This Skill is used to perform reproducible latency tests for a single operator in an Ascend NPU environment.
Execution policy
- 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).
- If the user does not provide the server IP, account, or password, stop immediately and do not guess the environment.
- 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.5common paths:/usr/local/Ascend/ascend-toolkit/latestCANN >= 8.5common paths:/usr/local/Ascend/cann/latest
- If the user filled in a conda environment name, prioritize the conda approach according to conda .
- If the user filled in a docker container name, prioritize checking that container according to docker .
- If
conda 环境名anddocker 容器名are both无, first check candidate conda environments; if the user does not accept conda, then check candidate container environments. - 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.
demo 方案only accepts two values:我生成or我提供. If the user chooses我提供, prioritize the demo or operator supplementary information provided by the user.- The
assets/config_template.yaml、scripts/bench_repeat_interleave.pyandscripts/bench_op.pyin the current repository whererepeat_interleaverelated content is only an example and does not mean that this Skill only supports testingrepeat_interleave。 - 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.
- When actually executing the benchmark, prioritize reusing the target environment's existing
torchandtorch_npu; do not reinstall them. - If the current environment lacks the target CANN,
torch_npuis 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. - Do not automatically install CANN, do not automatically repair conda or the container, and do not enable any fallback installation process.
- If files must be created during testing, put them all in an isolated test directory and delete them after finishing.
- 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 shapedemo 代码性能数据
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: