使用场景
数据采集对比
- 关键数据采集
按如下配置运行模型将采集对应数据。如需对比同一模型在标杆Device与当前Device上的表现,可分别采集,(两次需要设置不同的dump_path)
precision_collector: msprobe: True # 使用以下采集、加载功能时,必须开启 dump_path: "./benchmark_infer_data" key_data_dump: True # 关键数据采集 actor_infer_dump: True # 推理数据采集 step_start: 0 # 从0开始采集 step_end: 58 # 采集步数 token_range_start: 1 token_range_end: 2 level: "L0" task: "statistics" enable_mock_inference: False # 仅采集不加载数据时,需要禁用mock推理使能
得到两次训练过程的关键阶段性数据,数据可用来定界到模型或代码块。
- 对比data关键数据
复制如下训练脚本py,将dump_path1和dump_path2改为需要比对的dump_path文件路径,output_path改为保存路径,执行该脚本:
from msprobe.core import SingleComparator SingleComparator.compare( "dump_path1", "dump_path2", "output_path")获得对 data 中各关键数据的比对结果.xlsx表格。
- 对比模型层数据
如采集到模型层数据,将./dump_path1/step2和./dump_path2/step2改为需要比对的step层级路径(比如./msprobe_dump/reference_compute_log_prob/step2)
from msprobe.pytorch import * compare_distributed( './dump_path1/step2', './dump_path2/step2', './output_path')获得一个比对结果表格compare_result_{timestamp}.xlsx。
- 观察结果表格,找到首个出现差异的位置
具体差异对比标准和方法可见:关键数据比对指南(key_data_dump)、模型层数据比对指南(actor_train_dump、reference_dump、critic_train_dump)

- 标杆Device训练,开启推理数据采集,保存在 benchmark_infer_data/ 中,配置如下:
precision_collector: msprobe: True # 使用以下采集、加载功能时,必须开启 dump_path: "./benchmark_infer_data" key_data_dump: True # 关键数据采集 step_start: 0 # 使用此方案时,需从0开始采集 step_end: 58 # 采集步数,至少两步 enable_mock_inference: False # 仅采集不加载数据时,需要禁用mock推理使能 mock_data_path: "./collector_saved_path"
key_data_dump将采集关键的推理数据,包括 response、input_ids、attention_mask、 prompts、position_ids。
注:如需要对比整个训练过程,step_end 可设置为最大step数+1,如上将采集0-57步数据。
- 当前Device训练,开启标杆Device推理数据顺序加载,配置如下:
precision_collector: msprobe: True # 使用以下采集、加载功能时,必须开启 step_start: 0 # 使用此方案时,需从0开始加载 step_end: 58 # 加载步数 enable_mock_inference: True # 加载推理数据时,开启mock推理使能 mock_data_path: "./benchmark_infer_data" # 待加载数据位置
开启Mock时,Log 将给出警告信息:“Mock inference enabled - loading from {config.mock_data_path}, You can disable in precision_collector.yaml”。
注:加载的同时可以采集,只需配置相应采集开关为True即可。
但要注意此时 mock_data_path、dump_path 如果相同可能覆盖数据,Log将给出警告信息:“The dump_path and mock_data_path in the configuration are the same ... ”
- 对比两个Device的训练Loss曲线、使用上节方法对比落盘数据。