Optimizes Ascend NPU Triton operator performance: fixes UB overflow, improves Cube utilization, and designs tiling strategies. Use when profiling shows memory/compute/latency bottlenecks.
Ships in external-gitcode-ascend-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
性能比定义:Ratio = torch_npu 耗时 / Triton 耗时(耗时倒数)。Ratio > 1.0 表示 Triton 更快。
优先级:正确性 > 泛化性 > 性能。
优化前先审视算法本身。低效算法再优化也有先天不足。
time.time() 测端到端(覆盖小/中/大),达标则完成msprof 测 kernel 侧耗时,定位真正瓶颈| 瓶颈 | 优化重点 |
|---|---|
| Memory-Bound | 向量化访存、UB 缓存复用、算子融合 |
| Compute-Bound | Cube 适配、Block 尺寸调优 |
| Latency-Bound | 增大并行度、减少同步 |
基础四板斧(按顺序):Block/Grid Size → 连续访存 → UB 复用 → 编译时常量
加载:optimization-patterns.md, ascend-terminology.md
tl.parallel(bind_sub_block=True) 分配到 2 个 vector cores加载:triton-ascend-api.md, tiling-strategies.md, triton-api-reference.md
算子融合、Double Buffer(tl.multibuffer(tensor, 2) 或 tl.compile_hint(tensor, "multi_buffer", 2))
精度 + 泛化性 + 性能 + 端到端回归
tensor.item()(触发 CPU-NPU 同步)| msprof 指标 | 瓶颈 | 典型优化 |
|---|---|---|
| aiv_scalar > 80% | Scalar Bound | 检查双 pass / 逐行循环+tl.where 累加,改单 pass |
| aiv_mte2 > 50% | Memory Bound | 连续访存、expand+contiguous、增大 BLOCK |
| aiv_vec > 50% | Compute Bound | 算法优化、减少冗余计算 |
| aic_cube_ratio < 50% | Cube 利用率低 | 检查对齐(512B/元素大小)、BLOCK 是否 16 倍数、用 compile_hint('dot_pad_only_k') |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/external-gitcode-ascend-skills:external-gitcode-ascend-triton-operator-performance-optimfrom external-gitcode-ascend-skills
npx claudepluginhub ascend-ai-coding/awesome-ascend-skills --plugin external-gitcode-ascend-skills91 skills in this plugin
/external-gitcode-ascend-analyse-coverage分析测试覆盖率盲区,生成覆盖率分析报告/external-gitcode-ascend-arxiv-recommendation-npu自动化推荐系统论文发现流水线。抓取 arxiv 推荐论文,检测源码,生成待迁移任务清单,由 npu-model-migration skill 完成 NPU 适配。/external-gitcode-ascend-ascendc-operator-code-gen根据设计文档生成 AscendC 算子完整代码实现并完成框架适配。TRIGGER when: 设计文档已完成,需要生成 op_host/op_kernel 代码、注册到 PyTorch 框架、编译测试。关键词:代码生成、op_host、op_kernel、tiling、kernel、框架适配、算子注册。Other plugins' skills for the same job