|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -xeuo pipefail |
| 3 | + |
| 4 | +project_name='DAPO' |
| 5 | +exp_name='DAPO-Qwen3-30B-A3B-Base-MATH-0527a1' |
| 6 | + |
| 7 | +adv_estimator=grpo |
| 8 | + |
| 9 | +use_kl_in_reward=False |
| 10 | +kl_coef=0.0 |
| 11 | +use_kl_loss=False |
| 12 | +kl_loss_coef=0.0 |
| 13 | + |
| 14 | +clip_ratio_low=0.2 |
| 15 | +clip_ratio_high=0.28 |
| 16 | + |
| 17 | +max_prompt_length=$((1024 * 2)) |
| 18 | +max_response_length=$((1024 * 8)) |
| 19 | +enable_overlong_buffer=True |
| 20 | +overlong_buffer_len=$((1024 * 4)) |
| 21 | +overlong_penalty_factor=1.0 |
| 22 | + |
| 23 | +loss_agg_mode="token-mean" |
| 24 | + |
| 25 | +train_prompt_bsz=512 |
| 26 | +n_resp_per_prompt=16 |
| 27 | +train_prompt_mini_bsz=32 |
| 28 | + |
| 29 | +# Ray |
| 30 | +# RAY_ADDRESS=${RAY_ADDRESS:-"http://localhost:8265"} |
| 31 | +# WORKING_DIR=${WORKING_DIR:-"${PWD}"} |
| 32 | +# RUNTIME_ENV=${RUNTIME_ENV:-"${WORKING_DIR}/verl/trainer/runtime_env.yaml"} |
| 33 | +NNODES=${NNODES:-8} |
| 34 | +NGPUS_PER_NODE=${NGPUS_PER_NODE:-8} |
| 35 | +# Paths |
| 36 | +RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"} |
| 37 | +MODEL_PATH=${MODEL_PATH:-"${RAY_DATA_HOME}/models/Qwen3-30B-A3B-Base"} |
| 38 | +CKPTS_DIR=${CKPTS_DIR:-"${RAY_DATA_HOME}/ckpts/${project_name}/${exp_name}"} |
| 39 | +TRAIN_FILE=${TRAIN_FILE:-"${RAY_DATA_HOME}/data/dapo-math-17k.parquet"} |
| 40 | +TEST_FILE=${TEST_FILE:-"${RAY_DATA_HOME}/data/aime-2024.parquet"} |
| 41 | + |
| 42 | +# Algorithm |
| 43 | +temperature=1.0 |
| 44 | +top_p=1.0 |
| 45 | +top_k=-1 # 0 for HF rollout, -1 for vLLM rollout |
| 46 | +val_top_p=0.7 |
| 47 | + |
| 48 | +# Performance Related Parameter |
| 49 | +sp_size=4 |
| 50 | +use_dynamic_bsz=True |
| 51 | +actor_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 2)) |
| 52 | +infer_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 3)) |
| 53 | +offload=True |
| 54 | +gen_tp=4 |
| 55 | +fsdp_size=32 |
| 56 | + |
| 57 | +python3 -m verl.trainer.main_ppo \ |
| 58 | + data.train_files="${TRAIN_FILE}" \ |
| 59 | + data.val_files="${TEST_FILE}" \ |
| 60 | + data.prompt_key=prompt \ |
| 61 | + data.truncation='left' \ |
| 62 | + data.max_prompt_length=${max_prompt_length} \ |
| 63 | + data.max_response_length=${max_response_length} \ |
| 64 | + data.train_batch_size=${train_prompt_bsz} \ |
| 65 | + actor_rollout_ref.rollout.n=${n_resp_per_prompt} \ |
| 66 | + algorithm.adv_estimator=${adv_estimator} \ |
| 67 | + algorithm.use_kl_in_reward=${use_kl_in_reward} \ |
| 68 | + algorithm.kl_ctrl.kl_coef=${kl_coef} \ |
| 69 | + actor_rollout_ref.actor.use_kl_loss=${use_kl_loss} \ |
| 70 | + actor_rollout_ref.actor.kl_loss_coef=${kl_loss_coef} \ |
| 71 | + actor_rollout_ref.actor.clip_ratio_low=${clip_ratio_low} \ |
| 72 | + actor_rollout_ref.actor.clip_ratio_high=${clip_ratio_high} \ |
| 73 | + actor_rollout_ref.actor.clip_ratio_c=10.0 \ |
| 74 | + actor_rollout_ref.model.use_remove_padding=True \ |
| 75 | + actor_rollout_ref.actor.use_dynamic_bsz=${use_dynamic_bsz} \ |
| 76 | + actor_rollout_ref.ref.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \ |
| 77 | + actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \ |
| 78 | + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len} \ |
| 79 | + actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \ |
| 80 | + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \ |
| 81 | + actor_rollout_ref.model.path="${MODEL_PATH}" \ |
| 82 | + actor_rollout_ref.model.enable_gradient_checkpointing=True \ |
| 83 | + actor_rollout_ref.actor.optim.lr=1e-6 \ |
| 84 | + actor_rollout_ref.actor.optim.lr_warmup_steps=10 \ |
| 85 | + actor_rollout_ref.actor.optim.weight_decay=0.1 \ |
| 86 | + actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz} \ |
| 87 | + actor_rollout_ref.actor.fsdp_config.param_offload=${offload} \ |
| 88 | + actor_rollout_ref.actor.fsdp_config.optimizer_offload=${offload} \ |
| 89 | + actor_rollout_ref.actor.entropy_coeff=0 \ |
| 90 | + actor_rollout_ref.actor.grad_clip=1.0 \ |
| 91 | + actor_rollout_ref.actor.loss_agg_mode=${loss_agg_mode} \ |
| 92 | + actor_rollout_ref.actor.ulysses_sequence_parallel_size=${sp_size} \ |
| 93 | + actor_rollout_ref.rollout.gpu_memory_utilization=0.80 \ |
| 94 | + actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \ |
| 95 | + actor_rollout_ref.rollout.enable_chunked_prefill=True \ |
| 96 | + actor_rollout_ref.rollout.max_num_batched_tokens=$((max_prompt_length + max_response_length)) \ |
| 97 | + actor_rollout_ref.rollout.temperature=${temperature} \ |
| 98 | + actor_rollout_ref.rollout.top_p=${top_p} \ |
| 99 | + actor_rollout_ref.rollout.top_k=${top_k} \ |
| 100 | + actor_rollout_ref.rollout.val_kwargs.temperature=${temperature} \ |
| 101 | + actor_rollout_ref.rollout.val_kwargs.top_p=${val_top_p} \ |
| 102 | + actor_rollout_ref.rollout.val_kwargs.top_k=${top_k} \ |
| 103 | + actor_rollout_ref.rollout.val_kwargs.do_sample=True \ |
| 104 | + actor_rollout_ref.rollout.val_kwargs.n=1 \ |
| 105 | + actor_rollout_ref.ref.fsdp_config.param_offload=${offload} \ |
| 106 | + actor_rollout_ref.ref.ulysses_sequence_parallel_size=${sp_size} \ |
| 107 | + actor_rollout_ref.actor.fsdp_config.fsdp_size=${fsdp_size} \ |
| 108 | + reward_model.reward_manager=dapo \ |
| 109 | + +reward_model.reward_kwargs.overlong_buffer_cfg.enable=${enable_overlong_buffer} \ |
| 110 | + +reward_model.reward_kwargs.overlong_buffer_cfg.len=${overlong_buffer_len} \ |
| 111 | + +reward_model.reward_kwargs.overlong_buffer_cfg.penalty_factor=${overlong_penalty_factor} \ |
| 112 | + +reward_model.reward_kwargs.overlong_buffer_cfg.log=False \ |
| 113 | + +reward_model.reward_kwargs.max_resp_len=${max_response_length} \ |
| 114 | + trainer.logger=['console','wandb'] \ |
| 115 | + trainer.project_name="${project_name}" \ |
| 116 | + trainer.experiment_name="${exp_name}" \ |
| 117 | + trainer.n_gpus_per_node="${NGPUS_PER_NODE}" \ |
| 118 | + trainer.nnodes="${NNODES}" \ |
| 119 | + trainer.val_before_train=True \ |
| 120 | + trainer.test_freq=10 \ |
| 121 | + trainer.save_freq=10 \ |
| 122 | + trainer.total_epochs=10 \ |
| 123 | + trainer.total_training_steps=300 \ |
| 124 | + trainer.default_local_dir="${CKPTS_DIR}" \ |
| 125 | + trainer.resume_mode=auto \ |
| 126 | + trainer.log_val_generations=10 |
0 commit comments