ascend-npu-profile-operator
Get and analyze Ascend NPU operator performance data. Use for profiling Ascend operators, identifying hot operators and timing bottlenecks, summarizing performance evidence, comparing profiling results across runs, or inspecting profiler artifacts such as msprof outputs, op_statistic/op_summary CSV files, and Ascend profiler .bin data.
- License 许可
- Apache-2.0
- 所属仓库
- Piagari/helix
- 最近更新
- 2026-07-16
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- ascend-npu-profile-operator
- description
- Get and analyze Ascend NPU operator performance data. Use for profiling Ascend operators, identifying hot operators and timing bottlenecks, summarizing performance evidence, comparing profiling results across runs, or inspecting profiler artifacts such as msprof outputs, op_statistic/op_summary CSV files, and Ascend profiler .bin data.
02 资源文件 8
- 参考文档references/binary-format-spec.md9.0 KB
- 参考文档references/profiler-csv-spec.md1.4 KB
- 脚本scripts/models.py6.5 KB
- 脚本scripts/msprof_parser.py8.0 KB
- 脚本scripts/parse_bin.py26.2 KB
- 脚本scripts/parser_base.py5.2 KB
- 脚本scripts/reporter.py26.4 KB
- 脚本scripts/torch_npu_profiler_parser.py8.5 KB
03 SKILL.md 正文
Ascend NPU Operator Profiler
Profile Ascend NPU operators and summarize the resulting timing data.
Default workflow
Profiling + summary (profile-bench)
-
Profile benchmark harnesses through the
ascend-npu-run-evalskill'sprofile-benchhelper.- For the exact wrapper invocation, read that skill's
references/profile-bench.md. - The standard argument shape is:
profile-bench --bench-file bench_matmul.py --operator-file matmul.py - For the exact wrapper invocation, read that skill's
-
The helper runs the profiler, copies back the generated local
PROF_*directory, and prints a summary inline. -
Review the inline summary in the conversation. Call out:
- which operator was analyzed
- whether that operator was explicit or inferred
- total, average, min, and max time
- runtime ratio and top hotspots
Re-reporting without re-profiling (profile-report)
When the profiling data already exists (e.g. from a previous profile-bench run), use profile-report to generate a new summary without re-running the benchmark:
profile-report --profile-dir PROF_000001_.../ --target-op matmul_kernel
For round-analysis workflows that need structured signals, use JSON mode:
profile-report --profile-dir PROF_000001_.../ --target-op matmul_kernel --format json
This is useful when you want to:
- Inspect the same
PROF_*data with different--target-opvalues - Re-summarize historical profiling data
- Emit structured JSON for downstream workflows without re-profiling
Working rules
- Prefer the
ascend-npu-run-evalskill'sprofile-benchhelper for benchmark profiling, especially when the workflow is remote-aware. - profile one selected
--case-id <id>case for bothtorch-npu-profilerandmsprof; benchmark profiling must not receive--benchor--num-bench. - If the benchmark file declares exactly one case, the helper may auto-select it; otherwise provide
--case-id. - If the benchmark metadata says
# bench-mode: msprof, the selected case still requires resolvable# kernels:metadata in the benchmark header. - When the outer task is remote-aware, pass the same
--remoteand--remote-workdirsettings throughprofile-benchso profiling runs on the remote machine while the resultingPROF_*directory is copied back locally. - Keep direct
msprof <command>only as a local fallback when there is no generated benchmark harness or when the user explicitly wants a manual invocation. - Treat
op_summary_*.csvas potentially large. Do not dump it into the conversation or read it naively line-by-line into memory if a streaming pass is enough. - Prefer the bundled summary script over ad hoc shell parsing so the report stays consistent.
- Prefer the bundled summary script in JSON mode when the downstream task is
ascend-npu-analyze-round-performanceor any profiler-first layered analysis workflow. - If the user names the operator, pass it through
--target-op. - If the user does not name the operator, let the script infer the hottest operator from
op_statisticand state that this is an inference. - Always show the final Markdown summary in the conversation instead of only mentioning generated files.
Bench mode contract
-
torch-npu-profiler- Use:
profile-bench --bench-file bench_<operator>.py --operator-file <operator>.py --case-id <id> - Runtime command shape inside the helper:
python3 bench_runtime.py profile-one --bench-file bench_<operator>.py --operator-file <operator>.py --case-id <id> - Do not pass
--benchor--num-bench. - The helper profiles one selected
--case-id <id>case withtorch_npu.profiler.
- Use:
-
msprof- Use:
profile-bench --bench-file bench_<operator>.py --operator-file <operator>.py --case-id <id> - Runtime command shape inside the helper:
msprof python3 bench_runtime.py run-one --bench-file bench_<operator>.py --operator-file <operator>.py --case-id <id> - The helper profiles the requested
--case-id <id>case and may auto-select only when the benchmark declares exactly one case. - This mode requires benchmark metadata with
# kernels: <resolved_kernel_names>.
- Use:
Validation checks
- Accept any of these input shapes for CSV summarization: a
PROF_*directory, amindstudio_profiler_output/directory, or a parent directory that contains one of them. - Before summarizing CSV output, confirm
mindstudio_profiler_output/exists and contains at least oneop_statistic_*.csv. - When
op_summary_*.csvexists, use it as a cross-check for the target operator but keep the main summary anchored onop_statistic. - Before running binary parsing, confirm the
.binfile exists and containsZZ{markers.
Failure handling
- If no profile directory can be resolved, re-run the profiling command and check the working directory.
- If
mindstudio_profiler_output/orop_statistic_*.csvis missing, stop and report that the profiler output is incomplete. - If the requested operator is not present in
op_statistic, list the available operators and ask the user to confirm the target. - If
op_summaryuses unrecognized columns, fall back toop_statisticand mention that theop_summaryaggregation was unavailable. - If
.binparsing finds noZZ{markers, treat the file as unsupported profiler data instead of guessing.
Bundled resources
-
scripts/reporter.pyUnified profile reporter used by theprofile-reportsubcommand. Loads profiles from either mode, runs classification (operator type, bound analysis), and renders Markdown or JSON output. -
scripts/models.pyTyped data model for parsed profile data (OperatorStats,KernelInvocation,PipelineStage,ParsedProfile). Shared byreporter.pyand all parsers. -
scripts/parser_base.pyShared parsing utilities: mode auto-detection,op_statisticCSV parser,api_statisticCSV parser. Used by both mode-specific parsers. -
scripts/msprof_parser.pyParsesPROF_*/mindstudio_profiler_output/artifacts:op_statistic,op_summary,task_time,api_statistic,msprofJSON. -
scripts/torch_npu_profiler_parser.pyParsesASCEND_PROFILER_OUTPUT/artifacts:op_statistic,kernel_details,operator_details,step_trace_time,api_statistic,trace_view. -
scripts/parse_bin.pyKeep this for raw profiler binary inspection when the user provides files such asvisualize_data.bin. It also owns the structured deep-signal parsing that the summary script can reuse. -
references/profiler-csv-spec.mdRead this when you need the expected CSV layout or column names forop_statisticandop_summary. -
references/binary-format-spec.mdRead this only when the user needs.binparsing details.
Examples
Profile a benchmark and summarize the hottest operator:
profile-bench --bench-file bench_matmul.py --operator-file matmul.py --case-id fp16_1024
Profile a benchmark and summarize a known operator:
profile-bench --bench-file bench_matmul.py --operator-file matmul.py --case-id fp16_1024 --target-op MatMul
Profile one msprof benchmark case on a remote machine and keep the remote workspace:
profile-bench --bench-file bench_matmul.py --operator-file opt_matmul.py --case-id fp16_2048 --remote user@host:2222 --remote-workdir /tmp/helix --keep-remote-workdir
Fallback manual profiling when you intentionally bypass the helper:
msprof python3 bench_runtime.py run-one --bench-file bench_matmul.py --operator-file matmul.py --case-id fp16_1024
Then re-summarize the copied-back profile through the ascend-npu-run-eval skill's profile-report helper, for example profile-report --profile-dir PROF_000001_.../ --target-op MatMul.
Inspect a raw profiler binary block:
python3 <skill-path>/scripts/parse_bin.py visualize_data.bin --block-id 0
04 同仓库更多 Skills
triton-npu-repair-guide
Heuristic fixes for Ascend Triton compile/JIT/kernel errors and numerical precision mismatches when editing or converting the operator. Does not replace ascend-npu-gen-test, ascend-npu-gen-bench, or harness specs.
triton-npu-optimize
Iteratively optimize a Triton Ascend NPU operator with correctness and performance gates. Use for operator optimization tasks that need repeated correctness validation, benchmark validation, multi-round experiment tracking, reusable optimization notes, and profiler-backed performance analysis when benchmark results need deeper explanation.
triton-npu-optimize-knowledge
Generic reference-only optimize knowledge for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts.
triton-npu-optimize-knowledge-v3
Generic reference-only optimize knowledge (v3 working copy) for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts; prefer this tree for ongoing knowledge updates.
triton-npu-optimize-knowledge
Generic reference-only optimize knowledge for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts.
triton-npu-convert-pytorch-operator
Convert one PyTorch operator into a Triton NPU-backed PyTorch operator, preserve the trailing input-helper block, and validate the converted output through standalone or differential testing.