torch.profiler的distributed view?如何profile分布式训练的通信开销?torch.profiler的distributed view?
torch.profiler 支持多进程下的时间线汇总:用 schedule、activities 等记录各 rank 的 CPU/CUDA 与通信事件,导出 Chrome trace 或用 profiler.key_averages() 看汇总。Distributed 视角:需在各 rank 上一致地 start/stop profiler,并确保记录 NCCL/custom collective 事件(通常通过 CUDA 活动或 backend hook 看到通信 kernel)。
torch.profiler.ProfilerActivity.CUDA 时,NCCL 的 kernel 会出现在 timeline 上,可看到 all-reduce、all-gather 等占用的时间与重叠情况。nccl:all_reduce 等占 CPU/CUDA 时间比例;group_by_stack_n=5 可看调用栈,定位是 DDP、FSDP 还是自定义 collective。torch.profiler.profile(..., record_shapes=True) 可看到 tensor 大小,便于对照通信量。trace_rank{rank}.json),再一起打开对比;或使用能合并多进程的 profiler 后端。NCCL_DEBUG=INFO 看实际 collective 次数与大小,与 profile 里的通信事件对应,判断是否有多余或过大的 collective。| 返回模块 | 返回总览 |