-
Notifications
You must be signed in to change notification settings - Fork 2.2k
【fleet】support Dpo lora #3617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
【fleet】support Dpo lora #3617
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ea32c0c
glm test
xiaoguoguo626807 7cda94f
uodate
xiaoguoguo626807 43e0b46
fix conflict
xiaoguoguo626807 a40381c
update dpo-lora and qwenvl3 lora
xiaoguoguo626807 e1a6d2f
Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleForme…
xiaoguoguo626807 239f45f
fix conflict
xiaoguoguo626807 0115abf
fix
xiaoguoguo626807 f822ae7
update loss
xiaoguoguo626807 0c7d2dd
update loss
xiaoguoguo626807 c27546e
add dpo lora ci
xiaoguoguo626807 3e1255f
fix test load path
xiaoguoguo626807 fa940a0
Merge commit 'refs/pull/3636/head' of https://github.com/PaddlePaddle…
xiaoguoguo626807 33b20e3
fix qwen3vl
xiaoguoguo626807 bf7e830
fallback qwen3_vl_moe lora
xiaoguoguo626807 b84ae4d
delete print
xiaoguoguo626807 59e51f2
Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleForme…
xiaoguoguo626807 43f8d3a
fix conflict and change ckp
xiaoguoguo626807 66fc8c0
fix yaml
xiaoguoguo626807 c4254f2
fix confilict
xiaoguoguo626807 6ac56e2
modify step
xiaoguoguo626807 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| ### data | ||
| train_dataset_type: erniekit | ||
| eval_dataset_type: erniekit | ||
| train_dataset_path: ./dpo_train.jsonl | ||
| train_dataset_prob: "1.0" | ||
| eval_dataset_path: ./dpo_eval.jsonl | ||
| eval_dataset_prob: "1.0" | ||
| max_seq_len: 2048 | ||
| packing: true | ||
| mix_strategy: concat | ||
|
|
||
| ### model | ||
| model_name_or_path: zai-org/GLM-4.5-Air-Base/ | ||
| #attn_impl: sdpa | ||
| attn_impl: flashmask | ||
|
|
||
| ### finetuning | ||
| # base | ||
| stage: DPO | ||
| params_dtype: bfloat16 | ||
| fine_tuning: lora | ||
| seed: 23 | ||
| bf16: true | ||
| fp16_opt_level: O2 | ||
| do_train: true | ||
| do_eval: true | ||
| per_device_eval_batch_size: 1 | ||
| per_device_train_batch_size: 1 | ||
| num_train_epochs: 1 | ||
| #use_attn_mask_startend_row_indices: false | ||
| use_attn_mask_startend_row_indices: true | ||
| #tensor_model_parallel_size: 2 | ||
| max_steps: 10 | ||
| eval_steps: 100000 | ||
| evaluation_strategy: steps | ||
| #pipeline_model_parallel_size: 1 | ||
| continue_training: true | ||
| save_steps: 100000 | ||
| save_strategy: steps | ||
| logging_steps: 1 | ||
| gradient_accumulation_steps: 4 | ||
| logging_dir: ./vdl_log | ||
| output_dir: ./checkpoints/glm4_hf_dpo_lora_ckpts | ||
| disable_tqdm: true | ||
| eval_accumulation_steps: 16 | ||
| tensor_model_parallel_size: 4 | ||
| pipeline_model_parallel_size: 2 | ||
| expert_model_parallel_size: 4 | ||
| use_expert_parallel: true | ||
| sequence_parallel: true | ||
|
|
||
| moe_group: mp | ||
| moe_token_dispatcher_type: "deepep" | ||
| gated_linear_unit: true | ||
| hidden_dropout_prob: 0.0 | ||
| attention_dropout: 0.0 | ||
| recompute_granularity: "" | ||
| amp_master_grad: true | ||
|
|
||
| # train | ||
| warmup_steps: 20 | ||
| learning_rate: 1.0e-5 | ||
| save_checkpoint_format: flex_checkpoint | ||
| load_checkpoint_format: flex_checkpoint | ||
| moe_router_force_load_balancing: false | ||
| clear_every_step_cache: true | ||
| partial_send_recv: false | ||
| #use_cpu_initialization: true | ||
| fuse_attention_qkv: true | ||
| fuse_attention_ffn: true | ||
|
|
||
| num_hidden_layers: 3 | ||
| num_empty_layers_add_in_tail: 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -exo pipefail | ||
| export root_dir=$(pwd) | ||
|
|
||
| if [ -f 'PaddleFleet/.venv/bin/activate' ]; then | ||
| source PaddleFleet/.venv/bin/activate | ||
| fi | ||
|
|
||
| cd $root_dir/glm45_fleet | ||
| export cur_dir=$(pwd) | ||
|
|
||
| # prepare dpo data | ||
| wget https://paddle-qa.bj.bcebos.com/fleet/fleet_dpo.tar | ||
| tar -xf fleet_dpo.tar | ||
|
|
||
| config_dpo_yaml=$root_dir/PaddleFormers/tests/config/ci/glm45_dpo_lora.yaml | ||
|
|
||
| config_json=$CACHE_DIR/glm45/GLM-4.5-Air/config.json | ||
|
|
||
| yq '.train_dataset_path = strenv(cur_dir) + "/dpo_data/dpo_train.jsonl" | ||
| | .eval_dataset_path = strenv(cur_dir) + "/dpo_data/dpo_eval.jsonl" | ||
| | .model_name_or_path = strenv(CACHE_DIR) + "/zai-org/GLM-4.5-Air-Base" | ||
| | .logging_dir = strenv(cur_dir) + "/glm_full_dpo_lora_vdl_log" | ||
| | .output_dir = strenv(cur_dir) + "/checkpoints/glm_full_dpo_lora_ckpts"' \ | ||
| $config_dpo_yaml > ${config_dpo_yaml}.tmp | ||
| mv ${config_dpo_yaml}.tmp $config_dpo_yaml | ||
|
|
||
| rm -rf ./outputs | ||
| rm -rf paddleformers_dist_log | ||
| master=$(hostname -i) | ||
| port=36677 | ||
|
|
||
| export FLAGS_use_stride_compute_kernel=False | ||
| export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 | ||
|
|
||
| unset http_proxy https_proxy | ||
|
|
||
| export FLAGS_embedding_deterministic=1 | ||
| export FLAGS_cudnn_deterministic=1 | ||
|
|
||
| log_file=glm45_dpo_lora.txt | ||
| gt_loss_file=glm45_dpo_lora_multi_card_gt_loss.txt | ||
|
|
||
| set +e | ||
| NNODES=1 MASTER_ADDR=$master MASTER_PORT=$port coverage run $(which paddleformers-cli) train $config_dpo_yaml 2>&1 | tee ./${log_file} | ||
| sft_exit_code=$? | ||
| if [ $sft_exit_code -ne 0 ]; then | ||
| echo "GLM4.5 multi-cards training failed, try to check the log file" | ||
| python $root_dir/PaddleFormers/tests/check_log_for_exitcode.py ./${log_file} "***** eval metrics *****" | ||
| sft_check_exit_code=$? | ||
| if [ $sft_check_exit_code -ne 0 ]; then | ||
| echo "Failed to find 'Training completed' in log file." | ||
| exit 1 | ||
| else | ||
| echo "Log check passed." | ||
| fi | ||
| fi | ||
|
|
||
| export repo_name=$(echo $GITHUB_REPO_NAME | awk -F'/' '{print $2}') | ||
| # if [[ "${PP}" == "rel" ]]; then | ||
| # export pppatch="_PPrel" | ||
| # fi | ||
| # if [[ "${PF}" == rel* ]]; then | ||
| # export pfpatch="rel" | ||
| # fi | ||
| wget --no-proxy --no-check-certificate https://xly-devops.cdn.bcebos.com/PaddleFleet/precision/${repo_name}${pfpatch}${pppatch}_latest/${gt_loss_file} | ||
| if [ $? -ne 0 ]; then | ||
| echo "To request precision checks for new models, please contact swgu98." | ||
| exit 1 | ||
| fi | ||
|
|
||
| log_loss_file=${log_file%.*}_loss.${log_file##*.} | ||
| python $root_dir/PaddleFormers/tests/integration_test/check_loss.py \ | ||
| --compare_step 10 \ | ||
| --log_file ./${log_file} \ | ||
| --log_loss_file ./${log_loss_file} \ | ||
| --gt_file ./${gt_loss_file} | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| pushd $root_dir/PaddleFormers | ||
| source /root/proxy | ||
| bash $root_dir/PaddleFormers/tests/integration_test/check_precision_approval.sh | ||
| if [ $? -ne 0 ]; then | ||
| echo -e "\033[31mThe precision has been changed and requires approvals.\033[0m" | ||
| exit 1 | ||
| fi | ||
| popd | ||
| rm ${gt_loss_file} && mv ${log_loss_file} ${gt_loss_file} | ||
| if [ ! -f precision_list.txt ]; then | ||
| wget --no-proxy --no-check-certificate https://paddle-github-action.cdn.bcebos.com/PaddleFleet/precision/${repo_name}${pfpatch}${pppatch}/${PR_ID}/precision_list.txt | ||
| if [ $? -ne 0 ]; then | ||
| wget --no-proxy --no-check-certificate https://xly-devops.cdn.bcebos.com/PaddleFleet/precision/${repo_name}${pfpatch}${pppatch}_latest/precision_list.txt | ||
| python $root_dir/bos/BosClient.py precision_list.txt paddle-github-action/PaddleFleet/precision/${repo_name}${pfpatch}${pppatch}/${PR_ID} | ||
| fi | ||
| fi | ||
| python $root_dir/bos/BosClient.py ${gt_loss_file} paddle-github-action/PaddleFleet/precision/${repo_name}${pfpatch}${pppatch}/${PR_ID} | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.