ascendc-performance-best-practices

Provides performance optimization guides and template code for Ascend C operator families.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Ascend C kernel developers often lack a centralized, queryable knowledge base of proven performance optimization techniques for NPU operators, forcing them to rediscover tiling, pipelining, and memory-movement strategies from scratch for each operator family. ## Core Features & Use Cases - Operator-family knowledge base: Organizes optimization guides by operator family (MatMul, MC2, Reduction, Elementwise, Broadcast, Conversion, Sort, Scalar, SIMT) targeting DAV_3510 and DAV_2201 architectures. - Reusable template code: Ships copy-ready Ascend C template files (.h/.cpp/.template) such as Softmax reduction templates and broadcast kernel samples, with a defined lookup chain from SKILL.md to family guides to template code. - Cross-cutting optimizations: Documents common techniques including tail-block handling, DataCopy optimization, UB/TBuf resident reuse, and small-shape core shrinkage. - Use Case: When implementing a fused BatchMatmulMaxSum operator, query the MatMul family guide for constant folding and full-load strategies, then consult the Reduction family templates for the MaxSim and sum stages. ## Quick Start Ask the assistant to load this skill and show the performance optimization guide for a specific operator family such as matmul or reduce on DAV_3510.

Frequently Asked Questions about ascendc-performance-best-practices

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

FAQPage Schema
How do I optimize an Ascend C MatMul operator on DAV_3510?

Query the MatMul family guide, which covers optimizations like pingpong, SWAT, StreamK, full-load, scale coalescing, MTE2 preload, and constant folding. Variants such as matmul_mxfp4, batch_matmul, and matmul_a16w16 all map to the same matmul family documentation.

How do I find and reuse Softmax template code for Ascend C?

Follow the lookup chain from SKILL.md to references/reduce/guide.md, then select a template in the templates directory based on your R dimension versus UB capacity. Convert .template files to .h per usage_guide.md, copy them into your op_kernel directory, and never rewrite the MicroAPI code from scratch.

What optimization applies when data size is not divisible by the tile size?

Use the common tail-block handling guide at references/common/tail_block_design.md. It covers norm/tail kernel separation, GatherMask vectorized tail processing, and 32B/64B alignment with DataCopyPad to avoid out-of-bounds access and load imbalance.

Does this skill cover fused operators like AddRelu?

Yes. Fused operators are decomposed into base operator families, and each family's optimization guide is consulted separately. For example, AddRelu splits into Broadcast (Add) plus Elementwise (Relu), then the practices are adapted to the fusion scenario.

Why does my Broadcast operator produce nan or run slowly on Ascend NPU?

Broadcast performance depends on selecting the right implementation among OneDim fast path, NDDMA, DataCopyPad, and UB Broadcast. Choosing UB Broadcast when no expandable dimension exists in the tile causes empty broadcast and nan; the family decision tree explains the selection criteria.

What are the limitations of the ascendc-performance-best-practices knowledge base?

Convolution, NN, and Random operator families are planned but not yet covered, and queries for unlisted families return a not-yet-collected response. Most guides target DAV_3510, and template code requires minimal adaptation such as namespace aliases to compile against your CANN version.