文档首页/
AI开发平台ModelArts/
最佳实践/
LLM大语言模型训练/
LLM大语言模型训练历史版本文档/
主流开源大模型基于Lite Server适配LlamaFactory PyTorch NPU训练指导(6.5.901)/
准备工作/
准备代码
更新时间:2025-07-29 GMT+08:00
准备代码
本教程中用到的训练、推理代码如下表所示,请提前准备好。
获取模型软件包和权重文件
模型软件包结构说明
本教程需要使用到的AscendCloud-6.5.901中的AscendCloud-LLM-xxx.zip软件包和算子包AscendCloud-OPP,AscendCloud-LLM关键文件介绍如下。
|——AscendCloud-LLM |──llm_train # 模型训练代码包 |──AscendFactory |──examples/ # config配置文件目录 |──data.tgz # 样例数据压缩包 |──third-party/ # patch包 |──src/acs_train_solution/ # 训练运行包 |──intall.sh # 需要的依赖包 |──scripts_llamafactory/ # llamafactory兼容旧版本启动方式目录 |──scripts_modellink/ # modelLink兼容旧版本启动方式目录 |──Dockerfile
工作目录介绍
详细的工作目录参考如下,根据实际要求设置。
${workdir}(例如/home/ma-user/ws) |──llm_train # 模型训练代码包 |──AscendFactory |──examples/ # config配置文件目录 |──config/ # 配置文件 |──deepspeed/ # deepspeed配置json文件 |──performance_cfgs.yaml # 微调性能配置json文件 |──llama_factory_performance_cfgs_VL.yaml # qwen2vl微调json文件 |──accuracy_cfgs.yaml # 训练精度配置json文件 |──....... |──data.tgz # 样例数据压缩包 |──intall.sh # 需要的依赖包 |──scripts_llamafactory/ # 兼容旧版本启动方式目录 |──tools/ # 针对昇腾云平台适配的功能补丁包 |──demo.yaml # 样例yaml配置文件 |──demo.sh # 训练启动shell脚本 |──merge_lora_cli.sh # lora权重合并脚本 |──third-party/ # patch包 |──src/acs_train_solution/ # 训练运行包 |──ascendcloud_patch/ # patch补丁包 |──benchmark/ #工具包,存放数据集及基线数据 |──trainer.py # 训练启动脚本 |──performance.py # 训练性能比较启动脚本 |──accuracy.py # 训练精度启动脚本 |──model/Qwen2-7B/ # 权重词表文件目录,如Qwen2-7B |──saves/qwen2-7b/sft_lora/ # 训练完成生成目录Qwen2-7B,自动生成
上传代码和权重文件到工作环境
- 使用root用户以SSH的方式登录Server。
- 将AscendCloud代码包AscendCloud-xxx-xxx.zip上传到${workdir}目录下并解压缩,如:/home/ma-user/ws目录下,以下都以/home/ma-user/ws为例,请根据实际修改。
unzip AscendCloud-*.zip unzip AscendCloud-LLM-*.zip
- 上传tokenizers文件到工作目录中的/home/ma-user/ws/model/{Model_Name}目录,用户根据自己实际规划路径修改;如Qwen2-72B。
进入到${workdir}目录下,如:/home/ma-user/ws,创建tokenizers文件目录将权重和词表文件放置此处,以Qwen2-72B为例。
cd /home/ma-user/ws mkdir -p model/Qwen2-72B
- 修改权重文件:以下模型需修改,根据所选框架及模型修改相应文件,详情参考各个模型训练前文件替换
- Llama-Factory:falcon-11B、GLMv4-9B、MiniCPM-2B、MiniCPM3-4B
父主题: 准备工作