For kernel_details.csv in aic_mac_ratio≥80% operators, calculate the theoretical time based on the NPU peak compute and bandwidth, compare it with the actual time, and give whether optimization is needed and preliminary investigation directions.
This Skill is at the same level as profiling-analysis-computing and independent of it: compute bottleneck insight/shape analysis still uses computing; this Skill focuses on Roofline theoretical/actual verification.
Required inputs
All are mandatory; if any is missing, ask the user first and do not guess by default:
kernel_details.csvpath, or the profiling root directory containing that file (must contain theaic_mac_ratiocolumn)- NPU compute (TFLOPS): enter FP16/BF16 Cube peak
- Memory bandwidth: by default interpreted as GB/s Explanation
--bandwidth;1.2 TB/swritten as--bandwidth 1.2 --bw-unit TB/s, or--bandwidth 1200
Optional:--mac-threshold(default 0.80),--top、--output-path / --out、--int8-scale(default 2)
Script
scripts/kernel_roofline_compute_check.py: analysis entry pointreference/kernel_roofline_compute_check.md: conventions, criteria, and investigation directions
Usage
python scripts/kernel_roofline_compute_check.py \
--input-path <profiling根目录> \
--flops <TFLOPS> --bandwidth 1.2 --bw-unit TB/s \
--output-path <输出目录>
Or specify the CSV directly:
python scripts/kernel_roofline_compute_check.py \
--csv <path>/kernel_details.csv \
--flops <TFLOPS> --bandwidth 1200 \
--out <输出目录>/kernel_roofline_compute_check.csv
Self-check:
python scripts/kernel_roofline_compute_check.py --self-test
Analysis conventions (summary)
- Theoretical time =
max(FLOPs/算力, Bytes/带宽); efficiency = theoretical/actual - By default, only analyze
aic_mac_ratio≥80% - Modelable: MatMul family, QuantBatchMatmul, TransposeBatchMatMul, GroupedMatmul/SwigluQuant, Compressor, SparseAttn, HcPre/HcPost, etc.
Whether optimization is needed (summary)
| Efficiency | Judgment |
|---|---|
| 80%~120% | Do not prioritize optimizing the kernel for now (Cube is already near peak) |
| 40%~70% | Optimization recommended |
| <40% | Optimization needed |
| >150% | Model overestimates; do not rank based on this |
For detailed criteria and investigation directions, see Compute Bottleneck Roofline Check。
Output
- Terminal report: overall overview, summary by type, Top details, optimization-needed summary, preliminary investigation directions
- CSV (optional):
kernel_roofline_compute_check.csv