# MindSpeed-Megatron-UT **Repository Path**: glhyy/Mindspeed-Megatron-UT ## Basic Information - **Project Name**: MindSpeed-Megatron-UT - **Description**: megatron用例迁移到mindspeed - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-18 - **Last Updated**: 2025-04-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MindSpeed-Megatron-UT ## 介绍 [MindSpeed-Megatron-UT代码地址](https://gitee.com/glhyy/Mindspeed-Megatron-UT) 将Megatron main分支UT用例迁移到Mindspeed+NPU环境跑每日流水 ## 迁移步骤 - step1:准备需要用到的数据:`/home/mgutdata/`,下面包含megatron UT用例需要的一些数据,在xx.xx.xx.xx机器上有。 - step2:`git clone https://gitee.com/glhyy/Mindspeed-Megatron-UT.git`。 - step3:修改`runmgut.sh`中的内容: ```shell # 这里修改代理以确保网络能正常git clone需要的仓库代码 export http_proxy="http://xx.xx.xx.xx:xxxx" export https_proxy="http://xx.xx.xx.xx:xxxx" export no_proxy=127.0.0.1,.huawei.com,localhost,local,.local # 修改这里以准备运行环境 source /root/.bashrc conda activate mstestpy310 source /home/xxx/pckg/rc4b080/ascend-toolkit/set_env.sh source /home/xxx/pckg/rc4b080/nnal/atb/set_env.sh ``` - step4:修改适配`commands.yml`中的内容。需要根据megatron和mindspeed代码演进每日动态监控用例运行情况,需要特殊适配的用例在commands.yml中适配想要命令,后面详述该文件内容。 - step5:`bash runmgut.sh` 每日流水运行完之后会生成日志信息,在`logs`下面,通过小鲁班插件每日下载解析日志并群发通知。 ## 说明 `runmgut.sh`内容步骤说明: 1. 准备网络和环境 ```shell export http_proxy="http://xx.xx.xx.xx:xxxx" export https_proxy="http://xx.xx.xx.xx:xxxx" export no_proxy=127.0.0.1,.huawei.com,localhost,local,.local source /root/.bashrc conda activate mstestpy310 source /home/xxx/pckg/rc4b080/ascend-toolkit/set_env.sh source /home/xxx/pckg/rc4b080/nnal/atb/set_env.sh ``` 2. 准备megatron代码并备份旧代码 ```shell rm -rf Megatron-LM_last mv Megatron-LM_now Megatron-LM_last rm -rf Megatron-LM git clone https://github.com/NVIDIA/Megatron-LM.git cp -rf Megatron-LM Megatron-LM_now ``` 3. 准备mindspeed代码 ```shell rm -rf MindSpeed git clone https://gitee.com/ascend/MindSpeed.git ``` 4. 检查megatron代码更新情况并记录。日志路径见传参路径。 ```shell dt=$(date '+%Y%m%d') python check_mgut_update.py Megatron-LM_last Megatron-LM tests/unit_tests "./logs/mg_update/ut_chgs_$dt.txt" cp -rf ./logs/mg_update/ut_chgs_$dt.txt ./logs/mg_update/ut_chgs.txt python check_mgut_update.py Megatron-LM_last Megatron-LM megatron "./logs/mg_update/mg_chgs_$dt.txt" cp -rf ./logs/mg_update/mg_chgs_$dt.txt ./logs/mg_update/mg_chgs.txt python check_args_update.py Megatron-LM_last Megatron-LM "./logs/mg_update/args_chgs_$dt.txt" cp -rf ./logs/mg_update/args_chgs_$dt.txt ./logs/mg_update/args_chgs.txt ``` 5. 用例执行 ```shell cp -rf MindSpeed/mindspeed ./Megatron-LM/ cp commands.yml exemgut.py ./Megatron-LM/ cd Megatron-LM python exemgut.py ``` 执行用例之前需要根据megatron代码演进监控情况动态修改适配commands.yml文件,文件内容格式如下: ```yaml scripts: tests/unit_tests/data/test_bin_reader.py: prepare: - mkdir -p /home/gitlab-runner/data/gpt3_data/ - cp -rf /home/mgutdata/gpt3_data/* /home/gitlab-runner/data/gpt3_data/ nproc_per_node: 1 ignores: tests/unit_tests/test_utilities.py: util ``` - ignores:需要忽略,不用执行的用例脚本 - scripts:需要修改源码或者运行特殊配置的用例脚本 - prepare:运行该用例需要做的准备工作,比如准备数据,修改代码,命令都写在prepare下面,执行用例的时候会先执行这些命令 - nproc_pre_node:运行卡数,默认用8卡,有些用例8卡会报错,在这里设置卡数 6. 用例执行日志结果解析,统计。日志结果存放在logs/utresult下面,小鲁班插件可直接下载日志。 ```shell cd .. python utlogparse.py ```