内核优化的常见步骤

  1. 分析 Kernel 的执行时间
    1. 统计、查看各个 Kernel 的执行时间
    2. 定位性能瓶颈,确定需要优化的 Kernel
  2. 检查 GPU 的利用率等信息
    1. 例如检查是否占用过多的寄存器
    2. (更细粒度)确定 Kernel 的性能瓶颈
  3. 优化 Kernel 性能
    1. 通过各种技术手段(软硬件、调度、内存优化)优化 Kernel

PyTorch 内置

torch.profiler

  1. TensorBoard
  2. Holistic Trace Analysis

NVIDIA Nsight 工具

  • Nsight System
  • Nsight Compute

Triton

  • Proton