Ascend/msagent / skills/operator/ops-performance-tuning
ops-performance-tuning
VerifiedCompile, profile, diagnose, optimize, and compare Ascend NPU operators across CANN versions and A2/A3/A5 for Ascend C, CATLASS, Triton-Ascend, TileLang-Ascend, PyPTO, and SHMEM/MC2. Use when an operator already has a runnable implementation and the user asks for msOpProf collection, bottleneck analysis, source-level tuning, or a reproducible before/after performance report. Do not use as the primary workflow for operator creation, migration, or unresolved correctness failures.
references/cases/shmem/pr_shmem_alltoallv_mr152.md
View on GitHub# MR !152(Ascend/agent-skills)SHMEM alltoallv 8PE full-mesh 端到端调优交付总结【PR】
## 基本信息
- 算子类别:communication
- DSL/框架:shmem
- 类型:PR(GitCode MR)
- 来源可信度:一手 MR 原文(官方交付总结 MR)
## 来源链接
- PR/出处链接:<https://gitcode.com/Ascend/agent-skills/pull/152>(官方交付总结 MR; 已验证可达,验证日期 2026-08)
- 优化代码查看:<https://gitcode.com/Ascend/agent-skills/pull/152/files>( 已验证可达,验证日期 2026-08)
- 关联知识:[../../optimize-shmem.md](../../optimize-shmem.md) §2.6
## 问题与瓶颈
SHMEM alltoallv 通信算子在 8PE full-mesh 拓扑下的性能优化问题,交付总结记录了多轮(Round)调优过程。具体 profiling 指标原文未附详细定位数据;从优化手段可推断瓶颈在于:MTE2 搬入与 MTE3 搬出/处理串行等待、全局 barrier 使所有核等待最慢者、流水依赖点控制不精确导致全流水 flush。
## 优化方法(理论手段)
最终优化手段组合:**向量 barrier + ping-pong 双缓冲(95KB×2)+ PipeBarrier**。主收益来自 Round 2 的 ping-pong 双缓冲(单轮 +16%)。机制分析(结合 `optimization-patterns.md` §2.2 与 `references/optimize-shmem.md` §2.2):
1. **Ping-Pong 双缓冲**:两组 UB buffer + 两组 event id 交替,`SetFlag`/`WaitFlag<HardEvent::MTE3_MTE2>` 成对使用,使第 k 块的 MTE2 搬入与第 k-1 块的 MTE3 搬出/处理重叠,消除搬运串行等待;
2. **向量 barrier 替代全局 barrier**:producer-consumer 点对点同步,避免全局 barrier 使所有核等待最慢者;
3. **PipeBarrier**:精确控制流水依赖点,避免全流水 flush;
4. Chunk 大小 95KB 与 double buffer 的 UB/2 上限约束相洽(MTE chunk 经验区间:≥16KB、allgather 经验最优 ~190KB)。
## 性能对比
MR !152 交付总结原文实测(L 档 8M 消息):
| 指标 | 优化前 | 优化后 | 变化 |
|---|---|---|---|
| 带宽 | 68.99 GB/s | 79.75 GB/s | +15.6% |
| e2e 时延 | 1702.4 μs | 1472.7 μs | −13.5% |
| 峰值利用率 | 35.2% | 40.7% | +5.5 pp |
## 适用范围与警示
- 适用场景:SHMEM alltoallv 通信算子,8PE full-mesh 拓扑;数字为 L 档 8M 消息下的实测结果。
- 主收益来自 ping-pong 双缓冲(单轮 +16%),chunk 大小受 double buffer 的 UB/2 上限约束,迁移到其他芯片时需重新核算 UB 容量。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| planning-and-task-breakdownaddyosmani/agent-skillsBreaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| screenpipethedotmack/claude-memSearch screen and audio history recorded by Screenpipe and optionally save selected context into claude-mem. Use when the user asks to recall desktop activity, a meeting, or something seen in another app through Screenpipe. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| contact-widgetnexu-io/open-designSelf-contained floating chat widget with welcome screen, social links, meeting button, and message input. Single HTML file, zero dependencies. | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |
| meeting-notesnexu-io/open-designMeeting notes page — title bar with attendees, agenda checklist, decisions block, action items table with owners + dates, and a "next meeting" footer. Use when the brief mentions "meeting notes", "minutes", "1:1 notes", "all-hands recap", or "会议纪要". | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |