diff --git a/README.md b/README.md index 0f8a9b621dc83d80ba979058daf3d796f766caa4..67cf3410ceb4c5e2ed9fe860a768e8734a197ecb 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,63 @@ -# att +# ATT -#### 介绍 -Ascend Training Tools,昇腾训练工具链 -针对训练&大模型场景,提供端到端命令行&可视化调试调优工具,帮助用户快速提高模型开发效率 +Ascend Training Tools,昇腾训练工具链。针对训练&大模型场景,提供端到端命令行&可视化调试调优工具,帮助用户快速提高模型开发效率。 -#### 模型训练迁移全流程 +## 模型训练迁移全流程 ![输入图片说明](debug/resources/model_training_migration_process.png) -#### 使用说明 -1. 性能工具[tools](https://gitee.com/ascend/att/tree/master/profiler) +## 使用说明 - a. [compare_tools](https://gitee.com/ascend/att/tree/master/profiler/compare_tools) +### [分析迁移工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D) - **GPU与NPU性能比较工具**:提供NPU与GPU性能拆解功能以及算子、通信、内存性能的比较功能。 +1. [脚本分析工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E8%84%9A%E6%9C%AC%E5%88%86%E6%9E%90%E5%B7%A5%E5%85%B7) - b. [distribute_tools](https://gitee.com/ascend/att/tree/master/profiler/distribute_tools) + 脚本分析工具提供分析脚本,帮助用户在执行迁移操作前,分析基于GPU平台的PyTorch训练脚本中算子、三方库套件、亲和API分析以及动态shape的支持情况。 - **集群场景脚本集合**:提供集群场景数据一键汇聚功能。 +2. [脚本迁移工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E8%84%9A%E6%9C%AC%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D) - c. [merge_profiling_timeline](https://gitee.com/ascend/att/tree/master/profiler/merge_profiling_timeline) + 脚本迁移工具提供后端命令行用于将GPU上训练的PyTorch脚本迁移至NPU上,得到新的训练脚本用于训练。 - **合并大json工具**:融合多个profiling的timeline在一个json文件中的功能。 +3. [自动迁移工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E8%87%AA%E5%8A%A8%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7) - d. [cluster_analyse](https://gitee.com/ascend/att/tree/master/profiler/cluster_analyse) + 自动迁移只需在训练脚本中导入库代码即可完成模型脚本迁移,使用方式较简单,且修改内容最少。 - **集群分析工具**:提供多机多卡的集群分析能力(基于通信域的通信分析和迭代耗时分析), 当前需要配合Ascend Insight的集群分析功能使用。 +### [精度工具](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools) +1. [api_accuracy_checker(Ascend模型精度预检工具)](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/api_accuracy_checker) -2. 精度工具[tools](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools) + 在昇腾NPU上扫描用户训练模型中所有API,进行API复现,给出精度情况的诊断和分析。 - a. [api_accuracy_checker](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/api_accuracy_checker) +2. [ptdbg_ascend(PyTorch精度工具)](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend) - **预检功能**:Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所有API,给出它们精度情况的诊断和分析。 + 进行PyTorch整网API粒度的数据dump、精度比对和溢出检测,从而定位PyTorch训练场景下的精度问题。 - b. [ptdbg_ascend](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend) +### [性能工具](https://gitee.com/ascend/att/tree/master/profiler) - **PyTorch精度工具**:用来进行PyTorch整网API粒度的数据dump、精度比对和溢出检测,从而定位PyTorch训练场景下的精度问题。 +1. [compare_tools(性能比对工具)](https://gitee.com/ascend/att/tree/master/profiler/compare_tools) -3. 分析迁移工具[tools](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D) + 提供NPU与GPU性能拆解功能以及算子、通信、内存性能的比对功能。 - a. [脚本分析工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E5%88%86%E6%9E%90%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D) - - **脚本分析能力**:脚本分析工具提供分析脚本,帮助用户在执行迁移操作前,分析基于GPU平台的PyTorch训练脚本中算子、三方库套件、亲和API分析以及动态shape的支持情况 - b. [脚本迁移工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D#%E8%84%9A%E6%9C%AC%E8%BF%81%E7%A7%BB) - - **脚本迁移能力**:脚本迁移工具提供后端命令行用于将GPU上训练的PyTorch脚本迁移至NPU上,得到新的训练脚本用于训练 - - c. [自动迁移工具](https://gitee.com/ascend/att/wikis/%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D/%E5%88%86%E6%9E%90%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7/%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D#%E8%87%AA%E5%8A%A8%E8%BF%81%E7%A7%BB%E5%B7%A5%E5%85%B7) +2. [cluster_analyse(集群分析工具)](https://gitee.com/ascend/att/tree/master/profiler/cluster_analyse) - **自动迁移能力**:自动迁移只需在训练脚本中导入库代码即可完成模型脚本迁移,使用方式较简单,且修改内容最少 + 提供多机多卡的集群分析能力(基于通信域的通信分析和迭代耗时分析), 当前需要配合Ascend Insight的集群分析功能使用。 - -4. tensorboard支持npu可视化插件[tb-plugin](https://gitee.com/ascend/att/tree/master/plugins/tensorboard-plugins/tb_plugin) +3. [merge_profiling_timeline(合并大json工具)](https://gitee.com/ascend/att/tree/master/profiler/merge_profiling_timeline) - **PyTorch profiling数据可视化的TensorBoard的插件**: 它支持将Ascend平台采集、解析的Pytorch Profiling数据可视化呈现,也兼容GPU数据采集、解析可视化。 + 融合多个Profiling的timeline在一个json文件中的功能。 +4. [distribute_tools(集群场景脚本集合工具)](https://gitee.com/ascend/att/tree/master/profiler/distribute_tools) -#### 参与贡献 + 提供集群场景数据一键汇聚功能。 -1. Fork 本仓库 -2. 新建 xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### [Tensorboard](https://gitee.com/ascend/att/tree/master/plugins/tensorboard-plugins/tb_plugin) +Tensorboard支持NPU性能数据可视化插件PyTorch Profiler TensorBoard NPU Plugin。 + +支持将Ascend平台采集、解析的Pytorch Profiling数据可视化呈现,也兼容GPU数据采集、解析可视化。 + +## 参与贡献 + +1. Fork 本仓库 +2. 新建 xxx 分支 +3. 提交代码 +4. 新建 Pull Request diff --git a/debug/accuracy_tools/README.md b/debug/accuracy_tools/README.md index 7fbf89ef3981863ee50320141c998511634e12ce..d26ee95aee43608ca7cc3cd3b7d617e5c117e71a 100644 --- a/debug/accuracy_tools/README.md +++ b/debug/accuracy_tools/README.md @@ -1,88 +1,20 @@ # 精度工具 -## 目录 +ATT工具针对模型训练精度问题设计推出了一系列精度工具,包括模型精度预检工具和PyTorch精度工具的精度比对功能、溢出检测功能、通信精度检测等功能。这些工具有各自侧重的场景,用于辅助用户定位模型精度问题。 -- [介绍](#介绍) -- [工具安装](#工具安装) -- [工具使用](#工具使用) +### 子功能介绍 -## 介绍 +NPU上训练的网络存在精度问题,精度指标(loss或者具体的评价指标)与标杆相差较多。对于该场景的问题,可以使用**Ascend模型精度预检工具**或者**PyTorch精度工具**进行定位。 -MindStudio精度工具针对模型训练精度问题设计推出了一系列精度工具,包括模型精度预检工具(预检工具)、溢出检测工具、精度比对工具、通信精度检测功能。这些工具有各自侧重的场景,用于辅助用户定位模型精度问题。 +| 工具名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [api_accuracy_checker(Ascend模型精度预检工具)](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/api_accuracy_checker) | 在昇腾NPU上扫描用户训练模型中所有API,进行API复现,给出精度情况的诊断和分析。 | +| [ptdbg_ascend(PyTorch精度工具)](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend) | 进行PyTorch整网API粒度的数据dump、精度比对和溢出检测,从而定位PyTorch训练场景下的精度问题。 | -### 精度工具各子功能介绍 +### 场景介绍 -| 工具名称 | 说明 | -| ------------ | ------------------------------------------------------------ | -| [精度比对工具](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend) | 用于进行PyTorch整网API粒度的数据dump、精度比对和溢出检测,从而定位PyTorch训练场景下的精度问题。 | -| [精度预检工具](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/api_accuracy_checker) | 用于扫描用户训练模型中所有API,给出各API精度情况的诊断和分析。 | +**Ascend模型精度预检工具**会对全网每一个API根据其实际训练中的shape、dtype和数值范围生成随机的输入,对比它与标杆的输出差异,并指出输出差异过大不符合精度标准的API。该工具检查单API精度问题准确率超过80%,对比一般dump比对方法减少落盘数据量99%以上。具体使用请参见《[Ascend模型精度预检工具](https://gitee.com/ascend/att/blob/master/debug/accuracy_tools/api_accuracy_checker/README.md)》 -## 工具安装 +**PyTorch精度工具精度比对功能**可以对NPU整网API数据进行与CPU或GPU标杆数据的精度比对,从而检测精度问题。具体来说,dump统计量、分段dump、模块化dump,通讯算子dump等功能可以用较轻的数据量实现不同侧重的精度比对,从而定位精度问题。具体使用请参见《[ptdbg_ascend精度工具功能说明](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend/doc)》。 -[精度比对工具安装指南](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend#%E5%BF%AB%E9%80%9F%E5%AE%89%E8%A3%85) - -**精度预检工具安装指南**: - -安装预检工具 - -将att仓代码下载到本地,并配置环境变量。假设下载后att仓路径为 $ATT_HOME,环境变量应配置为: - -``` -export PYTHONPATH=$PYTHONPATH:$ATT_HOME/debug/accuracy_tools/ -``` - -环境和依赖 - -``` -pip3 install tqdm prettytable pyyaml -``` - -## 工具使用 - -### 场景一:精度存在偏差 - -该场景的现象表现为:NPU上训练的网络存在精度问题,精度指标(loss或者具体的评价指标)与标杆相差较多。 - -对于该场景的问题,可以使用**精度预检工具**或者**精度比对工具**进行定位。 - -精度预检工具:该工具会对全网每一个API根据其实际训练中的shape、dtype和数值范围生成随机的输入,对比它与标杆的输出差异,并指出输出差异过大不符合精度标准的API。该工具检查单API精度问题准确率超过80%,对比一般dump比对方法减少落盘数据量99%以上。 - -精度比对工具:在预检工具的输入随机生成的情况下,有些场景预检工具有概率检测不到算子精度问题,这时候除了多跑几次预检工具之外,用户还可以使用dump 比对工具来检测精度问题。具体来说,dump统计量、分段dump、模块化dump,通讯算子dump等功能可以用较轻的数据量实现不同侧重的精度比对,从而定位精度问题。 - -[精度比对工具使用指南](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend#%E5%BF%AB%E9%80%9F%E5%AE%89%E8%A3%85) - -[精度预检工具使用指南](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/api_accuracy_checker#%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) - -### 场景二:训练存在溢出 - -该场景的现象表现为:训练网络可能存在溢出现象,例如某个step的loss突然变成inf nan,或者混精场景下loss_scale不断减小。 - -使用方法如下: - -1、 使能ptdbg的溢出检测能力。import工具并加上以下代码: - -debugger = PrecisionDebugger(dump_path="./dump_overflow_path", hook_name="overflow_check") - -关键参数如下: - -dump_path:配置数据落盘的路径,必须提前创建 - -hook_name:必须设置为"overflow_check" - -2、 加入启动工具开关代码 - -溢出检测功能也需要用户模型初始化之后或在训练迭代中配置工具开关: - -启动开关:PrecisionDebugger.start() 或 debugger.start() - -关闭开关:PrecisionDebugger.stop() 或 debugger.stop() - -3、 运行训练脚本,检测溢出。 - -工具默认会在检测到1次溢出之后退出训练,将数据保存到相应目录下。 - -用户可以配置debugger.configure_hook(overflow_nums=-1)来告诉工具在检测到溢出后不退出,这样会检测无限次溢出。在这种场景下也可以在debugger构造时传入step和enable_dataloader等参数来把不同迭代发生的溢出数据存到不同文件夹中。 - -4、 溢出检测生成的数据 - -溢出数据同样包括了一个pkl文件和一个保存npy数据的文件夹。其中Overflow_info开头这个pkl保存的是溢出api的简略信息(包括最大最小值等,与dump数据时的pkl格式一致),文件夹中保存的是溢出api的npy数据。 \ No newline at end of file +**PyTorch精度工具溢出检测功能**是在判断训练网络可能存在溢出现象时,例如某个step的loss突然变成inf nan,或者混精场景下loss_scale不断减小,可以通过ptdbg_ascend的精度检测工具检测API的溢出情况。具体使用请参见《[ptdbg_ascend精度工具功能说明](https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend/doc)》。 \ No newline at end of file diff --git a/profiler/README.md b/profiler/README.md index a406d47b5e26ad0a011c6395dda40299fc04137b..44666e7434ac0a80dee94bb8663b7616b72fdf5e 100644 --- a/profiler/README.md +++ b/profiler/README.md @@ -1,19 +1,16 @@ # 性能工具 +ATT工具针对训练&大模型场景,提供端到端调优工具:用户采集到性能数据后,由ATT工具提供统计、分析以及相关的调优建议。 -## 介绍 -ATT仓针对训练&大模型场景,提供端到端调优工具:用户采集到profiling后,由att仓提供统计、分析以及相关的调优建议。 +### Profiling采集 +目前ATT工具主要支持Ascend PyTorch Profiler接口的性能数据采集,请参见《[Ascend PyTorch Profiler性能调优工具介绍](https://gitee.com/ascend/att/wikis/%E6%A1%88%E4%BE%8B%E5%88%86%E4%BA%AB/%E6%80%A7%E8%83%BD%E6%A1%88%E4%BE%8B/Ascend%20PyTorch%20Profiler%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D)》。 -### profiling采集 -目前att仓工具主要支持Ascend PyTorch Profiler采集工具,请参见《[Ascend PyTorch Profiler性能调优工具介绍](https://gitee.com/ascend/att/wikis/%E6%A1%88%E4%BE%8B%E5%88%86%E4%BA%AB/%E6%80%A7%E8%83%BD%E6%A1%88%E4%BE%8B/Ascend%20PyTorch%20Profiler%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D)》。 - -Ascend PyTorch Profiler采集工具支持AscendPyTorch 5.0.RC2或更高版本,支持的PyThon和CANN软件版本配套关系请参见《CANN软件安装指南》中的“[安装PyTorch](https://www.hiascend.com/document/detail/zh/canncommercial/63RC2/envdeployment/instg/instg_000041.html)”。 +Ascend PyTorch Profiler接口支持AscendPyTorch 5.0.RC2或更高版本,支持的PyThon和CANN软件版本配套关系请参见《CANN软件安装指南》中的“[安装PyTorch](https://www.hiascend.com/document/detail/zh/canncommercial/63RC2/envdeployment/instg/instg_000041.html)”。 ### 子功能介绍 -| 工具名称 | 说明 | -| ------------ | ------------------------------------------------------------ | -| [性能比对工具](https://gitee.com/ascend/att/tree/master/profiler/compare_tools) |提供NPU与GPU性能拆解功能以及算子、通信、内存性能的比较功能。 | -| [集群分析工具](https://gitee.com/ascend/att/tree/master/profiler/cluster_analyse) | 提供多机多卡的集群分析能力(基于通信域的通信分析和迭代耗时分析)。 | -| [合并timeline工具](https://gitee.com/ascend/att/tree/master/profiler/merge_profiling_timeline) | 融合多个profiling的timeline在一个json文件中的功能。 | -| [数据汇聚工具](https://gitee.com/ascend/att/tree/master/profiler/distribute_tools) | 提供集群场景数据一键汇聚功能。 | - +| 工具名称 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [compare_tools(性能比对工具)](https://gitee.com/ascend/att/tree/master/profiler/compare_tools) | 提供NPU与GPU性能拆解功能以及算子、通信、内存性能的比对功能。 | +| [cluster_analyse(集群分析工具)](https://gitee.com/ascend/att/tree/master/profiler/cluster_analyse) | 提供多机多卡的集群分析能力(基于通信域的通信分析和迭代耗时分析), 当前需要配合Ascend Insight的集群分析功能使用。 | +| [merge_profiling_timeline(合并大json工具)](https://gitee.com/ascend/att/tree/master/profiler/merge_profiling_timeline) | 融合多个Profiling的timeline在一个json文件中的功能。 | +| [distribute_tools(集群场景脚本集合工具)](https://gitee.com/ascend/att/tree/master/profiler/distribute_tools) | 提供集群场景数据一键汇聚功能。 |