Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
"./skills/profiling/profiling-analysis/profiling-analysis-hostbound",
"./skills/profiling/profiling-analysis/profiling-analysis-computing",
"./skills/profiling/profiling-analysis/profiling-analysis-communication",
"./skills/profiling/profiling-analysis/profiling-analysis-roofline",
"./skills/profiling/mindspeed-llm-train-profiler",
"./skills/profiling/mindspeed-mm-train-profiler",
"./skills/profiling/pytorch-profiling-collection",
Expand Down Expand Up @@ -658,7 +659,8 @@
"./skills/profiling/profiling-analysis",
"./skills/profiling/profiling-analysis/profiling-analysis-hostbound",
"./skills/profiling/profiling-analysis/profiling-analysis-computing",
"./skills/profiling/profiling-analysis/profiling-analysis-communication"
"./skills/profiling/profiling-analysis/profiling-analysis-communication",
"./skills/profiling/profiling-analysis/profiling-analysis-roofline"
],
"category": "profiling",
"categories": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ npx skills add https://github.com/ascend-ai-coding/awesome-ascend-skills -s '*'

`ascend-profiling` 和 `ascend-ops` 的区别:

- 选 `ascend-profiling`:你已经有模型/训练任务,重点是**采集 Profiling、定位性能瓶颈、分析 hostbound / computing / communication**。
- 选 `ascend-profiling`:你已经有模型/训练任务,重点是**采集 Profiling、定位性能瓶颈、分析 hostbound / computing / communication / roofline**。
- 选 `ascend-ops`:你要做的是**算子开发、算子迁移、op-plugin 接入、Triton-Ascend 改写或算子级调优**。

### 领域技能包
Expand Down
2 changes: 1 addition & 1 deletion skills/profiling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

当前 `skills/profiling/` 已承载真实 skill 目录;请按下面链接进入对应 skill 开发:

- [`profiling-analysis/`](profiling-analysis/):hostbound / computing / communication 分析
- [`profiling-analysis/`](profiling-analysis/):hostbound / computing / communication / roofline 分析
- [`mindspeed-llm-train-profiler/`](mindspeed-llm-train-profiler/):MindSpeed-LLM 训练 Profiling 采集
- [`mindspeed-mm-train-profiler/`](mindspeed-mm-train-profiler/):MindSpeed-MM 多模态训练 Profiling 采集
- [`pytorch-profiling-collection/`](pytorch-profiling-collection/):基于 torch_npu.profiler 的通用训练/推理脚本 Profiling 采集(非 MindSpeed 场景)
Expand Down
4 changes: 4 additions & 0 deletions skills/profiling/profiling-analysis/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ profiling-analysis 技能通过以下流程自动完成性能分析:

# 分析下发瓶颈
调用 skill "profiling-analysis-hostbound" 分析 "input_path" 中的Host侧问题

# 算力瓶颈 Roofline 核对
调用 skill "profiling-analysis-roofline" 分析 "kernel_details.csv"(需提供 NPU 峰值算力与带宽)
```

## 子技能介绍
Expand All @@ -131,6 +134,7 @@ profiling-analysis 包含以下子技能,用于不同类型的性能分析。
| **profiling-analysis-computing(.\profiling-analysis-computing\SKILL.md)** | 计算瓶颈分析,包含:<br>- 高耗时算子筛选(Top-N算子)<br>- 算子性能数据透视表分析<br>- 关键算子(如MatMul系列)形状解析与优化建议 | 计算占比过高时,深入分析具体的高耗时算子及其性能特征 |
| **profiling-analysis-communication(.\profiling-analysis-communication\SKILL.md)** | 通信瓶颈分析,分析集合通信性能 | 通信占比过高时,分析通信操作的性能 |
| **profiling-analysis-hostbound(.\profiling-analysis-hostbound\SKILL.md)** | 下发瓶颈分析,分析Host侧性能问题 | 空闲占比过高时,分析Host侧的下发问题 |
| **profiling-analysis-roofline(.\profiling-analysis-roofline\SKILL.md)** | 算力瓶颈 Roofline 核对:对 aic_mac_ratio≥80% 算子比较理论/实际耗时,并给出是否需优化建议 | 需要判断算力瓶颈算子是否打满峰值、是否值得做单 kernel 优化时 |

## 支持的数据格式

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: profiling-analysis-roofline
description: 对 Ascend profiler 的 kernel_details.csv 做算力瓶颈 Roofline 核对:筛选 aic_mac_ratio≥80% 的算子,比较理论耗时与实际耗时,判断是否需要优化并给出排查方向。当用户提到 Roofline、aic_mac_ratio、理论耗时、算力瓶颈核对、kernel_details 峰值对比时使用。
keywords:
- profiling
- Roofline
- aic_mac_ratio
- 算力瓶颈
- 理论耗时
- kernel_details
---

# Profiling 算力瓶颈 Roofline 核对 Skill

对 `kernel_details.csv` 中 `aic_mac_ratio≥80%` 的算子,按 NPU 峰值算力与带宽计算理论耗时,并与实际耗时对比,给出是否需要优化及初步排查方向。

本 Skill 与 `profiling-analysis-computing` 同级、相互独立:计算瓶颈透视/形状解析仍用 computing;本 Skill 专注 Roofline 理论/实际核对。

## 需要的输入

缺一不可;缺失时先向用户询问,不要默认猜测:

1. `kernel_details.csv` 路径,或含该文件的 profiling 根目录(需含 `aic_mac_ratio` 列)
2. NPU 算力(TFLOPS):填 **FP16/BF16 Cube 峰值**
3. 内存带宽:默认按 **GB/s** 解释 `--bandwidth`;`1.2 TB/s` 写作 `--bandwidth 1.2 --bw-unit TB/s`,或 `--bandwidth 1200`

可选:`--mac-threshold`(默认 0.80)、`--top`、`--output-path` / `--out`、`--int8-scale`(默认 2)

## 脚本

- `scripts/kernel_roofline_compute_check.py`:分析入口
- `reference/kernel_roofline_compute_check.md`:口径、判据与排查方向

## 使用方式

```bash
python scripts/kernel_roofline_compute_check.py \
--input-path <profiling根目录> \
--flops <TFLOPS> --bandwidth 1.2 --bw-unit TB/s \
--output-path <输出目录>
```

或直接指定 CSV:

```bash
python scripts/kernel_roofline_compute_check.py \
--csv <path>/kernel_details.csv \
--flops <TFLOPS> --bandwidth 1200 \
--out <输出目录>/kernel_roofline_compute_check.csv
```

自检:

```bash
python scripts/kernel_roofline_compute_check.py --self-test
```

## 分析口径(摘要)

- 理论耗时 = `max(FLOPs/算力, Bytes/带宽)`;效率 = 理论/实际
- 默认只分析 `aic_mac_ratio≥80%`
- 可建模:MatMul 系、QuantBatchMatmul、TransposeBatchMatMul、GroupedMatmul/SwigluQuant、Compressor、SparseAttn、HcPre/HcPost 等

## 是否需要优化(摘要)

| 效率 | 判断 |
|------|------|
| 80%~120% | 暂不优先优化 kernel(Cube 已接近峰值) |
| 40%~70% | 建议优化 |
| <40% | 需要优化 |
| >150% | 模型高估,不据此排序 |

详细判据与排查方向见 [算力瓶颈 Roofline 核对](./reference/kernel_roofline_compute_check.md)。

## 输出

- 终端报告:总体概况、按类型汇总、Top 明细、是否需优化摘要、初步排查方向
- CSV(可选):`kernel_roofline_compute_check.csv`
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 算力瓶颈算子 Roofline 核对

对 `kernel_details.csv` 中 `aic_mac_ratio≥80%` 的算子比较理论耗时与实际耗时,判断是否需优化。

## 输入与命令

必填:`--flops`(FP16/BF16 Cube TFLOPS)、`--bandwidth`(配合 `--bw-unit`)。缺失时先询问用户,不要猜测。

```bash
python scripts/kernel_roofline_compute_check.py --input-path <profiling根目录> \
--flops <TFLOPS> --bandwidth 1.2 --bw-unit TB/s --output-path <输出目录>
# 或 --csv <kernel_details.csv> --bandwidth 1200 --out <明细.csv>
```

## 口径

- 理论耗时 = `max(FLOPs/算力, Bytes/带宽)`;效率 = 理论/实际
- 默认过滤 `aic_mac_ratio≥0.80`(`--mac-threshold` 可调)
- INT8/FP8 Cube 默认 `--int8-scale 2`
- 可建模:MatMul 系、QuantBatchMatmul、TransposeBatchMatMul、GroupedMatmul/SwigluQuant(含 ceiling)、Compressor、SparseAttn、HcPre/HcPost、Scatter 等;Metadata/Indexer 等标未建模

## 是否需要优化

| 效率 | 判断 | 方向 |
|------|------|------|
| 80%~120% | 暂不优先优化 kernel | 图级融合/合批/减调用/算法降算量 |
| 70%~80% | 可选优化 | 核对合批与精度路径 |
| 40%~70% | 建议优化 | M/N/K、合批、库路径、tiling |
| <40% | 需要优化 | 同上,优先浪费最大的 Type |
| >150% | 不据此优化 | 模型高估 |

单次 Duration&lt;10us 的低效率常为 launch 开销。输出含终端报告与可选 `kernel_roofline_compute_check.csv`。
Loading
Loading