pypto-op-perf-tune

Analyzes and iteratively tunes PyPTO operator performance on Ascend NPU hardware.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill pypto-op-perf-tune-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pypto-op-perf-tune
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/pypto-op-perf-tune
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill pypto-op-perf-tune-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch_npu, pypto, and includes scripts (resource) and references (resource) components.

What problem does it solve? PyPTO operators that pass correctness checks often still run far below hardware capability, and manual performance tuning on Ascend NPU requires expertise in swimlane analysis, TileShape configuration, graph merging, and scheduling. This Skill provides a structured, orchestrator-driven workflow that turns ad-hoc trial-and-error tuning into a controlled, measurable process with enforced accuracy gates. ## Core Features & Use Cases - Orchestrated tuning state machine: A tune-orchestrator enforces the fixed pipeline of environment checks, precision validation, performance data collection, analysis, phased tuning (frontend, swimlane, incore), and final report generation. - Phased optimization guidance: Dedicated sub-skills cover out-of-box code-level tuning (loop structure, TileShape, reshape), deep swimlane-based tuning (core usage, load balancing, graph merging, Stitch), and in-core tuning (L2 cache policy, instruction-level fixes, special shapes). - Automated performance analysis: The perf-analyzer component extracts core utilization, bubble rate, and load balance metrics from bubble_analysis.log and swimlane JSON files, then produces a rated performance report. - Use Case: Given a verified Add operator running at 27000 us with a 5x speedup target, the Skill validates precision on NPU, collects swimlane data, iterates single-parameter optimizations with per-round accuracy re-verification, and delivers a final tuning report with adopted and failed optimizations. ## Quick Start Ask the assistant to analyze and tune the performance of your implemented PyPTO operator, stating the operator directory and a concrete target such as a speedup multiple or maximum execution time.

Frequently Asked Questions about pypto-op-perf-tune

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I tune PyPTO operator performance on Ascend NPU?

Load the tune-orchestrator, which drives a fixed pipeline: environment checks, precision validation, performance data collection with debug_options, swimlane analysis, then phased tuning across frontend, swimlane, and incore stages. Each iteration changes one parameter and re-verifies accuracy on hardware.

Can I start performance tuning before precision validation passes?

No. Precision validation is a hard gate: tuning is forbidden without a passing accuracy record. If initial validation fails, you may retry on a different NPU card, but repeated failures stop the process for user confirmation rather than attempting fixes.

What environment is required for PyPTO operator tuning?

A working NPU environment is mandatory: npu-smi must report devices, torch_npu must be importable with available devices, TILE_FWK_DEVICE_ID must point to a free card, PTO-ISA compatibility must pass, and PyPTO must be compiled and installed.

Why must each tuning iteration change only one parameter?

Single-parameter changes isolate the effect of each optimization so performance gains or regressions can be attributed correctly. Batching changes like TileShape, unroll, and stitch together makes results uninterpretable and complicates rollback when precision fails.

What happens when a tuning phase stops improving performance?

Each phase has exit thresholds: frontend stops after 5 consecutive non-improving rounds, swimlane after 8, and incore after 5 or when theoretical limits are reached. The orchestrator then generates a handoff summary and moves to the next phase or final reporting.

What performance metrics does the analysis report include?

The report extracts core utilization, bubble rate, load balance, and per-core AicoreTime from bubble_analysis.log and merged_swimlane.json. It assigns star ratings per metric and identifies bottlenecks with prioritized optimization suggestions.