共 13 个文件变更+33-48
| @@ -482,8 +482,6 @@ MindSpeed-LLM作为昇腾大模型训练框架,旨在为华为 [昇腾芯片]( | |||
| 482 | </table> | 482 | </table> |
| 483 | 483 | ||
| 484 | 484 | ||
| 485 | - | ||
| 486 | - | ||
| 487 | 【偏好对齐特性】 | 485 | 【偏好对齐特性】 |
| 488 | 486 | ||
| 489 | <table><thead> | 487 | <table><thead> |
| @@ -115,9 +115,7 @@ pip install -r requirements.txt | |||
| 115 | 115 | ||
| 116 | 从Huggingface等网站下载开源模型权重 | 116 | 从Huggingface等网站下载开源模型权重 |
| 117 | 117 | ||
| 118 | -预训练权重链接在 [MindSpeed-LLM 预置大模型](./models/pretrain.md/#mindspeed-llm-预置模型) 章节列表的`参数`列链接中可以获取 | 118 | +预训练权重链接在 [MindSpeed-LLM 预置大模型](./models/pretrain.md/#mindspeed-llm-预置模型) 章节列表的`参数`列链接中可以获取;更多社区资源可以在`模型`列链接中获取,如`Chat/Instruct`权重等。 |
| 119 | - | ||
| 120 | -更多社区资源可以在`模型`列链接中获取,如`Chat/Instruct`权重等 | ||
| 121 | 119 | ||
| 122 | 权重可以基于网页直接下载,也可以基于命令行下载,保存到MindSpeed-LLM/model_from_hf目录,比如: | 120 | 权重可以基于网页直接下载,也可以基于命令行下载,保存到MindSpeed-LLM/model_from_hf目录,比如: |
| 123 | 121 | ||
| @@ -143,9 +141,6 @@ cd ../../ | |||
| 143 | ##### 2.1 Huggingface权重转换到Megatron-LM格式 | 141 | ##### 2.1 Huggingface权重转换到Megatron-LM格式 |
| 144 | 142 | ||
| 145 | ```shell | 143 | ```shell |
| 146 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 147 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 148 | - | ||
| 149 | python convert_ckpt.py \ | 144 | python convert_ckpt.py \ |
| 150 | --model-type GPT \ | 145 | --model-type GPT \ |
| 151 | --load-model-type hf \ | 146 | --load-model-type hf \ |
| @@ -216,9 +211,6 @@ bash examples/mcore/llama2/ckpt_convert_llama2_hf2mcore.sh | |||
| 216 | ##### 2.2 Megatron-LM权重转换到Huggingface格式 | 211 | ##### 2.2 Megatron-LM权重转换到Huggingface格式 |
| 217 | 212 | ||
| 218 | ```shell | 213 | ```shell |
| 219 | -# 请按照您的真实环境 soure set_env.sh 环境变量 | ||
| 220 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 221 | - | ||
| 222 | python convert_ckpt.py \ | 214 | python convert_ckpt.py \ |
| 223 | --model-type GPT \ | 215 | --model-type GPT \ |
| 224 | --load-model-type mg \ | 216 | --load-model-type mg \ |
| @@ -254,9 +246,6 @@ bash examples/mcore/llama2/ckpt_convert_llama2_mcore2hf.sh | |||
| 254 | ##### 2.3 Megatron-LM格式权重互转 | 246 | ##### 2.3 Megatron-LM格式权重互转 |
| 255 | 247 | ||
| 256 | ```shell | 248 | ```shell |
| 257 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 258 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 259 | - | ||
| 260 | # legacy转legacy | 249 | # legacy转legacy |
| 261 | python convert_ckpt.py \ | 250 | python convert_ckpt.py \ |
| 262 | --model-type GPT \ | 251 | --model-type GPT \ |
| @@ -319,12 +308,16 @@ mcore转legacy时设置此参数以指定保存权重格式为legacy | |||
| 319 | 在上述权重转换命令中,加入如下参数可以将训练的lora权重与base进行融合。 | 308 | 在上述权重转换命令中,加入如下参数可以将训练的lora权重与base进行融合。 |
| 320 | 309 | ||
| 321 | ```bash | 310 | ```bash |
| 322 | ---lora-load ${CHECKPOINT_LORA} \ | 311 | +--lora-load ./ckpt/llama-2-7b-lora \ |
| 323 | --lora-r 16 \ | 312 | --lora-r 16 \ |
| 324 | --lora-alpha 32 \ | 313 | --lora-alpha 32 \ |
| 325 | --lora-target-modules query_key_value dense dense_h_to_4h dense_4h_to_h \ | 314 | --lora-target-modules query_key_value dense dense_h_to_4h dense_4h_to_h \ |
| 326 | ``` | 315 | ``` |
| 327 | 316 | ||
| 317 | +【lora-load】 | ||
| 318 | + | ||
| 319 | +`--lora-load`为lora权重路径,lora微调权重可通过lora微调(见低参微调章节)保存,在此处加载 | ||
| 320 | + | ||
| 328 | 【lora-r】 | 321 | 【lora-r】 |
| 329 | 322 | ||
| 330 | `--lora_r`参数指的是LoRA中的秩(rank),它决定了低秩矩阵的大小。 | 323 | `--lora_r`参数指的是LoRA中的秩(rank),它决定了低秩矩阵的大小。 |
| @@ -340,9 +333,6 @@ mcore转legacy时设置此参数以指定保存权重格式为legacy | |||
| 340 | 【合并后转换为Megatron-Legacy权重】 | 333 | 【合并后转换为Megatron-Legacy权重】 |
| 341 | 334 | ||
| 342 | ```shell | 335 | ```shell |
| 343 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 344 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 345 | - | ||
| 346 | python convert_ckpt.py \ | 336 | python convert_ckpt.py \ |
| 347 | --model-type GPT \ | 337 | --model-type GPT \ |
| 348 | --load-model-type mg \ | 338 | --load-model-type mg \ |
| @@ -367,9 +357,6 @@ bash examples/legacy/llama2/ckpt_convert_llama2_legacy2legacy_lora.sh | |||
| 367 | 【合并后转换为Huggingface权重】 | 357 | 【合并后转换为Huggingface权重】 |
| 368 | 358 | ||
| 369 | ```shell | 359 | ```shell |
| 370 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 371 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 372 | - | ||
| 373 | python convert_ckpt.py \ | 360 | python convert_ckpt.py \ |
| 374 | --model-type GPT \ | 361 | --model-type GPT \ |
| 375 | --load-model-type mg \ | 362 | --load-model-type mg \ |
| @@ -426,13 +413,9 @@ cd .. | |||
| 426 | ##### 2.1 预训练数据集处理方法 | 413 | ##### 2.1 预训练数据集处理方法 |
| 427 | 414 | ||
| 428 | ```shell | 415 | ```shell |
| 429 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 430 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 431 | -mkdir ./dataset | ||
| 432 | - | ||
| 433 | python ./preprocess_data.py \ | 416 | python ./preprocess_data.py \ |
| 434 | --input ./dataset/train-00000-of-00042-d964455e17e96d5a.parquet \ | 417 | --input ./dataset/train-00000-of-00042-d964455e17e96d5a.parquet \ |
| 435 | - --tokenizer-name-or-path ./model_from_hf/llama-2-hf \ | 418 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf \ |
| 436 | --tokenizer-type PretrainedFromHF \ | 419 | --tokenizer-type PretrainedFromHF \ |
| 437 | --handler-name GeneralPretrainHandler \ | 420 | --handler-name GeneralPretrainHandler \ |
| 438 | --output-prefix ./dataset/enwiki \ | 421 | --output-prefix ./dataset/enwiki \ |
| @@ -501,8 +484,6 @@ cd .. | |||
| 501 | 在指令监督微调时,instruction 列对应的内容会与 input 列对应的内容拼接后作为人类指令,即人类指令为 instruction\ninput。而 output 列对应的内容为模型回答。如果指定了history,则会将历史对话内容也加入进来。如果指定system 列,则对应的内容将被作为系统提示词。 | 484 | 在指令监督微调时,instruction 列对应的内容会与 input 列对应的内容拼接后作为人类指令,即人类指令为 instruction\ninput。而 output 列对应的内容为模型回答。如果指定了history,则会将历史对话内容也加入进来。如果指定system 列,则对应的内容将被作为系统提示词。 |
| 502 | 485 | ||
| 503 | ```shell | 486 | ```shell |
| 504 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 505 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 506 | mkdir ./finetune_dataset | 487 | mkdir ./finetune_dataset |
| 507 | 488 | ||
| 508 | python ./preprocess_data.py \ | 489 | python ./preprocess_data.py \ |
| @@ -612,8 +593,6 @@ cd .. | |||
| 612 | ``` | 593 | ``` |
| 613 | Sharegpt格式数据预处理脚本: | 594 | Sharegpt格式数据预处理脚本: |
| 614 | ```shell | 595 | ```shell |
| 615 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 616 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 617 | mkdir ./finetune_dataset | 596 | mkdir ./finetune_dataset |
| 618 | 597 | ||
| 619 | python ./preprocess_data.py \ | 598 | python ./preprocess_data.py \ |
| @@ -664,8 +643,6 @@ OpenAI格式示例: | |||
| 664 | OpenAI格式数据预处理脚本: | 643 | OpenAI格式数据预处理脚本: |
| 665 | 644 | ||
| 666 | ```shell | 645 | ```shell |
| 667 | -# 请按照您的真实环境 source set_env.sh 环境变量 | ||
| 668 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 669 | mkdir ./finetune_dataset | 646 | mkdir ./finetune_dataset |
| 670 | 647 | ||
| 671 | python ./preprocess_data.py \ | 648 | python ./preprocess_data.py \ |
| @@ -1073,7 +1050,7 @@ bash examples/mcore/llama2/generate_llama2_7b_ptd.sh | |||
| 1073 | ```shell | 1050 | ```shell |
| 1074 | # 按实际情况修改启动脚本中模型权重路径和分词器路径 | 1051 | # 按实际情况修改启动脚本中模型权重路径和分词器路径 |
| 1075 | CHECKPOINT="./model_weights/llama-2-7b-legacy" | 1052 | CHECKPOINT="./model_weights/llama-2-7b-legacy" |
| 1076 | -TOKENIZER_PATH="./model_from_hf/llama-2-hf/" | 1053 | +TOKENIZER_PATH="./model_from_hf/llama-2-7b-hf/" |
| 1077 | 1054 | ||
| 1078 | # 启动任务(以 legacy 为例) | 1055 | # 启动任务(以 legacy 为例) |
| 1079 | bash examples/legacy/llama2/generate_llama2_7b_ptd.sh | 1056 | bash examples/legacy/llama2/generate_llama2_7b_ptd.sh |
| @@ -1154,9 +1131,6 @@ bash examples/legacy/llama2/evaluate_llama2_7B_lora_ptd.sh | |||
| 1154 | ``` | 1131 | ``` |
| 1155 | 1132 | ||
| 1156 | ```shell | 1133 | ```shell |
| 1157 | -#请根据实际路径 source set_env.sh 环境变量 | ||
| 1158 | -source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 1159 | - | ||
| 1160 | # 修改模型参数路径和词表路径 | 1134 | # 修改模型参数路径和词表路径 |
| 1161 | TOKENIZER_PATH="./model_from_hf/llama-2-hf/" #词表路径 | 1135 | TOKENIZER_PATH="./model_from_hf/llama-2-hf/" #词表路径 |
| 1162 | CHECKPOINT="./model_weights/llama-2-7b-legacy" #权重路径 | 1136 | CHECKPOINT="./model_weights/llama-2-7b-legacy" #权重路径 |
| @@ -85,4 +85,4 @@ bash examples/legacy/llama3/data_convert_llama3_pairwise.sh | |||
| 85 | ./pairwise_dataset/orca_rlhf_llama3_packed_rejected_labels_document.idx | 85 | ./pairwise_dataset/orca_rlhf_llama3_packed_rejected_labels_document.idx |
| 86 | ``` | 86 | ``` |
| 87 | 87 | ||
| 88 | -DPO或SimPO时,数据集路径输入 `./pairwise_dataset/orca_rlhf_llama3` 即可,同时须设置`--is-pairwise-dataset`参数 | 88 | +进行DPO或SimPO训练任务时,数据集路径输入 `./pairwise_dataset/orca_rlhf_llama3` 即可,同时须设置`--is-pairwise-dataset`参数 |
| @@ -8,7 +8,7 @@ python convert_ckpt.py \ | |||
| 8 | --save-model-type mg \ | 8 | --save-model-type mg \ |
| 9 | --target-tensor-parallel-size 1 \ | 9 | --target-tensor-parallel-size 1 \ |
| 10 | --target-pipeline-parallel-size 2 \ | 10 | --target-pipeline-parallel-size 2 \ |
| 11 | - --load-dir ./model_from_hf/llama-2-hf/ \ | 11 | + --load-dir ./model_from_hf/llama-2-7b-hf/ \ |
| 12 | --save-dir ./model_weights/llama-2-legacy/ \ | 12 | --save-dir ./model_weights/llama-2-legacy/ \ |
| 13 | - --tokenizer-model ./model_from_hf/llama-2-hf/tokenizer.model \ | 13 | + --tokenizer-model ./model_from_hf/llama-2-7b-hf/tokenizer.model \ |
| 14 | --model-type-hf llama2 | 14 | --model-type-hf llama2 |
| @@ -8,8 +8,8 @@ python convert_ckpt.py \ | |||
| 8 | --save-model-type mg \ | 8 | --save-model-type mg \ |
| 9 | --target-tensor-parallel-size 1 \ | 9 | --target-tensor-parallel-size 1 \ |
| 10 | --target-pipeline-parallel-size 2 \ | 10 | --target-pipeline-parallel-size 2 \ |
| 11 | - --load-dir ./model_from_hf/Llama2-hf/ \ | 11 | + --load-dir ./model_from_hf/llama-2-7b-hf/ \ |
| 12 | --save-dir ./model_weights/Llama2-mcore/ \ | 12 | --save-dir ./model_weights/Llama2-mcore/ \ |
| 13 | - --tokenizer-model ./model_from_hf/Llama2-hf/tokenizer.model \ | 13 | + --tokenizer-model ./model_from_hf/llama-2-7b-hf/tokenizer.model \ |
| 14 | --use-mcore-models \ | 14 | --use-mcore-models \ |
| 15 | --model-type-hf llama2 | 15 | --model-type-hf llama2 |
| @@ -0,0 +1,13 @@ | |||
| 1 | +# 修改 ascend-toolkit 路径 | ||
| 2 | +source /usr/local/Ascend/ascend-toolkit/set_env.sh | ||
| 3 | + | ||
| 4 | +# 权重格式转换,设置需要的并行配置,--num-layers-per-virtual-pipeline-stage 5,--params-dtype bf16 结合需要使用 | ||
| 5 | +python convert_ckpt.py \ | ||
| 6 | + --model-type GPT \ | ||
| 7 | + --load-model-type mg \ | ||
| 8 | + --save-model-type hf \ | ||
| 9 | + --target-tensor-parallel-size 1 \ | ||
| 10 | + --target-pipeline-parallel-size 1 \ | ||
| 11 | + --load-dir ./model_weights/Llama2-mcore/ \ | ||
| 12 | + --save-dir ./model_from_hf/llama-2-7b-hf/ \ | ||
| 13 | + --use-mcore-models | ||
| @@ -5,7 +5,7 @@ mkdir ./finetune_dataset | |||
| 5 | 5 | ||
| 6 | python ./preprocess_data.py \ | 6 | python ./preprocess_data.py \ |
| 7 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ | 7 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ |
| 8 | - --tokenizer-name-or-path ./model_from_hf/Llama2-hf/ \ | 8 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf/ \ |
| 9 | --output-prefix ./finetune_dataset/alpaca \ | 9 | --output-prefix ./finetune_dataset/alpaca \ |
| 10 | --workers 4 \ | 10 | --workers 4 \ |
| 11 | --log-interval 1000 \ | 11 | --log-interval 1000 \ |
| @@ -5,7 +5,7 @@ mkdir ./finetune_dataset | |||
| 5 | 5 | ||
| 6 | python ./preprocess_data.py \ | 6 | python ./preprocess_data.py \ |
| 7 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ | 7 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ |
| 8 | - --tokenizer-name-or-path ./model_from_hf/Llama2-hf/ \ | 8 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf/ \ |
| 9 | --output-prefix ./finetune_dataset/alpaca \ | 9 | --output-prefix ./finetune_dataset/alpaca \ |
| 10 | --workers 4 \ | 10 | --workers 4 \ |
| 11 | --log-interval 1000 \ | 11 | --log-interval 1000 \ |
| @@ -6,7 +6,7 @@ python ./preprocess_data.py \ | |||
| 6 | --input ./dataset/orca_rlhf.jsonl \ | 6 | --input ./dataset/orca_rlhf.jsonl \ |
| 7 | --tokenizer-type PretrainedFromHF \ | 7 | --tokenizer-type PretrainedFromHF \ |
| 8 | --tokenizer-not-use-fast \ | 8 | --tokenizer-not-use-fast \ |
| 9 | - --tokenizer-name-or-path ./model_from_hf/Llama2-hf/ \ | 9 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf/ \ |
| 10 | --output-prefix ./dataset/orca_rlhf \ | 10 | --output-prefix ./dataset/orca_rlhf \ |
| 11 | --workers 4 \ | 11 | --workers 4 \ |
| 12 | --log-interval 1000 \ | 12 | --log-interval 1000 \ |
| @@ -4,7 +4,7 @@ mkdir ./dataset | |||
| 4 | 4 | ||
| 5 | python ./preprocess_data.py \ | 5 | python ./preprocess_data.py \ |
| 6 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ | 6 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ |
| 7 | - --tokenizer-name-or-path ./model_from_hf/Llama2-hf/ \ | 7 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf/ \ |
| 8 | --tokenizer-type PretrainedFromHF \ | 8 | --tokenizer-type PretrainedFromHF \ |
| 9 | --handler-name GeneralPretrainHandler \ | 9 | --handler-name GeneralPretrainHandler \ |
| 10 | --output-prefix ./dataset/enwiki \ | 10 | --output-prefix ./dataset/enwiki \ |
| @@ -4,7 +4,7 @@ mkdir ./dataset | |||
| 4 | 4 | ||
| 5 | python ./preprocess_data.py \ | 5 | python ./preprocess_data.py \ |
| 6 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ | 6 | --input ./dataset/train-00000-of-00001-a09b74b3ef9c3b56.parquet \ |
| 7 | - --tokenizer-name-or-path ./model_from_hf/Llama2-hf/ \ | 7 | + --tokenizer-name-or-path ./model_from_hf/llama-2-7b-hf/ \ |
| 8 | --tokenizer-type PretrainedFromHF \ | 8 | --tokenizer-type PretrainedFromHF \ |
| 9 | --handler-name GeneralPretrainHandler \ | 9 | --handler-name GeneralPretrainHandler \ |
| 10 | --output-prefix ./dataset/enwiki \ | 10 | --output-prefix ./dataset/enwiki \ |
| @@ -11,7 +11,7 @@ WORLD_SIZE=$(($NPUS_PER_NODE*$NNODES)) | |||
| 11 | CKPT_SAVE_DIR="your model save ckpt path" | 11 | CKPT_SAVE_DIR="your model save ckpt path" |
| 12 | DATA_PATH="your data path" | 12 | DATA_PATH="your data path" |
| 13 | TOKENIZER_MODEL="your tokenizer path" | 13 | TOKENIZER_MODEL="your tokenizer path" |
| 14 | -CKPT_LOAD_DIR="your model save ckpt path" | 14 | +CKPT_LOAD_DIR="your model load ckpt path" |
| 15 | TP=1 | 15 | TP=1 |
| 16 | PP=8 | 16 | PP=8 |
| 17 | 17 | ||
| @@ -100,7 +100,7 @@ RL_ARGS=" | |||
| 100 | --is-pairwise-dataset | 100 | --is-pairwise-dataset |
| 101 | " | 101 | " |
| 102 | 102 | ||
| 103 | -torchrun $DISTRIBUTED_ARGS trainer.py \ | 103 | +torchrun $DISTRIBUTED_ARGS posttrain_gpt.py \ |
| 104 | $GPT_ARGS \ | 104 | $GPT_ARGS \ |
| 105 | $DATA_ARGS \ | 105 | $DATA_ARGS \ |
| 106 | $OUTPUT_ARGS \ | 106 | $OUTPUT_ARGS \ |