AGENT SKILL

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

03 SKILL.md 正文

Ascend NPU Operator Profiler

Profile Ascend NPU operators and summarize the resulting timing data.

Default workflow

Profiling + summary (profile-bench)

  1. Profile benchmark harnesses through the ascend-npu-run-eval skill's profile-bench helper.

    • 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
    
  2. The helper runs the profiler, copies back the generated local PROF_* directory, and prints a summary inline.

  3. 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-op values
  • Re-summarize historical profiling data
  • Emit structured JSON for downstream workflows without re-profiling

Working rules

  • Prefer the ascend-npu-run-eval skill's profile-bench helper for benchmark profiling, especially when the workflow is remote-aware.
  • profile one selected --case-id <id> case for both torch-npu-profiler and msprof; benchmark profiling must not receive --bench or --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 --remote and --remote-workdir settings through profile-bench so profiling runs on the remote machine while the resulting PROF_* 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_*.csv as 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-performance or 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_statistic and 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 --bench or --num-bench.
    • The helper profiles one selected --case-id <id> case with torch_npu.profiler.
  • 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>.

Validation checks

  • Accept any of these input shapes for CSV summarization: a PROF_* directory, a mindstudio_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 one op_statistic_*.csv.
  • When op_summary_*.csv exists, use it as a cross-check for the target operator but keep the main summary anchored on op_statistic.
  • Before running binary parsing, confirm the .bin file exists and contains ZZ{ markers.

Failure handling

  • If no profile directory can be resolved, re-run the profiling command and check the working directory.
  • If mindstudio_profiler_output/ or op_statistic_*.csv is 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_summary uses unrecognized columns, fall back to op_statistic and mention that the op_summary aggregation was unavailable.
  • If .bin parsing finds no ZZ{ markers, treat the file as unsupported profiler data instead of guessing.

Bundled resources

  • scripts/reporter.py Unified profile reporter used by the profile-report subcommand. Loads profiles from either mode, runs classification (operator type, bound analysis), and renders Markdown or JSON output.

  • scripts/models.py Typed data model for parsed profile data (OperatorStats, KernelInvocation, PipelineStage, ParsedProfile). Shared by reporter.py and all parsers.

  • scripts/parser_base.py Shared parsing utilities: mode auto-detection, op_statistic CSV parser, api_statistic CSV parser. Used by both mode-specific parsers.

  • scripts/msprof_parser.py Parses PROF_*/mindstudio_profiler_output/ artifacts: op_statistic, op_summary, task_time, api_statistic, msprof JSON.

  • scripts/torch_npu_profiler_parser.py Parses ASCEND_PROFILER_OUTPUT/ artifacts: op_statistic, kernel_details, operator_details, step_trace_time, api_statistic, trace_view.

  • scripts/parse_bin.py Keep this for raw profiler binary inspection when the user provides files such as visualize_data.bin. It also owns the structured deep-signal parsing that the summary script can reuse.

  • references/profiler-csv-spec.md Read this when you need the expected CSV layout or column names for op_statistic and op_summary.

  • references/binary-format-spec.md Read this only when the user needs .bin parsing 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

Piagari
Piagari/helix

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.

★ 0
Piagari
Piagari/helix

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.

★ 0
Piagari
Piagari/helix

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.

★ 0
Piagari
Piagari/helix

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.

★ 0
Piagari
Piagari/helix

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.

★ 0
Piagari
Piagari/helix

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.

★ 0