昇腾社区首页
EN
注册

torch_npu.profiler.ProfilerLevel

接口原型

1
torch_npu.profiler.ProfilerLevel

功能描述

采集等级,Enum类型。用于作为 _ExperimentalConfig类的profiler_level参数。

参数说明

  • Level_none:不采集所有Level层级控制的数据,即关闭profiler_level。
  • Level0:采集上层应用数据、底层NPU数据以及NPU上执行的算子信息。配置该参数时,仅采集部分数据,其中部分算子信息不采集,详细情况请参见CANN 性能调优工具用户指南》中的“op_summary(算子详细信息)”章节
  • Level1:在Level0的基础上多采集CANN层AscendCL数据和NPU上执行的AI Core性能指标信息、开启aic_metrics=torch_npu.profiler.AiCMetrics.PipeUtilization以及HCCL的communication.json和communication_matrix.json文件。
  • Level2:在Level1的基础上多采集CANN层Runtime数据以及AI CPU(data_preprocess.csv文件)。

默认值为Level0。

支持的型号

  • Atlas 训练系列产品
  • Atlas A2 训练系列产品
  • Atlas A3 训练系列产品

调用示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import torch
import torch_npu

...

experimental_config = torch_npu.profiler._ExperimentalConfig(
       profiler_level=torch_npu.profiler.ProfilerLevel.Level0
       )
with torch_npu.profiler.profile(
        on_trace_ready=torch_npu.profiler.tensorboard_trace_handler("./result"),
        experimental_config=experimental_config) as prof:
        for step in range(steps): # 训练函数
                train_one_step() # 训练函数
                prof.step()