forked from verl-project/verl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_qwen3_5_35b_a3b_veomni.sh
More file actions
167 lines (143 loc) · 5.15 KB
/
Copy pathrun_qwen3_5_35b_a3b_veomni.sh
File metadata and controls
167 lines (143 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env bash
# This script is a demo for GRPO training of Qwen3.5-35B-A3B using VeOmniEngine.
#
# Environment:
# - transformers==5.3.0
# - sglang==0.5.9
# - flash-linear-attention==0.4.1
# - veomni==0.1.9a1
# Tested configuration:
# - Model: Qwen3.5-35B-A3B
# - Sequence Parallel (SP): Tested with sp=1 and sp=2 (ulysses_parallel_size).
set -xeuo pipefail
# ---- user-adjustable ----
data_path=${data_path:-$HOME/data/geo3k}
model_path=${model_path:-$HOME/model/Qwen3.5-35B-A3B}
usp_size=${usp_size:-2}
nnodes=${nnodes:-2}
backend=fsdp2
model_engine=veomni
project_name='verl_grpo_qwen3_5_35b_a3b_geo3k'
exp_name='qwen3_5_35b_a3b_veomni_sp2'
# ===================================== Algorithm =====================================
adv_estimator=grpo
loss_mode=gspo
# reference policy
use_kl_in_reward=False
kl_coef=0.001
use_kl_loss=False
kl_loss_coef=0.001
clip_ratio_low=3e-4
clip_ratio_high=4e-4
actor_lr=1e-6
critic_lr=2e-6
gae_gamma=1.0
gae_lam=0.95
critic_warmup=0
# ===================================== Data/Model =====================================
train_files=$data_path/train.parquet
test_files=$data_path/test.parquet
actor_model_path=$model_path
max_prompt_length=$((1024 * 1))
max_response_length=$((1024 * 2))
train_batch_size=128
ppo_mini_batch_size=32
n_resp_per_prompt=8
n_resp_per_prompt_val=1
use_remove_padding=True
use_dynamic_bsz=False
# ===================================== Training =====================================
actor_max_token_len_per_gpu=$(((max_prompt_length + max_response_length) * 8))
ppo_micro_batch_size_per_gpu=1
# VeOmni config
ACTOR_VEOMNI_CONFIG="
actor_rollout_ref.actor.veomni.param_offload=True \
actor_rollout_ref.actor.veomni.optimizer_offload=True \
actor_rollout_ref.actor.veomni.enable_full_shard=True \
actor_rollout_ref.actor.veomni.ulysses_parallel_size=$usp_size \
actor_rollout_ref.actor.veomni.expert_parallel_size=1 \
actor_rollout_ref.actor.veomni.attn_implementation=flash_attention_2"
# ---- end user-adjustable ----
# ---- no user adjustment needed below ----
# Actor model config
ACTOR_CONFIG="
actor_rollout_ref.actor.optim.lr=$actor_lr \
actor_rollout_ref.model.path=$actor_model_path \
actor_rollout_ref.model.use_remove_padding=$use_remove_padding \
actor_rollout_ref.actor.use_kl_loss=$use_kl_loss \
actor_rollout_ref.actor.kl_loss_coef=$kl_loss_coef \
actor_rollout_ref.actor.clip_ratio_low=$clip_ratio_low \
actor_rollout_ref.actor.clip_ratio_high=$clip_ratio_high \
actor_rollout_ref.actor.clip_ratio_c=10.0 \
actor_rollout_ref.actor.policy_loss.loss_mode=${loss_mode} \
actor_rollout_ref.actor.use_dynamic_bsz=$use_dynamic_bsz \
actor_rollout_ref.actor.ppo_mini_batch_size=$ppo_mini_batch_size \
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_max_token_len_per_gpu} \
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=$ppo_micro_batch_size_per_gpu"
CONFIG_NAME=ppo_trainer
ACTOR_CONFIG="$ACTOR_CONFIG $ACTOR_VEOMNI_CONFIG"
# ===================================== Inference =====================================
rollout_name=sglang
infer_tp=4
infer_dp=1
infer_ep=1
gpu_memory_utilization=0.6
ROLLOUT_CONFIG="
actor_rollout_ref.rollout.name=$rollout_name \
actor_rollout_ref.rollout.tensor_model_parallel_size=$infer_tp \
actor_rollout_ref.rollout.data_parallel_size=$infer_dp \
actor_rollout_ref.rollout.expert_parallel_size=$infer_ep \
actor_rollout_ref.rollout.gpu_memory_utilization=$gpu_memory_utilization \
actor_rollout_ref.rollout.n=$n_resp_per_prompt \
actor_rollout_ref.rollout.val_kwargs.top_p=0.7 \
actor_rollout_ref.rollout.val_kwargs.temperature=1.0 \
actor_rollout_ref.rollout.val_kwargs.n=$n_resp_per_prompt_val \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=False"
########################### parameter arrays ###########################
CONFIG=(
--config-path=./config
--config-name=$CONFIG_NAME
)
DATA=(
algorithm.adv_estimator=$adv_estimator
algorithm.use_kl_in_reward=$use_kl_in_reward
algorithm.kl_ctrl.kl_coef=$kl_coef
algorithm.gamma=$gae_gamma
algorithm.lam=$gae_lam
data.train_files="$train_files"
data.val_files="$test_files"
data.return_raw_chat=True
data.train_batch_size=$train_batch_size
data.max_prompt_length=$max_prompt_length
data.max_response_length=$max_response_length
data.filter_overlong_prompts=True
data.filter_overlong_prompts_workers=64
data.truncation='error'
)
TRAINER=(
trainer.critic_warmup=$critic_warmup
trainer.logger=['console','wandb']
trainer.project_name=$project_name
trainer.experiment_name=$exp_name
trainer.n_gpus_per_node=8
trainer.nnodes=$nnodes
trainer.val_before_train=False
trainer.log_val_generations=100
trainer.save_freq=-1
trainer.test_freq=10
trainer.total_epochs=10
trainer.total_training_steps=500
)
EXTRA=(
model_engine=$model_engine
$ACTOR_CONFIG
$ROLLOUT_CONFIG
)
########################### launch ###########################
python -m verl.trainer.main_ppo \
"${CONFIG[@]}" \
"${DATA[@]}" \
"${TRAINER[@]}" \
"${EXTRA[@]}" \
"$@"