Top-down training performance profiling toolkit for PyTorch + DeepSpeed workloads
npx claudepluginhub jimmypeilinli/profile_claude_skillComplete top-down performance profiling pipeline: from nsys/torch.profiler/pyinstrument traces to hierarchical time attribution with source code mapping
PyTorch + DeepSpeed 训练性能 Top-Down 分析工具包。
从三种 profile 数据(nsys、torch.profiler、pyinstrument)出发,完成完整的层次化时间归因分析,最终输出到具体代码和 aten 操作级别的性能分解。
# 安装为 Claude Code plugin
claude plugin add /path/to/profile_toolkit
# 使用 skill
/profile-training
cd profile_toolkit/scripts
# Step 1: 探索数据文件结构
python 01_explore_data.py /path/to/profile_data
# Step 2: 提取 NVTX 训练时间线
python 02_nsys_nvtx_timeline.py /path/to/nsys.json
# Step 3: GPU kernel 分类(nsys sqlite,避免 JSON 名称截断)
python 03_nsys_gpu_kernels.py /path/to/nsys.sqlite time_ranges.json
# Step 4: Memcpy + Sync 分析
python 04_nsys_memcpy_sync.py /path/to/nsys.sqlite time_ranges.json
# Step 5: CPU ops Total Time 聚合
python 05_torch_cpu_ops.py /path/to/torch_trace.json <start_us> <end_us>
# Step 6: Self Time 计算(核心算法)
python 06_self_time.py /path/to/torch_trace.json <start_us> <end_us>
# Step 7: CUDA Runtime 归因到关键 Op
python 07_cuda_runtime_attribution.py /path/to/torch_trace.json <start_us> <end_us>
# Step 8: Pyinstrument 代码路径分析
python 08_pyinstrument_analysis.py /path/to/pyinstrument_trace.json
三种 Profile 输入
├── nsys sqlite → GPU kernel 分类 + Memcpy/Sync 统计
├── nsys JSON → NVTX 训练时间线(forward/backward wall time)
├── torch.profiler → cpu_op Total/Self Time + CUDA Runtime 归因
└── pyinstrument → Python 代码路径映射
↓ 分析流水线
Step 1: 数据探索 → 确认文件结构和可用字段
Step 2: NVTX 时间线 → 识别稳态 step、提取时间范围
Step 3: GPU kernel → 完整 demangled 名称分类(修正 JSON 截断问题)
Step 4: Memcpy/Sync → HtoD 搬运量、带宽、同步等待时间
Step 5: CPU ops → Total Time 聚合(含嵌套重复)
Step 6: Self Time → Stack-based 去重算法(核心创新)
Step 7: CUDA Runtime 归因 → 分解 self time 为 GPU sync vs Python dispatch
Step 8: 代码路径 → 映射到 DeepSpeed/框架源码
↓ 输出文档
01. 训练整体流程时间分布
02. Step 级 forward/backward wall time
03. GPU kernel 分类统计
04. 数据搬运深度分析
05. CPU Self Time 层次化分解
06. 完整时间归因大表(一级→二级→三级,到代码级)
torch.profiler 的 cpu_op 事件是嵌套的。使用 stack-based interval containment 算法:
(ts, -dur) 排序(相同起始时间,长事件先入栈成为父事件)child_dur[parent] += child.durself_time = dur - child_dur(自身独占 CPU 时间)对每个关键 cpu_op,用 bisect 二分查找其时间范围内的 cuda_runtime 事件, 分解 self time 为:
Apache 2.0
7-day visitors to each marketplace page
Anthropic example skills
Anthropic's Claude Code plugins, installed from the claude-plugins-official repository
Ultra-compressed communication mode. Shortens prose while preserving technical terms, code, commands, and exact errors.