tune-swimlane

Analyzes PyPTO operator swimlane traces to guide Stitch, TileShape, merge, and scheduling performance tuning.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? PyPTO operators on Ascend NPU often underperform after initial code-level optimization, and developers lack a systematic way to interpret swimlane profiling data (merged_swimlane.json, bubble analysis) and translate it into concrete tuning actions such as Stitch configuration, TileShape adjustment, graph merging, and scheduling strategy selection. ## Core Features & Use Cases - Swimlane Analysis Scripts: analyze_swimlane.py, analyze_core_usage.py, analyze_aiv_dep_chains.py, and leafhash_to_code.py parse trace data to report per-leafHash timing, core utilization, AIV dependency chains, and leafHash-to-source-line mappings. - Four Tuning Dimensions: Stitch tuning (stitch_function_max_num), TileShape deep tuning (compute-bound vs memory-bound decision tree, split-K), merge tuning (cube_l1_reuse_setting, cube_nbuffer_setting, vec_nbuffer_setting, sg_set_scope), and scheduling strategy tuning (device_sched_mode). - Gated Checklist Workflow: Enforces core-usage analysis before merge tuning, load-balancing analysis before graph merging, and fresh data collection after every code change. - Use Case: After frontend tuning of a fused attention operator, run the analysis scripts on freshly collected swimlane data, identify a NOT FULL AIC subgraph, reduce its TileShape to fill all 24 AIC cores, then apply vec_nbuffer_setting with the hashOrder key reported by the Merge Tuning Guide. ## Quick Start Ask the assistant to perform deep performance tuning on your PyPTO operator using the latest swimlane data collected with runtime_debug_mode enabled.

Frequently Asked Questions about tune-swimlane

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

FAQPage Schema
How do I analyze PyPTO swimlane data for performance tuning?

Run analyze_swimlane.py on the output directory containing merged_swimlane.json, passing a manually computed --outer-loops value. The script reports per-leafHash timing statistics, hashOrder merge keys, subGraphCount, and a Merge Tuning Guide with suggested granularities.

What is Stitch tuning in PyPTO and how do I configure it?

Stitch tuning controls how many root functions are dispatched together via the stitch_function_max_num runtime option in pypto.frontend.jit. Larger values compact the swimlane and reduce scheduling overhead, but excessively large values increase scheduling latency and workspace usage.

When should I use cube_l1_reuse_setting versus cube_nbuffer_setting?

cube_l1_reuse_setting merges subgraphs that repeatedly load the same L1 data, while cube_nbuffer_setting merges structurally identical AIC subgraphs to cut scheduling overhead. Tune L1 reuse first, avoid setting both too large, and only apply them after cores are fully utilized.

Why does graph merging cause performance regression in PyPTO?

Merging before cores are fully utilized reduces parallelism by packing few tasks onto even fewer cores. Overly large merge granularity can also overflow L1/UB memory. Always run core-usage analysis first and validate each change with freshly collected swimlane data.

How do I choose TileShape for Matmul in PyPTO?

Follow the decision tree based on M, N, K sizes: large shapes target compute-bound with tiles like [128,128],[64,256],[256,256]; small M or N favors keeping that dimension unsplit with A resident in L1; small M and N with huge K uses split-K via enable_split_k or manual K loops.

Can I reuse old swimlane data after modifying PyPTO operator code?

No. The skill mandates recollecting swimlane data with runtime_debug_mode enabled after every code change, because performance characteristics shift with each modification and stale data leads to incorrect tuning decisions.