Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- verl/examples/grpo_trainer/run_qwen2_5_vl-7b.sh +47 -0
- verl/examples/grpo_trainer/run_qwen2_5_vl-7b_lora.sh +52 -0
- verl/examples/grpo_trainer/run_qwen2_5_vl-7b_seq_balance.sh +45 -0
- verl/examples/grpo_trainer/run_qwen2_5_vl_32b_npu.sh +52 -0
- verl/examples/grpo_trainer/run_qwen2_5_vl_3b_npu.sh +52 -0
- verl/examples/grpo_trainer/run_qwen2_5_vl_7b_npu.sh +52 -0
- verl/examples/grpo_trainer/run_qwen3-235b_megatron_96gb.sh +181 -0
- verl/examples/grpo_trainer/run_qwen3-32b_npu.sh +59 -0
- verl/examples/grpo_trainer/run_qwen3-8b.sh +43 -0
- verl/examples/grpo_trainer/run_qwen3-8b_npu.sh +59 -0
- verl/examples/grpo_trainer/run_qwen3_8b_grpo_sglang_1k_spmd_npu.sh +71 -0
- verl/examples/grpo_trainer/run_qwen3_8b_grpo_sglang_32k_spmd_npu.sh +71 -0
- verl/examples/grpo_trainer/run_qwen3moe-30b_megatron_96gb.sh +195 -0
- verl/examples/grpo_trainer/run_seed_oss_36b.sh +48 -0
- verl/examples/ppo_trainer/README.md +103 -0
- verl/examples/ppo_trainer/run_deepseek7b_llm.sh +42 -0
- verl/examples/ppo_trainer/run_deepseek7b_llm_modelscope.sh +42 -0
- verl/examples/ppo_trainer/run_deepseek7b_llm_pfppo.sh +45 -0
- verl/examples/ppo_trainer/run_deepseek7b_llm_sandbox_fusion.sh +44 -0
- verl/examples/ppo_trainer/run_deepseek7b_llm_sp2.sh +43 -0
- verl/examples/ppo_trainer/run_deepseek_full_hh_rlhf.sh +41 -0
- verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron.sh +49 -0
- verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron_nsys.sh +65 -0
- verl/examples/ppo_trainer/run_gemma.sh +40 -0
- verl/examples/ppo_trainer/run_moonlight16b_a3b_gsm8k_megatron.sh +106 -0
- verl/examples/ppo_trainer/run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh +73 -0
- verl/examples/ppo_trainer/run_qwen2-7b_math_gsm8k_megatron.sh +47 -0
- verl/examples/ppo_trainer/run_qwen2-7b_rm.sh +71 -0
- verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance.sh +60 -0
- verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_fused_kernels.sh +64 -0
- verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_nsys.sh +81 -0
- verl/examples/ppo_trainer/run_qwen2-7b_seq_balance.sh +60 -0
- verl/examples/ppo_trainer/run_qwen2-7b_sglang_seq_balance.sh +51 -0
- verl/examples/ppo_trainer/run_qwen2.5-32b.sh +50 -0
- verl/examples/ppo_trainer/run_qwen3-8b_npu.sh +55 -0
- verl/examples/ray/tutorial.ipynb +963 -0
- verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf.sh +49 -0
- verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf_baseline.sh +49 -0
- verl/examples/remax_trainer/run_qwen2.5-3b_seq_balance.sh +43 -0
- verl/examples/remax_trainer/run_qwen2.5-7b_seq_balance.sh +43 -0
- verl/examples/rloo_trainer/run_qwen2-7b.sh +40 -0
- verl/examples/sft/gsm8k/run_deepseek_6b7.sh +28 -0
- verl/examples/sft/gsm8k/run_gemma_2b.sh +30 -0
- verl/examples/sft/gsm8k/run_gemma_7b.sh +28 -0
- verl/examples/sft/gsm8k/run_qwen3_8b_sft_peft_sp2_npu.sh +36 -0
- verl/examples/sft/gsm8k/run_qwen_05_peft.sh +37 -0
- verl/examples/sft/gsm8k/run_qwen_05_sp2.sh +31 -0
- verl/examples/sft/gsm8k/run_qwen_05_sp2_liger.sh +31 -0
- verl/examples/sft/gsm8k/run_seed_oss_36b_sft.sh +31 -0
- verl/examples/sft/multiturn/run_qwen_05_sp2.sh +29 -0
verl/examples/grpo_trainer/run_qwen2_5_vl-7b.sh
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
|
| 4 |
+
python3 -m verl.trainer.main_ppo \
|
| 5 |
+
algorithm.adv_estimator=grpo \
|
| 6 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 7 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 8 |
+
data.train_batch_size=512 \
|
| 9 |
+
data.max_prompt_length=1024 \
|
| 10 |
+
data.max_response_length=2048 \
|
| 11 |
+
data.filter_overlong_prompts=True \
|
| 12 |
+
data.truncation='error' \
|
| 13 |
+
data.image_key=images \
|
| 14 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \
|
| 15 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 16 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 17 |
+
actor_rollout_ref.model.use_fused_kernels=True \
|
| 18 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 19 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \
|
| 20 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 21 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 22 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 23 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 24 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 25 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 26 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 27 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \
|
| 28 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 29 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 30 |
+
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
|
| 31 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 32 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 33 |
+
actor_rollout_ref.rollout.enforce_eager=False \
|
| 34 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 35 |
+
actor_rollout_ref.rollout.n=5 \
|
| 36 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \
|
| 37 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 38 |
+
algorithm.use_kl_in_reward=False \
|
| 39 |
+
trainer.critic_warmup=0 \
|
| 40 |
+
trainer.logger='["console","wandb"]' \
|
| 41 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 42 |
+
trainer.experiment_name='qwen2_5_vl_7b_function_rm' \
|
| 43 |
+
trainer.n_gpus_per_node=8 \
|
| 44 |
+
trainer.nnodes=1 \
|
| 45 |
+
trainer.save_freq=20 \
|
| 46 |
+
trainer.test_freq=5 \
|
| 47 |
+
trainer.total_epochs=15 $@
|
verl/examples/grpo_trainer/run_qwen2_5_vl-7b_lora.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
# If you are using vllm<=0.6.3, you might need to set the following environment variable to avoid bugs:
|
| 4 |
+
# export VLLM_ATTENTION_BACKEND=XFORMERS
|
| 5 |
+
|
| 6 |
+
python3 -m verl.trainer.main_ppo \
|
| 7 |
+
algorithm.adv_estimator=grpo \
|
| 8 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 9 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 10 |
+
data.train_batch_size=512 \
|
| 11 |
+
data.max_prompt_length=1024 \
|
| 12 |
+
data.max_response_length=2048 \
|
| 13 |
+
data.filter_overlong_prompts=True \
|
| 14 |
+
data.truncation='error' \
|
| 15 |
+
data.image_key=images \
|
| 16 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \
|
| 17 |
+
actor_rollout_ref.actor.optim.lr=3e-6 \
|
| 18 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 19 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 20 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \
|
| 21 |
+
actor_rollout_ref.model.lora_rank=64 \
|
| 22 |
+
actor_rollout_ref.model.lora_alpha=32 \
|
| 23 |
+
actor_rollout_ref.model.target_modules=all-linear \
|
| 24 |
+
actor_rollout_ref.model.exclude_modules='.*visual.*' \
|
| 25 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 26 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 27 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 28 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 29 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 30 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 31 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 32 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \
|
| 33 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 34 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 35 |
+
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
|
| 36 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 37 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 38 |
+
actor_rollout_ref.rollout.enforce_eager=False \
|
| 39 |
+
actor_rollout_ref.rollout.free_cache_engine=False \
|
| 40 |
+
actor_rollout_ref.rollout.n=5 \
|
| 41 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \
|
| 42 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 43 |
+
algorithm.use_kl_in_reward=False \
|
| 44 |
+
trainer.critic_warmup=0 \
|
| 45 |
+
trainer.logger='["console","wandb"]' \
|
| 46 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 47 |
+
trainer.experiment_name='qwen2_5_vl_7b_function_rm' \
|
| 48 |
+
trainer.n_gpus_per_node=8 \
|
| 49 |
+
trainer.nnodes=1 \
|
| 50 |
+
trainer.save_freq=20 \
|
| 51 |
+
trainer.test_freq=5 \
|
| 52 |
+
trainer.total_epochs=15 $@
|
verl/examples/grpo_trainer/run_qwen2_5_vl-7b_seq_balance.sh
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
|
| 4 |
+
python3 -m verl.trainer.main_ppo \
|
| 5 |
+
algorithm.adv_estimator=grpo \
|
| 6 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 7 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 8 |
+
data.train_batch_size=512 \
|
| 9 |
+
data.max_prompt_length=1024 \
|
| 10 |
+
data.max_response_length=2048 \
|
| 11 |
+
data.filter_overlong_prompts=True \
|
| 12 |
+
data.truncation='error' \
|
| 13 |
+
data.image_key=images \
|
| 14 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \
|
| 15 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 16 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 17 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 18 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 19 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=6144 \
|
| 20 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 21 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 22 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 23 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 24 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 25 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 26 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 27 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 28 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 29 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 30 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 31 |
+
actor_rollout_ref.rollout.enforce_eager=False \
|
| 32 |
+
actor_rollout_ref.rollout.free_cache_engine=False \
|
| 33 |
+
actor_rollout_ref.rollout.n=5 \
|
| 34 |
+
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=6144 \
|
| 35 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 36 |
+
algorithm.use_kl_in_reward=False \
|
| 37 |
+
trainer.critic_warmup=0 \
|
| 38 |
+
trainer.logger='["console","wandb"]' \
|
| 39 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 40 |
+
trainer.experiment_name='qwen2_5_vl_7b_function_rm' \
|
| 41 |
+
trainer.n_gpus_per_node=8 \
|
| 42 |
+
trainer.nnodes=1 \
|
| 43 |
+
trainer.save_freq=20 \
|
| 44 |
+
trainer.test_freq=5 \
|
| 45 |
+
trainer.total_epochs=15 $@
|
verl/examples/grpo_trainer/run_qwen2_5_vl_32b_npu.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
|
| 4 |
+
# Some models are optimized by vllm ascend. While in some case, e.g. rlhf training,
|
| 5 |
+
# the optimized model may not be suitable. In this case, set this value to 0 to disable the optimized model.
|
| 6 |
+
export USE_OPTIMIZED_MODEL=0
|
| 7 |
+
|
| 8 |
+
python3 -m verl.trainer.main_ppo \
|
| 9 |
+
algorithm.adv_estimator=grpo \
|
| 10 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 11 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 12 |
+
data.train_batch_size=512 \
|
| 13 |
+
data.max_prompt_length=1024 \
|
| 14 |
+
data.max_response_length=2048 \
|
| 15 |
+
data.filter_overlong_prompts=True \
|
| 16 |
+
data.truncation='error' \
|
| 17 |
+
data.image_key=images \
|
| 18 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct \
|
| 19 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 20 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 21 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=32 \
|
| 22 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
|
| 23 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 24 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 25 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 26 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 27 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 28 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 29 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 30 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 31 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
|
| 32 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=8 \
|
| 33 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 34 |
+
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
|
| 35 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.3 \
|
| 36 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 37 |
+
actor_rollout_ref.rollout.enforce_eager=True \
|
| 38 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 39 |
+
actor_rollout_ref.rollout.n=5 \
|
| 40 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
|
| 41 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 42 |
+
algorithm.use_kl_in_reward=False \
|
| 43 |
+
trainer.critic_warmup=0 \
|
| 44 |
+
trainer.logger=console \
|
| 45 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 46 |
+
trainer.experiment_name='qwen2_5_vl_32b_function_rm' \
|
| 47 |
+
trainer.n_gpus_per_node=16 \
|
| 48 |
+
trainer.nnodes=2 \
|
| 49 |
+
trainer.save_freq=-1 \
|
| 50 |
+
trainer.test_freq=-1 \
|
| 51 |
+
trainer.total_epochs=15 \
|
| 52 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen2_5_vl_3b_npu.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
|
| 4 |
+
# Some models are optimized by vllm ascend. While in some case, e.g. rlhf training,
|
| 5 |
+
# the optimized model may not be suitable. In this case, set this value to 0 to disable the optimized model.
|
| 6 |
+
export USE_OPTIMIZED_MODEL=0
|
| 7 |
+
|
| 8 |
+
python3 -m verl.trainer.main_ppo \
|
| 9 |
+
algorithm.adv_estimator=grpo \
|
| 10 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 11 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 12 |
+
data.train_batch_size=512 \
|
| 13 |
+
data.max_prompt_length=1024 \
|
| 14 |
+
data.max_response_length=2048 \
|
| 15 |
+
data.filter_overlong_prompts=True \
|
| 16 |
+
data.truncation='error' \
|
| 17 |
+
data.image_key=images \
|
| 18 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-3B-Instruct \
|
| 19 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 20 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 21 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=16 \
|
| 22 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \
|
| 23 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 24 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 25 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 26 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 27 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 28 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 29 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 30 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 31 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 32 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 33 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 34 |
+
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
|
| 35 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 36 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 37 |
+
actor_rollout_ref.rollout.enforce_eager=True \
|
| 38 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 39 |
+
actor_rollout_ref.rollout.n=5 \
|
| 40 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
|
| 41 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 42 |
+
algorithm.use_kl_in_reward=False \
|
| 43 |
+
trainer.critic_warmup=0 \
|
| 44 |
+
trainer.logger=console \
|
| 45 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 46 |
+
trainer.experiment_name='qwen2_5_vl_3b_function_rm' \
|
| 47 |
+
trainer.n_gpus_per_node=8 \
|
| 48 |
+
trainer.nnodes=1 \
|
| 49 |
+
trainer.save_freq=-1 \
|
| 50 |
+
trainer.test_freq=-1 \
|
| 51 |
+
trainer.total_epochs=15 \
|
| 52 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen2_5_vl_7b_npu.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
ENGINE=${1:-vllm}
|
| 3 |
+
|
| 4 |
+
# Some models are optimized by vllm ascend. While in some case, e.g. rlhf training,
|
| 5 |
+
# the optimized model may not be suitable. In this case, set this value to 0 to disable the optimized model.
|
| 6 |
+
export USE_OPTIMIZED_MODEL=0
|
| 7 |
+
|
| 8 |
+
python3 -m verl.trainer.main_ppo \
|
| 9 |
+
algorithm.adv_estimator=grpo \
|
| 10 |
+
data.train_files=$HOME/data/geo3k/train.parquet \
|
| 11 |
+
data.val_files=$HOME/data/geo3k/test.parquet \
|
| 12 |
+
data.train_batch_size=512 \
|
| 13 |
+
data.max_prompt_length=1024 \
|
| 14 |
+
data.max_response_length=2048 \
|
| 15 |
+
data.filter_overlong_prompts=True \
|
| 16 |
+
data.truncation='error' \
|
| 17 |
+
data.image_key=images \
|
| 18 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \
|
| 19 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 20 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 21 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=32 \
|
| 22 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \
|
| 23 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 24 |
+
actor_rollout_ref.actor.kl_loss_coef=0.01 \
|
| 25 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 26 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 27 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 28 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 29 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 30 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 31 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 32 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 33 |
+
actor_rollout_ref.rollout.name=$ENGINE \
|
| 34 |
+
+actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
|
| 35 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 36 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 37 |
+
actor_rollout_ref.rollout.enforce_eager=True \
|
| 38 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 39 |
+
actor_rollout_ref.rollout.n=5 \
|
| 40 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
|
| 41 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 42 |
+
algorithm.use_kl_in_reward=False \
|
| 43 |
+
trainer.critic_warmup=0 \
|
| 44 |
+
trainer.logger=console \
|
| 45 |
+
trainer.project_name='verl_grpo_example_geo3k' \
|
| 46 |
+
trainer.experiment_name='qwen2_5_vl_7b_function_rm' \
|
| 47 |
+
trainer.n_gpus_per_node=16 \
|
| 48 |
+
trainer.nnodes=1 \
|
| 49 |
+
trainer.save_freq=-1 \
|
| 50 |
+
trainer.test_freq=-1 \
|
| 51 |
+
trainer.total_epochs=15 \
|
| 52 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen3-235b_megatron_96gb.sh
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -xeuo pipefail
|
| 3 |
+
|
| 4 |
+
## !!!!!!!important!!!!!!
|
| 5 |
+
## set the following environment variables on all your nodes
|
| 6 |
+
# env_vars:
|
| 7 |
+
# CUDA_DEVICE_MAX_CONNECTIONS: "1"
|
| 8 |
+
# NCCL_NVLS_ENABLE: "0"
|
| 9 |
+
# VLLM_USE_V1: 1
|
| 10 |
+
# install mbridge=0.1.13 on all your node with the following command:
|
| 11 |
+
# pip3 install git+https://github.com/ISEEKYAN/mbridge
|
| 12 |
+
|
| 13 |
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 14 |
+
[ -f "${SCRIPT_DIR}/env.sh" ] && source "${SCRIPT_DIR}/env.sh"
|
| 15 |
+
|
| 16 |
+
adv_estimator=grpo
|
| 17 |
+
|
| 18 |
+
use_kl_in_reward=False
|
| 19 |
+
kl_coef=0.0
|
| 20 |
+
use_kl_loss=True
|
| 21 |
+
kl_loss_coef=0.001
|
| 22 |
+
|
| 23 |
+
clip_ratio_low=0.2
|
| 24 |
+
clip_ratio_high=0.28
|
| 25 |
+
|
| 26 |
+
max_prompt_length=$((1024 * 2))
|
| 27 |
+
max_response_length=$((1204 * 8))
|
| 28 |
+
enable_overlong_buffer=True
|
| 29 |
+
overlong_buffer_len=$((1024 * 1))
|
| 30 |
+
overlong_penalty_factor=1.0
|
| 31 |
+
|
| 32 |
+
loss_agg_mode="token-mean"
|
| 33 |
+
|
| 34 |
+
train_prompt_bsz=${TRAIN_BS:-32}
|
| 35 |
+
n_resp_per_prompt=8
|
| 36 |
+
train_prompt_mini_bsz=16
|
| 37 |
+
|
| 38 |
+
# minimum nodes need for qwen3-235B-A22B
|
| 39 |
+
NNODES=${NNODES:-4}
|
| 40 |
+
# Paths
|
| 41 |
+
|
| 42 |
+
RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"}
|
| 43 |
+
|
| 44 |
+
MODEL_PATH=$RAY_DATA_HOME/models/Qwen3-235B-A22B
|
| 45 |
+
|
| 46 |
+
TRAIN_FILE=$RAY_DATA_HOME/dataset/dapo-math-17k.parquet
|
| 47 |
+
TEST_FILE=$RAY_DATA_HOME/dataset/aime-2024.parquet
|
| 48 |
+
|
| 49 |
+
# Algorithm
|
| 50 |
+
temperature=1.0
|
| 51 |
+
top_p=1.0
|
| 52 |
+
top_k=-1 # 0 for HF rollout, -1 for vLLM rollout
|
| 53 |
+
val_top_p=0.7
|
| 54 |
+
# Performance Related Parameter
|
| 55 |
+
use_dynamic_bsz=True
|
| 56 |
+
actor_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 10 / 10))
|
| 57 |
+
infer_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 1))
|
| 58 |
+
offload=True
|
| 59 |
+
OPTIM_OFFLOAD=${OPTIM_OFFLOAD:-True}
|
| 60 |
+
gen_tp=8
|
| 61 |
+
train_tp=${TP:-4}
|
| 62 |
+
train_pp=${PP:-8}
|
| 63 |
+
|
| 64 |
+
EP=${EP:-4}
|
| 65 |
+
ETP=1
|
| 66 |
+
CP=1
|
| 67 |
+
optimizer_offload_fraction=${OFFLOAD_FRACTION:-1.}
|
| 68 |
+
last_layer=${LAST_LAYER:-10}
|
| 69 |
+
|
| 70 |
+
project_name='verl-qwen3'
|
| 71 |
+
exp_name="235B-${NNODES}-pp${train_pp}-tp${train_tp}-ep${EP}-actor-length${actor_ppo_max_token_len}"
|
| 72 |
+
CKPTS_DIR=$RAY_DATA_HOME/ckpt/${project_name}/${exp_name}
|
| 73 |
+
|
| 74 |
+
# TODO: support cuda graph for rollout by setting the following config
|
| 75 |
+
# actor_rollout_ref.rollout.cudagraph_capture_sizes=[1,2,4,8,16,32]
|
| 76 |
+
# actor_rollout_ref.rollout.enforce_eager=False
|
| 77 |
+
|
| 78 |
+
python3 -m verl.trainer.main_ppo \
|
| 79 |
+
--config-path=config \
|
| 80 |
+
--config-name='ppo_megatron_trainer.yaml' \
|
| 81 |
+
data.train_files="${TRAIN_FILE}" \
|
| 82 |
+
data.val_files="${TEST_FILE}" \
|
| 83 |
+
data.prompt_key=prompt \
|
| 84 |
+
data.truncation='left' \
|
| 85 |
+
data.max_prompt_length=${max_prompt_length} \
|
| 86 |
+
data.max_response_length=${max_response_length} \
|
| 87 |
+
data.train_batch_size=${train_prompt_bsz} \
|
| 88 |
+
actor_rollout_ref.rollout.n=${n_resp_per_prompt} \
|
| 89 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 90 |
+
actor_rollout_ref.rollout.enforce_eager=True \
|
| 91 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 92 |
+
algorithm.adv_estimator=${adv_estimator} \
|
| 93 |
+
algorithm.use_kl_in_reward=${use_kl_in_reward} \
|
| 94 |
+
algorithm.kl_ctrl.kl_coef=${kl_coef} \
|
| 95 |
+
actor_rollout_ref.model.use_fused_kernels=True \
|
| 96 |
+
actor_rollout_ref.actor.megatron.use_mbridge=True \
|
| 97 |
+
actor_rollout_ref.actor.use_kl_loss=${use_kl_loss} \
|
| 98 |
+
actor_rollout_ref.actor.kl_loss_coef=${kl_loss_coef} \
|
| 99 |
+
actor_rollout_ref.actor.clip_ratio_low=${clip_ratio_low} \
|
| 100 |
+
actor_rollout_ref.actor.clip_ratio_high=${clip_ratio_high} \
|
| 101 |
+
actor_rollout_ref.actor.clip_ratio_c=10.0 \
|
| 102 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \
|
| 103 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
|
| 104 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 105 |
+
actor_rollout_ref.actor.use_dynamic_bsz=${use_dynamic_bsz} \
|
| 106 |
+
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \
|
| 107 |
+
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \
|
| 108 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len} \
|
| 109 |
+
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
|
| 110 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
|
| 111 |
+
actor_rollout_ref.model.path="${MODEL_PATH}" \
|
| 112 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 113 |
+
actor_rollout_ref.actor.optim.lr_warmup_steps=10 \
|
| 114 |
+
actor_rollout_ref.actor.optim.weight_decay=0.1 \
|
| 115 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_offload_fraction=${optimizer_offload_fraction} \
|
| 116 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.overlap_cpu_optimizer_d2h_h2d=True \
|
| 117 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.use_precision_aware_optimizer=True \
|
| 118 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_cpu_offload=True \
|
| 119 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz} \
|
| 120 |
+
actor_rollout_ref.actor.megatron.param_offload=${offload} \
|
| 121 |
+
actor_rollout_ref.actor.megatron.optimizer_offload=${OPTIM_OFFLOAD} \
|
| 122 |
+
actor_rollout_ref.actor.megatron.grad_offload=${offload} \
|
| 123 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=${train_pp} \
|
| 124 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=${train_tp} \
|
| 125 |
+
actor_rollout_ref.actor.megatron.expert_model_parallel_size=$EP \
|
| 126 |
+
actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=$ETP \
|
| 127 |
+
actor_rollout_ref.actor.megatron.context_parallel_size=${CP} \
|
| 128 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 129 |
+
actor_rollout_ref.actor.optim.clip_grad=1.0 \
|
| 130 |
+
actor_rollout_ref.actor.loss_agg_mode=${loss_agg_mode} \
|
| 131 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.85 \
|
| 132 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \
|
| 133 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=True \
|
| 134 |
+
actor_rollout_ref.rollout.max_num_batched_tokens=$((max_prompt_length + max_response_length)) \
|
| 135 |
+
actor_rollout_ref.rollout.temperature=${temperature} \
|
| 136 |
+
actor_rollout_ref.rollout.top_p=${top_p} \
|
| 137 |
+
actor_rollout_ref.rollout.top_k=${top_k} \
|
| 138 |
+
actor_rollout_ref.nccl_timeout=1200 \
|
| 139 |
+
actor_rollout_ref.rollout.val_kwargs.temperature=${temperature} \
|
| 140 |
+
actor_rollout_ref.rollout.val_kwargs.top_p=${val_top_p} \
|
| 141 |
+
actor_rollout_ref.rollout.val_kwargs.top_k=${top_k} \
|
| 142 |
+
actor_rollout_ref.rollout.val_kwargs.do_sample=True \
|
| 143 |
+
actor_rollout_ref.rollout.val_kwargs.n=1 \
|
| 144 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=${train_pp} \
|
| 145 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=${train_tp} \
|
| 146 |
+
actor_rollout_ref.ref.megatron.expert_model_parallel_size=$EP \
|
| 147 |
+
actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=$ETP \
|
| 148 |
+
actor_rollout_ref.ref.megatron.context_parallel_size=${CP} \
|
| 149 |
+
actor_rollout_ref.ref.megatron.param_offload=${offload} \
|
| 150 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.apply_rope_fusion=True \
|
| 151 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.masked_softmax_fusion=True \
|
| 152 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.bias_activation_fusion=True \
|
| 153 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.bias_dropout_fusion=True \
|
| 154 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.gradient_accumulation_fusion=True \
|
| 155 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.deallocate_pipeline_outputs=True \
|
| 156 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.persist_layer_norm=True \
|
| 157 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_grouped_gemm=True \
|
| 158 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_permute_fusion=True \
|
| 159 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_token_dispatcher_type="flex" \
|
| 160 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_router_dtype=fp32 \
|
| 161 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_enable_deepep=True \
|
| 162 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.account_for_loss_in_pipeline_split=True \
|
| 163 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.account_for_embedding_in_pipeline_split=True \
|
| 164 |
+
reward_model.reward_manager=dapo \
|
| 165 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.enable=${enable_overlong_buffer} \
|
| 166 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.len=${overlong_buffer_len} \
|
| 167 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.penalty_factor=${overlong_penalty_factor} \
|
| 168 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.log=False \
|
| 169 |
+
+reward_model.reward_kwargs.max_resp_len=${max_response_length} \
|
| 170 |
+
trainer.logger=['console','wandb'] \
|
| 171 |
+
trainer.project_name="${project_name}" \
|
| 172 |
+
trainer.experiment_name="${exp_name}" \
|
| 173 |
+
trainer.n_gpus_per_node=8 \
|
| 174 |
+
trainer.nnodes="${NNODES}" \
|
| 175 |
+
trainer.val_before_train=False \
|
| 176 |
+
trainer.test_freq=10 \
|
| 177 |
+
trainer.save_freq=100 \
|
| 178 |
+
trainer.total_epochs=10 \
|
| 179 |
+
trainer.default_local_dir="${CKPTS_DIR}" \
|
| 180 |
+
trainer.resume_mode=auto \
|
| 181 |
+
trainer.log_val_generations=10
|
verl/examples/grpo_trainer/run_qwen3-32b_npu.sh
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
project_name='GRPO-Qwen3'
|
| 4 |
+
exp_name='GRPO-Qwen3-32b-npu'
|
| 5 |
+
gen_tp=4
|
| 6 |
+
RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"}
|
| 7 |
+
MODEL_PATH=${MODEL_PATH:-"${RAY_DATA_HOME}/models/Qwen3-32B"}
|
| 8 |
+
TRAIN_FILE=${TRAIN_FILE:-"${RAY_DATA_HOME}/data/gsm8k/train.parquet"}
|
| 9 |
+
TEST_FILE=${TEST_FILE:-"${RAY_DATA_HOME}/data/gsm8k/test.parquet"}
|
| 10 |
+
|
| 11 |
+
python3 -m verl.trainer.main_ppo \
|
| 12 |
+
algorithm.adv_estimator=grpo \
|
| 13 |
+
data.train_files="${TRAIN_FILE}" \
|
| 14 |
+
data.val_files="${TEST_FILE}" \
|
| 15 |
+
data.train_batch_size=1024 \
|
| 16 |
+
data.max_prompt_length=2048 \
|
| 17 |
+
data.max_response_length=2048 \
|
| 18 |
+
data.filter_overlong_prompts=True \
|
| 19 |
+
data.truncation='error' \
|
| 20 |
+
data.shuffle=False \
|
| 21 |
+
actor_rollout_ref.model.path=${MODEL_PATH} \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.actor.ulysses_sequence_parallel_size=4 \
|
| 25 |
+
+actor_rollout_ref.actor.fsdp_config.mixed_precision.param_dtype=bf16 \
|
| 26 |
+
+actor_rollout_ref.actor.fsdp_config.mixed_precision.reduce_dtype=bf16 \
|
| 27 |
+
+actor_rollout_ref.actor.fsdp_config.mixed_precision.buffer_dtype=fp32 \
|
| 28 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
|
| 29 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=8 \
|
| 30 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 31 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 32 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 33 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 34 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 35 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 36 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 37 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
|
| 38 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \
|
| 39 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 40 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \
|
| 41 |
+
actor_rollout_ref.rollout.n=4 \
|
| 42 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \
|
| 43 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 44 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 45 |
+
actor_rollout_ref.ref.use_torch_compile=False \
|
| 46 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=True \
|
| 47 |
+
actor_rollout_ref.rollout.max_num_batched_tokens=32768 \
|
| 48 |
+
algorithm.use_kl_in_reward=False \
|
| 49 |
+
trainer.critic_warmup=0 \
|
| 50 |
+
trainer.logger=['console','tensorboard'] \
|
| 51 |
+
trainer.project_name="${project_name}" \
|
| 52 |
+
trainer.experiment_name="${exp_name}" \
|
| 53 |
+
trainer.n_gpus_per_node=8 \
|
| 54 |
+
trainer.nnodes=4 \
|
| 55 |
+
trainer.resume_from_path=checkpoints/ \
|
| 56 |
+
trainer.save_freq=500 \
|
| 57 |
+
trainer.test_freq=50 \
|
| 58 |
+
trainer.total_epochs=50 \
|
| 59 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen3-8b.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Tested successfully on the hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.4-flashinfer0.2.2-cxx11abi0 image.
|
| 2 |
+
# It outperforms the Qwen2 7B base model by two percentage points on the test set of GSM8K.
|
| 3 |
+
|
| 4 |
+
set -x
|
| 5 |
+
|
| 6 |
+
python3 -m verl.trainer.main_ppo \
|
| 7 |
+
algorithm.adv_estimator=grpo \
|
| 8 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 9 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 10 |
+
data.train_batch_size=1024 \
|
| 11 |
+
data.max_prompt_length=512 \
|
| 12 |
+
data.max_response_length=1024 \
|
| 13 |
+
data.filter_overlong_prompts=True \
|
| 14 |
+
data.truncation='error' \
|
| 15 |
+
actor_rollout_ref.model.path=Qwen/Qwen3-8B \
|
| 16 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 17 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 18 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 19 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \
|
| 20 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 21 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 22 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 23 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 24 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 25 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 26 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 27 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 28 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 29 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 30 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 31 |
+
actor_rollout_ref.rollout.n=5 \
|
| 32 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \
|
| 33 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 34 |
+
algorithm.use_kl_in_reward=False \
|
| 35 |
+
trainer.critic_warmup=0 \
|
| 36 |
+
trainer.logger='["console","wandb"]' \
|
| 37 |
+
trainer.project_name='verl_grpo_example_gsm8k' \
|
| 38 |
+
trainer.experiment_name='qwen3_8b_function_rm' \
|
| 39 |
+
trainer.n_gpus_per_node=8 \
|
| 40 |
+
trainer.nnodes=1 \
|
| 41 |
+
trainer.save_freq=20 \
|
| 42 |
+
trainer.test_freq=5 \
|
| 43 |
+
trainer.total_epochs=15 $@
|
verl/examples/grpo_trainer/run_qwen3-8b_npu.sh
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
project_name='GRPO-Qwen3'
|
| 4 |
+
exp_name='GRPO-Qwen3-8B-npu'
|
| 5 |
+
gen_tp=2
|
| 6 |
+
RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"}
|
| 7 |
+
MODEL_PATH=${MODEL_PATH:-"${RAY_DATA_HOME}/models/Qwen3-8B"}
|
| 8 |
+
CKPTS_DIR=${CKPTS_DIR:-"${RAY_DATA_HOME}/ckpts/${project_name}/${exp_name}"}
|
| 9 |
+
TRAIN_FILE=${TRAIN_FILE:-"${RAY_DATA_HOME}/data/dapo-math-17k.parquet"}
|
| 10 |
+
TEST_FILE=${TEST_FILE:-"${RAY_DATA_HOME}/data/aime-2024.parquet"}
|
| 11 |
+
|
| 12 |
+
python3 -m verl.trainer.main_ppo \
|
| 13 |
+
algorithm.adv_estimator=grpo \
|
| 14 |
+
data.train_files="${TRAIN_FILE}" \
|
| 15 |
+
data.val_files="${TEST_FILE}" \
|
| 16 |
+
data.train_batch_size=256 \
|
| 17 |
+
data.max_prompt_length=512 \
|
| 18 |
+
data.max_response_length=1024 \
|
| 19 |
+
data.filter_overlong_prompts=True \
|
| 20 |
+
data.truncation='error' \
|
| 21 |
+
actor_rollout_ref.model.path=${MODEL_PATH} \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
|
| 25 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \
|
| 26 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 27 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 28 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 29 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 30 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 31 |
+
actor_rollout_ref.ref.use_torch_compile=False \
|
| 32 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 33 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 34 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 35 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 36 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \
|
| 37 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 38 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 39 |
+
actor_rollout_ref.rollout.n=5 \
|
| 40 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \
|
| 41 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 42 |
+
algorithm.use_kl_in_reward=False \
|
| 43 |
+
trainer.critic_warmup=0 \
|
| 44 |
+
trainer.logger='["console","wandb"]' \
|
| 45 |
+
trainer.project_name="${project_name}" \
|
| 46 |
+
trainer.experiment_name="${exp_name}" \
|
| 47 |
+
trainer.n_gpus_per_node=8 \
|
| 48 |
+
trainer.nnodes=1 \
|
| 49 |
+
trainer.default_local_dir=${CKPTS_DIR} \
|
| 50 |
+
trainer.device=npu \
|
| 51 |
+
trainer.resume_mode=auto \
|
| 52 |
+
actor_rollout_ref.actor.fsdp_config.forward_prefetch=True \
|
| 53 |
+
actor_rollout_ref.ref.fsdp_config.forward_prefetch=True \
|
| 54 |
+
++actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
|
| 55 |
+
++actor_rollout_ref.ref.entropy_from_logits_with_chunking=True \
|
| 56 |
+
trainer.val_before_train=True \
|
| 57 |
+
trainer.save_freq=5 \
|
| 58 |
+
trainer.test_freq=5 \
|
| 59 |
+
trainer.total_epochs=15
|
verl/examples/grpo_trainer/run_qwen3_8b_grpo_sglang_1k_spmd_npu.sh
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
export HCCL_CONNECT_TIMEOUT=1500
|
| 3 |
+
export HCCL_HOST_SOCKET_PORT_RANGE=60000-60050
|
| 4 |
+
export HCCL_NPU_SOCKET_PORT_RANGE=61000-61050
|
| 5 |
+
|
| 6 |
+
# WORKSPACE_HOME and DATA_HOME support custom path configuration.
|
| 7 |
+
WORKSPACE_HOME=$pwd
|
| 8 |
+
DATA_HOME=$pwd
|
| 9 |
+
|
| 10 |
+
sp_size=4
|
| 11 |
+
num_npu=4
|
| 12 |
+
tp_size=4
|
| 13 |
+
train_prompt_bsz=16
|
| 14 |
+
train_prompt_mini_bsz=16
|
| 15 |
+
|
| 16 |
+
max_prompt_length=512
|
| 17 |
+
max_response_length=1024
|
| 18 |
+
|
| 19 |
+
CKPTS_DIR=$WORKSPACE_HOME/logs/ckpt/qwen3_8b
|
| 20 |
+
model_path=$DATA_HOME/models/Qwen3-8B
|
| 21 |
+
train_data=$DATA_HOME/datasets/processed_gsm8k/train.parquet
|
| 22 |
+
valid_data=$DATA_HOME/datasets/processed_gsm8k/test.parquet
|
| 23 |
+
|
| 24 |
+
python3 -m verl.trainer.main_ppo \
|
| 25 |
+
algorithm.adv_estimator=grpo \
|
| 26 |
+
data.train_files=$train_data \
|
| 27 |
+
data.val_files=$valid_data \
|
| 28 |
+
data.train_batch_size=$train_prompt_bsz \
|
| 29 |
+
data.max_prompt_length=$max_prompt_length \
|
| 30 |
+
data.max_response_length=$max_response_length \
|
| 31 |
+
data.filter_overlong_prompts=True \
|
| 32 |
+
data.truncation='error' \
|
| 33 |
+
actor_rollout_ref.model.path=$model_path \
|
| 34 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 35 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 36 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=$train_prompt_mini_bsz \
|
| 37 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
|
| 38 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 39 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 40 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 41 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 42 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 43 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 44 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 45 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=True \
|
| 46 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \
|
| 47 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=$tp_size \
|
| 48 |
+
actor_rollout_ref.rollout.name=sglang \
|
| 49 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.3 \
|
| 50 |
+
actor_rollout_ref.rollout.n=5 \
|
| 51 |
+
+actor_rollout_ref.rollout.engine_kwargs.sglang.attention_backend="ascend" \
|
| 52 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 53 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 54 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=2 \
|
| 55 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 56 |
+
actor_rollout_ref.nccl_timeout=1800 \
|
| 57 |
+
algorithm.use_kl_in_reward=False \
|
| 58 |
+
trainer.critic_warmup=0 \
|
| 59 |
+
trainer.logger=console \
|
| 60 |
+
trainer.val_before_train=False \
|
| 61 |
+
trainer.project_name='verl_grpo_example_512_1024_gsm8k' \
|
| 62 |
+
trainer.experiment_name='qwen3_8b_function_rm' \
|
| 63 |
+
trainer.n_gpus_per_node=$num_npu \
|
| 64 |
+
trainer.nnodes=1 \
|
| 65 |
+
trainer.save_freq=1000 \
|
| 66 |
+
trainer.test_freq=10000 \
|
| 67 |
+
trainer.total_epochs=5 \
|
| 68 |
+
trainer.default_local_dir="${CKPTS_DIR}" \
|
| 69 |
+
actor_rollout_ref.actor.ulysses_sequence_parallel_size=${sp_size} \
|
| 70 |
+
actor_rollout_ref.ref.ulysses_sequence_parallel_size=${sp_size} \
|
| 71 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen3_8b_grpo_sglang_32k_spmd_npu.sh
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
export HCCL_CONNECT_TIMEOUT=1500
|
| 3 |
+
export HCCL_HOST_SOCKET_PORT_RANGE=60000-60050
|
| 4 |
+
export HCCL_NPU_SOCKET_PORT_RANGE=61000-61050
|
| 5 |
+
|
| 6 |
+
# WORKSPACE_HOME and DATA_HOME support custom path configuration.
|
| 7 |
+
WORKSPACE_HOME=$pwd
|
| 8 |
+
DATA_HOME=$pwd
|
| 9 |
+
|
| 10 |
+
sp_size=4
|
| 11 |
+
num_gpu=8
|
| 12 |
+
tp_size=4
|
| 13 |
+
train_prompt_bsz=16
|
| 14 |
+
train_prompt_mini_bsz=16
|
| 15 |
+
|
| 16 |
+
max_prompt_length=$((1024 * 2))
|
| 17 |
+
max_response_length=$((1024 * 32))
|
| 18 |
+
|
| 19 |
+
CKPTS_DIR=$WORKSPACE_HOME/logs/ckpt/qwen3_8b
|
| 20 |
+
model_path=$DATA_HOME/models/Qwen3-8B
|
| 21 |
+
train_data=$DATA_HOME/datasets/dapo/dapo-math-17k.parquet
|
| 22 |
+
valid_data=$DATA_HOME/datasets/dapo/aime-2024.parquet
|
| 23 |
+
|
| 24 |
+
python3 -m verl.trainer.main_ppo \
|
| 25 |
+
algorithm.adv_estimator=grpo \
|
| 26 |
+
data.train_files=$train_data \
|
| 27 |
+
data.val_files=$valid_data \
|
| 28 |
+
data.train_batch_size=$train_prompt_bsz \
|
| 29 |
+
data.max_prompt_length=$max_prompt_length \
|
| 30 |
+
data.max_response_length=$max_response_length \
|
| 31 |
+
data.filter_overlong_prompts=False \
|
| 32 |
+
data.truncation='error' \
|
| 33 |
+
actor_rollout_ref.model.path=$model_path \
|
| 34 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 35 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 36 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=$train_prompt_mini_bsz \
|
| 37 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
|
| 38 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 39 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 40 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 41 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 42 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 43 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 44 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 45 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=True \
|
| 46 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
|
| 47 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=$tp_size \
|
| 48 |
+
actor_rollout_ref.rollout.name=sglang \
|
| 49 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.3 \
|
| 50 |
+
actor_rollout_ref.rollout.n=5 \
|
| 51 |
+
+actor_rollout_ref.rollout.engine_kwargs.sglang.attention_backend="ascend" \
|
| 52 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 53 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
|
| 54 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
|
| 55 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 56 |
+
actor_rollout_ref.nccl_timeout=3600 \
|
| 57 |
+
algorithm.use_kl_in_reward=False \
|
| 58 |
+
trainer.critic_warmup=0 \
|
| 59 |
+
trainer.logger=console \
|
| 60 |
+
trainer.val_before_train=False \
|
| 61 |
+
trainer.project_name='verl_grpo_example_2k_32k' \
|
| 62 |
+
trainer.experiment_name='qwen3_8b_function_rm' \
|
| 63 |
+
trainer.n_gpus_per_node=$num_gpu \
|
| 64 |
+
trainer.nnodes=1 \
|
| 65 |
+
trainer.save_freq=1000 \
|
| 66 |
+
trainer.test_freq=10000 \
|
| 67 |
+
trainer.total_epochs=5 \
|
| 68 |
+
trainer.default_local_dir="${CKPTS_DIR}" \
|
| 69 |
+
actor_rollout_ref.actor.ulysses_sequence_parallel_size=${sp_size} \
|
| 70 |
+
actor_rollout_ref.ref.ulysses_sequence_parallel_size=${sp_size} \
|
| 71 |
+
trainer.device=npu $@
|
verl/examples/grpo_trainer/run_qwen3moe-30b_megatron_96gb.sh
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
# tested in NNODES=1~4 * 96G H20 GPU
|
| 4 |
+
NNODES=${NNODES:-1}
|
| 5 |
+
NGPUS_PER_NODES=${NGPUS_PER_NODES:-8}
|
| 6 |
+
|
| 7 |
+
project_name='DAPO-Qwen3-30b-MATH'
|
| 8 |
+
exp_name='DAPO-Qwen3-30b-MATH-megatron'
|
| 9 |
+
|
| 10 |
+
adv_estimator=grpo
|
| 11 |
+
|
| 12 |
+
use_kl_in_reward=False
|
| 13 |
+
kl_coef=0.0
|
| 14 |
+
use_kl_loss=False
|
| 15 |
+
kl_loss_coef=0.0
|
| 16 |
+
|
| 17 |
+
clip_ratio_low=0.2
|
| 18 |
+
clip_ratio_high=0.28
|
| 19 |
+
max_prompt_length=$((1024 * 2))
|
| 20 |
+
max_response_length=$((1024 * 8))
|
| 21 |
+
enable_overlong_buffer=True
|
| 22 |
+
overlong_buffer_len=$((1024 * 4))
|
| 23 |
+
overlong_penalty_factor=1.0
|
| 24 |
+
|
| 25 |
+
loss_agg_mode="token-mean"
|
| 26 |
+
|
| 27 |
+
train_prompt_bsz=512
|
| 28 |
+
n_resp_per_prompt=16
|
| 29 |
+
train_prompt_mini_bsz=128
|
| 30 |
+
train_ppo_micro_batch_size_per_gpu=2
|
| 31 |
+
infer_ppo_micro_batch_size_per_gpu=2
|
| 32 |
+
# Paths
|
| 33 |
+
MODEL_PATH=Qwen/Qwen3-30B-A3B
|
| 34 |
+
|
| 35 |
+
RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"}
|
| 36 |
+
TRAIN_FILE=$RAY_DATA_HOME/dataset/dapo-math-17k.parquet
|
| 37 |
+
TEST_FILE=$RAY_DATA_HOME/dataset/aime-2024.parquet
|
| 38 |
+
TEST_FILE="['$aime24_test_path']"
|
| 39 |
+
|
| 40 |
+
# Algorithm
|
| 41 |
+
temperature=1.0
|
| 42 |
+
top_p=1.0
|
| 43 |
+
top_k=-1 # 0 for HF rollout, -1 for vLLM rollout
|
| 44 |
+
val_top_p=0.7
|
| 45 |
+
|
| 46 |
+
# Performance Related Parameter
|
| 47 |
+
use_dynamic_bsz=True
|
| 48 |
+
actor_ppo_max_token_len=$(((max_prompt_length + max_response_length)))
|
| 49 |
+
infer_ppo_max_token_len=$(((max_prompt_length + max_response_length)))
|
| 50 |
+
offload=True
|
| 51 |
+
|
| 52 |
+
optimizer_offload_fraction=${OFFLOAD_FRACTION:-1.}
|
| 53 |
+
|
| 54 |
+
COMMON_PP=${COMMON_PP:-1}
|
| 55 |
+
COMMON_VPP=${COMMON_VPP:-null}
|
| 56 |
+
COMMON_CP=${COMMON_CP:-1}
|
| 57 |
+
COMMON_TP=${COMMON_TP:-1}
|
| 58 |
+
COMMON_EP=${COMMON_EP:-8}
|
| 59 |
+
COMMON_ETP=${COMMON_ETP:-1}
|
| 60 |
+
|
| 61 |
+
TRAIN_TP=${TRAIN_TP:-$COMMON_TP}
|
| 62 |
+
INFER_TP=${INFER_TP:-4}
|
| 63 |
+
|
| 64 |
+
ACTOR_PP=${ACTOR_PP:-$COMMON_PP}
|
| 65 |
+
ACTOR_VPP=${ACTOR_VPP:-$COMMON_VPP}
|
| 66 |
+
ACTOR_CP=${ACTOR_CP:-$COMMON_CP}
|
| 67 |
+
ACTOR_TP=${ACTOR_TP:-$TRAIN_TP}
|
| 68 |
+
ACTOR_EP=${ACTOR_EP:-$COMMON_EP}
|
| 69 |
+
ACTOR_ETP=${ACTOR_ETP:-$COMMON_ETP}
|
| 70 |
+
ROLLOUT_TP=${ROLLOUT_TP:-$INFER_TP}
|
| 71 |
+
REF_PP=${REF_PP:-$COMMON_PP}
|
| 72 |
+
REF_VPP=${REF_VPP:-$COMMON_VPP}
|
| 73 |
+
REF_CP=${REF_CP:-$COMMON_CP}
|
| 74 |
+
REF_TP=${REF_TP:-$TRAIN_TP}
|
| 75 |
+
REF_EP=${REF_EP:-$COMMON_EP}
|
| 76 |
+
REF_ETP=${REF_ETP:-$COMMON_ETP}
|
| 77 |
+
CRITIC_PP=${CRITIC_PP:-$COMMON_PP}
|
| 78 |
+
CRITIC_VPP=${CRITIC_VPP:-$COMMON_VPP}
|
| 79 |
+
CRITIC_CP=${CRITIC_CP:-$COMMON_CP}
|
| 80 |
+
CRITIC_TP=${CRITIC_TP:-$TRAIN_TP}
|
| 81 |
+
CRITIC_EP=${CRITIC_EP:-$COMMON_EP}
|
| 82 |
+
CRITIC_ETP=${CRITIC_ETP:-$COMMON_ETP}
|
| 83 |
+
RM_PP=${RM_PP:-$COMMON_PP}
|
| 84 |
+
RM_VPP=${RM_VPP:-$COMMON_VPP}
|
| 85 |
+
RM_CP=${RM_CP:-$COMMON_CP}
|
| 86 |
+
RM_TP=${RM_TP:-$TRAIN_TP}
|
| 87 |
+
RM_EP=${RM_EP:-$COMMON_EP}
|
| 88 |
+
RM_ETP=${RM_ETP:-$COMMON_ETP}
|
| 89 |
+
|
| 90 |
+
# install mbridge
|
| 91 |
+
# pip3 install git+https://github.com/ISEEKYAN/mbridge
|
| 92 |
+
USE_MBRIDGE=True
|
| 93 |
+
USE_DIST_CKPT=False
|
| 94 |
+
|
| 95 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 96 |
+
data.train_files="${TRAIN_FILE}" \
|
| 97 |
+
data.val_files="${TEST_FILE}" \
|
| 98 |
+
data.prompt_key=prompt \
|
| 99 |
+
data.truncation='left' \
|
| 100 |
+
data.max_prompt_length=${max_prompt_length} \
|
| 101 |
+
data.max_response_length=${max_response_length} \
|
| 102 |
+
data.train_batch_size=${train_prompt_bsz} \
|
| 103 |
+
actor_rollout_ref.rollout.n=${n_resp_per_prompt} \
|
| 104 |
+
algorithm.adv_estimator=${adv_estimator} \
|
| 105 |
+
algorithm.use_kl_in_reward=${use_kl_in_reward} \
|
| 106 |
+
algorithm.kl_ctrl.kl_coef=${kl_coef} \
|
| 107 |
+
actor_rollout_ref.model.path="${MODEL_PATH}" \
|
| 108 |
+
actor_rollout_ref.actor.use_kl_loss=${use_kl_loss} \
|
| 109 |
+
actor_rollout_ref.actor.kl_loss_coef=${kl_loss_coef} \
|
| 110 |
+
actor_rollout_ref.actor.clip_ratio_low=${clip_ratio_low} \
|
| 111 |
+
actor_rollout_ref.actor.clip_ratio_high=${clip_ratio_high} \
|
| 112 |
+
actor_rollout_ref.actor.clip_ratio_c=10.0 \
|
| 113 |
+
+actor_rollout_ref.model.override_config.model_config.max_position_embeddings=$((max_prompt_length + max_response_length)) \
|
| 114 |
+
actor_rollout_ref.model.use_fused_kernels=False \
|
| 115 |
+
actor_rollout_ref.actor.use_dynamic_bsz=${use_dynamic_bsz} \
|
| 116 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz} \
|
| 117 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=${train_ppo_micro_batch_size_per_gpu} \
|
| 118 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len} \
|
| 119 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 120 |
+
actor_rollout_ref.actor.optim.lr_warmup_steps=10 \
|
| 121 |
+
actor_rollout_ref.actor.optim.lr_decay_style='constant' \
|
| 122 |
+
actor_rollout_ref.actor.optim.weight_decay=0.1 \
|
| 123 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_offload_fraction=${optimizer_offload_fraction} \
|
| 124 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.overlap_cpu_optimizer_d2h_h2d=True \
|
| 125 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.use_precision_aware_optimizer=True \
|
| 126 |
+
+actor_rollout_ref.actor.optim.override_optimizer_config.optimizer_cpu_offload=True \
|
| 127 |
+
actor_rollout_ref.actor.megatron.use_mbridge=$USE_MBRIDGE \
|
| 128 |
+
actor_rollout_ref.actor.megatron.use_dist_checkpointing=$USE_DIST_CKPT \
|
| 129 |
+
actor_rollout_ref.actor.megatron.param_offload=${offload} \
|
| 130 |
+
actor_rollout_ref.actor.megatron.grad_offload=${offload} \
|
| 131 |
+
actor_rollout_ref.actor.megatron.optimizer_offload=${offload} \
|
| 132 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=${ACTOR_TP} \
|
| 133 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=${ACTOR_PP} \
|
| 134 |
+
actor_rollout_ref.actor.megatron.virtual_pipeline_model_parallel_size=${ACTOR_VPP} \
|
| 135 |
+
actor_rollout_ref.actor.megatron.context_parallel_size=${ACTOR_CP} \
|
| 136 |
+
actor_rollout_ref.actor.megatron.expert_model_parallel_size=${ACTOR_EP} \
|
| 137 |
+
actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=${ACTOR_ETP} \
|
| 138 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.apply_rope_fusion=True \
|
| 139 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.masked_softmax_fusion=True \
|
| 140 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.bias_activation_fusion=True \
|
| 141 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.bias_dropout_fusion=True \
|
| 142 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.gradient_accumulation_fusion=True \
|
| 143 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.deallocate_pipeline_outputs=True \
|
| 144 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.persist_layer_norm=True \
|
| 145 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_grouped_gemm=True \
|
| 146 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_permute_fusion=True \
|
| 147 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_token_dispatcher_type="flex" \
|
| 148 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_router_dtype=fp32 \
|
| 149 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_enable_deepep=True \
|
| 150 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 151 |
+
actor_rollout_ref.actor.loss_agg_mode=${loss_agg_mode} \
|
| 152 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=${infer_ppo_micro_batch_size_per_gpu} \
|
| 153 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
|
| 154 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \
|
| 155 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=${INFER_TP} \
|
| 156 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=True \
|
| 157 |
+
actor_rollout_ref.rollout.max_num_batched_tokens=$((max_prompt_length + max_response_length)) \
|
| 158 |
+
actor_rollout_ref.rollout.temperature=${temperature} \
|
| 159 |
+
actor_rollout_ref.rollout.top_p=${top_p} \
|
| 160 |
+
actor_rollout_ref.rollout.top_k=${top_k} \
|
| 161 |
+
actor_rollout_ref.rollout.val_kwargs.temperature=${temperature} \
|
| 162 |
+
actor_rollout_ref.rollout.val_kwargs.top_p=${val_top_p} \
|
| 163 |
+
actor_rollout_ref.rollout.val_kwargs.top_k=${top_k} \
|
| 164 |
+
actor_rollout_ref.rollout.val_kwargs.do_sample=True \
|
| 165 |
+
actor_rollout_ref.rollout.val_kwargs.n=1 \
|
| 166 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 167 |
+
actor_rollout_ref.rollout.enforce_eager=True \
|
| 168 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 169 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=${infer_ppo_micro_batch_size_per_gpu} \
|
| 170 |
+
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
|
| 171 |
+
actor_rollout_ref.ref.megatron.use_dist_checkpointing=${USE_DIST_CKPT} \
|
| 172 |
+
actor_rollout_ref.ref.megatron.param_offload=${offload} \
|
| 173 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=${REF_TP} \
|
| 174 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=${REF_PP} \
|
| 175 |
+
actor_rollout_ref.ref.megatron.virtual_pipeline_model_parallel_size=${REF_VPP} \
|
| 176 |
+
actor_rollout_ref.ref.megatron.context_parallel_size=${REF_CP} \
|
| 177 |
+
actor_rollout_ref.ref.megatron.expert_model_parallel_size=${REF_EP} \
|
| 178 |
+
actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=${REF_ETP} \
|
| 179 |
+
reward_model.reward_manager=dapo \
|
| 180 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.enable=${enable_overlong_buffer} \
|
| 181 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.len=${overlong_buffer_len} \
|
| 182 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.penalty_factor=${overlong_penalty_factor} \
|
| 183 |
+
+reward_model.reward_kwargs.overlong_buffer_cfg.log=False \
|
| 184 |
+
+reward_model.reward_kwargs.max_resp_len=${max_response_length} \
|
| 185 |
+
trainer.logger=['console','wandb'] \
|
| 186 |
+
trainer.project_name="${project_name}" \
|
| 187 |
+
trainer.experiment_name="${exp_name}" \
|
| 188 |
+
trainer.n_gpus_per_node="${NGPUS_PER_NODES}" \
|
| 189 |
+
trainer.nnodes="${NNODES}" \
|
| 190 |
+
trainer.val_before_train=False \
|
| 191 |
+
trainer.test_freq=10 \
|
| 192 |
+
trainer.save_freq=100 \
|
| 193 |
+
trainer.total_epochs=10 \
|
| 194 |
+
trainer.resume_mode=auto \
|
| 195 |
+
trainer.log_val_generations=10
|
verl/examples/grpo_trainer/run_seed_oss_36b.sh
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
algorithm.adv_estimator=grpo \
|
| 5 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 6 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 7 |
+
data.train_batch_size=64 \
|
| 8 |
+
data.max_prompt_length=512 \
|
| 9 |
+
data.max_response_length=1024 \
|
| 10 |
+
data.filter_overlong_prompts=True \
|
| 11 |
+
data.truncation='error' \
|
| 12 |
+
actor_rollout_ref.model.path=ByteDance-Seed/Seed-OSS-36B-Base \
|
| 13 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 14 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 15 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 16 |
+
actor_rollout_ref.model.use_fused_kernels=True \
|
| 17 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=8 \
|
| 18 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \
|
| 19 |
+
actor_rollout_ref.actor.use_kl_loss=True \
|
| 20 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 21 |
+
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
|
| 22 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 23 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 24 |
+
actor_rollout_ref.actor.strategy=fsdp2 \
|
| 25 |
+
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True \
|
| 26 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 27 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 28 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \
|
| 29 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 30 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 31 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 32 |
+
actor_rollout_ref.rollout.n=2 \
|
| 33 |
+
actor_rollout_ref.rollout.free_cache_engine=True \
|
| 34 |
+
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True \
|
| 35 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=2 \
|
| 36 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 37 |
+
actor_rollout_ref.ref.strategy=fsdp2 \
|
| 38 |
+
algorithm.use_kl_in_reward=False \
|
| 39 |
+
trainer.critic_warmup=0 \
|
| 40 |
+
trainer.logger='["console"]' \
|
| 41 |
+
trainer.project_name='verl_grpo_seed_oss_36b' \
|
| 42 |
+
trainer.experiment_name='seed_oss_36b' \
|
| 43 |
+
trainer.val_before_train=False \
|
| 44 |
+
trainer.n_gpus_per_node=8 \
|
| 45 |
+
trainer.nnodes=1 \
|
| 46 |
+
trainer.save_freq=20 \
|
| 47 |
+
trainer.test_freq=5 \
|
| 48 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Proximal Policy Optimization (PPO)
|
| 2 |
+
|
| 3 |
+
Proximal Policy Optimization (PPO) is a family of policy gradient methods for reinforcement learning, proposed by OpenAI in 2017. PPO strikes a balance between simplicity, stability, and performance, making it one of the most widely used algorithms in modern RL applications, including large-scale language model fine-tuning.
|
| 4 |
+
|
| 5 |
+
Traditional policy gradient methods like REINFORCE or Vanilla Policy Gradient suffer from:
|
| 6 |
+
|
| 7 |
+
- High variance and sample inefficiency.
|
| 8 |
+
- Instability due to large policy updates.
|
| 9 |
+
|
| 10 |
+
PPO addresses this problem using a clipped surrogate objective that avoids overly large updates without requiring second-order derivatives.
|
| 11 |
+
|
| 12 |
+
For more technical details regarding PPO, we suggest reading the introduction in the [OpenAI spinning up tutorial](https://spinningup.openai.com/en/latest/algorithms/ppo.html), and the paper [Proximal Policy Optimization Algorithms](https://arxiv.org/abs/1707.06347).
|
| 13 |
+
|
| 14 |
+
## Key Components
|
| 15 |
+
|
| 16 |
+
- Actor-Critic Architecture: PPO requires both an actor model (policy) and a critic model (value function). This differs from other algorithms like GRPO and RLOO that don't require a critic model.
|
| 17 |
+
|
| 18 |
+
- Generalized Advantage Estimation (GAE): PPO uses GAE for computing advantage values, which helps reduce variance in policy gradient estimates while maintaining low bias.
|
| 19 |
+
|
| 20 |
+
- Clipped Surrogate Objective: The core of PPO is implemented through the clipped surrogate objective function that limits policy updates.
|
| 21 |
+
|
| 22 |
+
## Configuration
|
| 23 |
+
|
| 24 |
+
Note that all configs containing `micro_batch_size` are used to configure the maximum sample or token count per forward or backward pass to avoid GPU OOMs, whose value should not change algorithmic/convergence behavior.
|
| 25 |
+
|
| 26 |
+
Most critic configs are similar to those of actors. Note that the critic model is omitted from the figure below.
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
|
| 30 |
+
- `data.train_batch_size`: The global batch size of prompts used to generate a set of sampled trajectories/rollouts. The number of responses/trajectories is `data.train_batch_size * actor_rollout.ref.rollout.n`
|
| 31 |
+
|
| 32 |
+
- `actor_rollout_ref.actor.ppo_mini_batch_size`: The set of sampled trajectories is split into multiple mini-batches with batch_size=ppo_mini_batch_size for PPO actor updates. The ppo_mini_batch_size is a global size across all workers
|
| 33 |
+
|
| 34 |
+
- `actor_rollout_ref.critic.ppo_mini_batch_size`: The set of sampled trajectories is split into multiple mini-batches with batch_size=ppo_mini_batch_size for PPO critic updates. The ppo_mini_batch_size is a global size across all workers
|
| 35 |
+
|
| 36 |
+
- `actor_rollout_ref.actor.clip_ratio`: The PPO clip range. Default to 0.2
|
| 37 |
+
|
| 38 |
+
- `actor_rollout_ref.actor.ppo_epochs`: Number of epochs for PPO updates on one set of sampled trajectories for actor
|
| 39 |
+
|
| 40 |
+
- `critic.ppo_epochs`: Number of epochs for PPO updates on one set of sampled trajectories for critic. Defaults to `actor_rollout_ref.actor.ppo_epochs`
|
| 41 |
+
|
| 42 |
+
- `algorithm.gamma`: discount factor
|
| 43 |
+
|
| 44 |
+
- `algorithm.lam`: The lambda term that trades off between bias and variance in the GAE estimator
|
| 45 |
+
|
| 46 |
+
- `algorithm.adv_estimator`: Support gae, grpo, reinforce_plus_plus, reinforce_plus_plus_baseline, rloo, rloo_vectorized
|
| 47 |
+
|
| 48 |
+
## Advanced Extensions
|
| 49 |
+
|
| 50 |
+
### KL Divergence Control
|
| 51 |
+
|
| 52 |
+
Options to prevent the policy from diverging too far from a reference policy. Two mechanisms are available: KL reward penalty and KL loss. For more technical details, see [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155)
|
| 53 |
+
|
| 54 |
+
Options to use KL loss for KL divergence control:
|
| 55 |
+
|
| 56 |
+
- `actor_rollout_ref.actor.use_kl_loss`: to use kl loss in the actor. When used, we are not applying KL in the reward function. Default is False
|
| 57 |
+
|
| 58 |
+
- `actor_rollout_ref.actor.kl_loss_coef`: The coefficient of kl loss. Default is 0.001.
|
| 59 |
+
|
| 60 |
+
- `actor_rollout_ref.actor.kl_loss_type`: Support kl(k1), abs, mse(k2), low_var_kl(k3) and full. Appending "+" in the end (e.g., 'k1+' and 'k3+') would apply straight through to employ k2 for unbiased gradient estimation, regardless of the kl value estimation (see https://github.com/volcengine/verl/pull/2953#issuecomment-3162113848 for more details). How to calculate the kl divergence between actor and reference policy. See this blog post for detailed analysis: http://joschu.net/blog/kl-approx.html
|
| 61 |
+
|
| 62 |
+
Options to use KL penalty in the reward:
|
| 63 |
+
|
| 64 |
+
- `algorithm.use_kl_in_reward`: Whether to enable in-reward kl penalty. Default is False.
|
| 65 |
+
|
| 66 |
+
- `algorithm.kl_penalty`: Support kl(k1), abs, mse(k2), low_var_kl(k3) and full. This defines the way to calculate the kl divergence between actor and reference policy. For specific options, refer to `kl_penalty` in core_algos.py. See this blog post for detailed analysis: http://joschu.net/blog/kl-approx.html
|
| 67 |
+
|
| 68 |
+
- `algorithm.kl_ctrl.kl_coef`: The (initial) coefficient of in-reward kl_penalty. Default is 0.001.
|
| 69 |
+
- `algorithm.kl_ctrl.type`: 'fixed' for FixedKLController and 'adaptive' for AdaptiveKLController.
|
| 70 |
+
- `algorithm.kl_ctrl.horizon`: See source code of AdaptiveKLController for details.
|
| 71 |
+
- `algorithm.kl_ctrl.target_kl`: See source code of AdaptiveKLController for details.
|
| 72 |
+
|
| 73 |
+
### Dual-clip PPO
|
| 74 |
+
|
| 75 |
+
The Dual-Clip PPO introduces a approach by applying a lower bound to the policy ratio when the advantage is less than zero, when multiplied by a large raito, does not exceed a specified lower bound.
|
| 76 |
+
|
| 77 |
+

|
| 78 |
+
|
| 79 |
+
- `actor_rollout_ref.actor.clip_ratio_c`: lower bound of the value for Dual-clip PPO, defaults to 3.0
|
| 80 |
+
|
| 81 |
+
## Reference Example
|
| 82 |
+
|
| 83 |
+
Qwen2.5 training log and commands: [link](https://github.com/eric-haibin-lin/verl-data/blob/experiments/gsm8k/Qwen2.5-0.5B-bsz256_2-prompt1024-resp512-0.567.log)
|
| 84 |
+
|
| 85 |
+
```bash
|
| 86 |
+
bash run_gemma.sh
|
| 87 |
+
trainer.n_gpus_per_node=1 \
|
| 88 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
|
| 89 |
+
trainer.logger=console \
|
| 90 |
+
critic.model.path=Qwen/Qwen2.5-0.5B-Instruct \
|
| 91 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-0.5B-Instruct \
|
| 92 |
+
data.train_batch_size=256 \
|
| 93 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
|
| 94 |
+
actor_rollout_ref.actor.ppo_micro_batch_size=2 \
|
| 95 |
+
critic.ppo_micro_batch_size=2
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
Reference performance with verl v0.2:
|
| 99 |
+
|
| 100 |
+
| Model | Method | Score | Link |
|
| 101 |
+
|-------------------------------|------------------|-------|------------------------------------------------------------------------------------------------|
|
| 102 |
+
| Qwen/Qwen2.5-0.5B-Instruct | pretrained model | 36.4 | [Qwen Blog](https://qwenlm.github.io/blog/qwen2.5-llm/) |
|
| 103 |
+
| Qwen/Qwen2.5-0.5B-Instruct | PPO | 56.7 | [PPO Command and Logs](https://github.com/eric-haibin-lin/verl-data/blob/experiments/gsm8k/Qwen2.5-0.5B-bsz256_2-prompt1024-resp512-0.567.log) |
|
verl/examples/ppo_trainer/run_deepseek7b_llm.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
algorithm.adv_estimator=gae \
|
| 5 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 6 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 7 |
+
data.train_batch_size=1024 \
|
| 8 |
+
data.max_prompt_length=512 \
|
| 9 |
+
data.max_response_length=512 \
|
| 10 |
+
data.filter_overlong_prompts=True \
|
| 11 |
+
data.truncation='error' \
|
| 12 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 13 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 14 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 15 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 16 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 17 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 18 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 19 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 20 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 21 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 22 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 23 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 24 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 25 |
+
critic.optim.lr=1e-5 \
|
| 26 |
+
critic.model.use_remove_padding=True \
|
| 27 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 28 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 29 |
+
critic.ppo_micro_batch_size_per_gpu=32 \
|
| 30 |
+
critic.model.fsdp_config.param_offload=False \
|
| 31 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 32 |
+
algorithm.use_kl_in_reward=False \
|
| 33 |
+
trainer.critic_warmup=0 \
|
| 34 |
+
trainer.logger='["console","wandb"]' \
|
| 35 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 36 |
+
trainer.experiment_name='deepseek_llm_7b_function_rm' \
|
| 37 |
+
trainer.n_gpus_per_node=8 \
|
| 38 |
+
trainer.nnodes=1 \
|
| 39 |
+
trainer.save_freq=20 \
|
| 40 |
+
trainer.test_freq=1 \
|
| 41 |
+
trainer.use_legacy_worker_impl=auto \
|
| 42 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_deepseek7b_llm_modelscope.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
VERL_USE_MODELSCOPE=True \
|
| 4 |
+
python3 -m verl.trainer.main_ppo \
|
| 5 |
+
algorithm.adv_estimator=gae \
|
| 6 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 7 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 8 |
+
data.train_batch_size=1024 \
|
| 9 |
+
data.max_prompt_length=512 \
|
| 10 |
+
data.max_response_length=512 \
|
| 11 |
+
data.filter_overlong_prompts=True \
|
| 12 |
+
data.truncation='error' \
|
| 13 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 14 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 15 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 16 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 17 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 18 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 19 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 20 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 21 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 22 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 23 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 24 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 25 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 26 |
+
critic.optim.lr=1e-5 \
|
| 27 |
+
critic.model.use_remove_padding=True \
|
| 28 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 29 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 30 |
+
critic.ppo_micro_batch_size_per_gpu=32 \
|
| 31 |
+
critic.model.fsdp_config.param_offload=False \
|
| 32 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 33 |
+
algorithm.use_kl_in_reward=False \
|
| 34 |
+
trainer.critic_warmup=0 \
|
| 35 |
+
trainer.logger='["console","wandb"]' \
|
| 36 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 37 |
+
trainer.experiment_name='deepseek_llm_7b_function_rm' \
|
| 38 |
+
trainer.n_gpus_per_node=8 \
|
| 39 |
+
trainer.nnodes=1 \
|
| 40 |
+
trainer.save_freq=20 \
|
| 41 |
+
trainer.test_freq=1 \
|
| 42 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_deepseek7b_llm_pfppo.sh
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
algorithm.adv_estimator=gae \
|
| 5 |
+
algorithm.use_pf_ppo=True \
|
| 6 |
+
algorithm.pf_ppo.reweight_method=pow \ # ["pow", "max_min", "max_random"]
|
| 7 |
+
algorithm.pf_ppo.weight_pow=2.0 \
|
| 8 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 9 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 10 |
+
data.train_batch_size=1024 \
|
| 11 |
+
data.max_prompt_length=512 \
|
| 12 |
+
data.max_response_length=512 \
|
| 13 |
+
data.filter_overlong_prompts=True \
|
| 14 |
+
data.truncation='error' \
|
| 15 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 16 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 17 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 18 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 19 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 20 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 21 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 22 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 23 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 24 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 25 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 26 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 27 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 28 |
+
actor_rollout_ref.rollout.n=5 \
|
| 29 |
+
critic.optim.lr=1e-5 \
|
| 30 |
+
critic.model.use_remove_padding=True \
|
| 31 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 32 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 33 |
+
critic.ppo_micro_batch_size_per_gpu=32 \
|
| 34 |
+
critic.model.fsdp_config.param_offload=False \
|
| 35 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 36 |
+
algorithm.use_kl_in_reward=False \
|
| 37 |
+
trainer.critic_warmup=0 \
|
| 38 |
+
trainer.logger='["console","wandb"]' \
|
| 39 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 40 |
+
trainer.experiment_name='deepseek_llm_7b_function_rm' \
|
| 41 |
+
trainer.n_gpus_per_node=8 \
|
| 42 |
+
trainer.nnodes=1 \
|
| 43 |
+
trainer.save_freq=20 \
|
| 44 |
+
trainer.test_freq=1 \
|
| 45 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_deepseek7b_llm_sandbox_fusion.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
reward_model.sandbox_fusion.url='https://xxxxxxxxx.apigateway-cn-beijing.volceapi.com/run_code' \
|
| 5 |
+
reward_model.sandbox_fusion.max_concurrent=128 \
|
| 6 |
+
reward_model.reward_manager=prime \
|
| 7 |
+
algorithm.adv_estimator=gae \
|
| 8 |
+
data.train_files=$HOME/data/Eurus-2-RL-Data/train.parquet \
|
| 9 |
+
data.val_files=$HOME/data/Eurus-2-RL-Data/validation.parquet \
|
| 10 |
+
data.train_batch_size=1024 \
|
| 11 |
+
data.max_prompt_length=512 \
|
| 12 |
+
data.max_response_length=512 \
|
| 13 |
+
data.filter_overlong_prompts=True \
|
| 14 |
+
data.truncation='error' \
|
| 15 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 16 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 17 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 18 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 19 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 20 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 21 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 22 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 23 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 24 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \
|
| 25 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 26 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 27 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 28 |
+
critic.optim.lr=1e-5 \
|
| 29 |
+
critic.model.use_remove_padding=True \
|
| 30 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 31 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 32 |
+
critic.ppo_micro_batch_size_per_gpu=32 \
|
| 33 |
+
critic.model.fsdp_config.param_offload=False \
|
| 34 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 35 |
+
algorithm.use_kl_in_reward=False \
|
| 36 |
+
trainer.critic_warmup=0 \
|
| 37 |
+
trainer.logger='["console","wandb"]' \
|
| 38 |
+
trainer.project_name='verl_example_sandbox_fusion' \
|
| 39 |
+
trainer.experiment_name='deepseek_llm_7b_function_sandbox_fusion' \
|
| 40 |
+
trainer.n_gpus_per_node=8 \
|
| 41 |
+
trainer.nnodes=1 \
|
| 42 |
+
trainer.save_freq=20 \
|
| 43 |
+
trainer.test_freq=1 \
|
| 44 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_deepseek7b_llm_sp2.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
algorithm.adv_estimator=gae \
|
| 5 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 6 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 7 |
+
data.train_batch_size=1024 \
|
| 8 |
+
data.max_prompt_length=512 \
|
| 9 |
+
data.max_response_length=512 \
|
| 10 |
+
data.filter_overlong_prompts=True \
|
| 11 |
+
data.truncation='error' \
|
| 12 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 13 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 14 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 15 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 16 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \
|
| 17 |
+
actor_rollout_ref.actor.ulysses_sequence_parallel_size=2 \
|
| 18 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 19 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 20 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 21 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 22 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=64 \
|
| 23 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 24 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 25 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 26 |
+
critic.optim.lr=1e-5 \
|
| 27 |
+
critic.ulysses_sequence_parallel_size=2 \
|
| 28 |
+
critic.model.use_remove_padding=True \
|
| 29 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 30 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 31 |
+
critic.ppo_micro_batch_size_per_gpu=64 \
|
| 32 |
+
critic.model.fsdp_config.param_offload=False \
|
| 33 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 34 |
+
algorithm.use_kl_in_reward=False \
|
| 35 |
+
trainer.critic_warmup=0 \
|
| 36 |
+
trainer.logger='["console","wandb"]' \
|
| 37 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 38 |
+
trainer.experiment_name='deepseek_llm_7b_function_rm_sp2' \
|
| 39 |
+
trainer.n_gpus_per_node=8 \
|
| 40 |
+
trainer.nnodes=1 \
|
| 41 |
+
trainer.save_freq=20 \
|
| 42 |
+
trainer.test_freq=5 \
|
| 43 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_deepseek_full_hh_rlhf.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
train_files=$HOME/data/full_hh_rlhf/rl/train.parquet
|
| 4 |
+
test_files=$HOME/data/full_hh_rlhf/rl/train.parquet # no use
|
| 5 |
+
|
| 6 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 7 |
+
algorithm.adv_estimator=gae \
|
| 8 |
+
data.train_files="$train_files" \
|
| 9 |
+
data.val_files="$test_files" \
|
| 10 |
+
data.train_batch_size=512 \
|
| 11 |
+
data.max_prompt_length=128 \
|
| 12 |
+
data.max_response_length=128 \
|
| 13 |
+
data.filter_overlong_prompts=True \
|
| 14 |
+
data.truncation='error' \
|
| 15 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 16 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 17 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 18 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 19 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 20 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 21 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 22 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 23 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 24 |
+
critic.optim.lr=1e-5 \
|
| 25 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 26 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 27 |
+
reward_model.enable=True \
|
| 28 |
+
reward_model.megatron.tensor_model_parallel_size=4 \
|
| 29 |
+
reward_model.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 30 |
+
reward_model.micro_batch_size_per_gpu=4 \
|
| 31 |
+
reward_model.param_offload=False \
|
| 32 |
+
algorithm.use_kl_in_reward=False \
|
| 33 |
+
trainer.critic_warmup=0 \
|
| 34 |
+
trainer.logger='["console","wandb"]' \
|
| 35 |
+
trainer.project_name='verl_megatron_full_hh_rlhf_examples' \
|
| 36 |
+
trainer.experiment_name='deepseek_llm_7b_model_rm' \
|
| 37 |
+
trainer.n_gpus_per_node=8 \
|
| 38 |
+
trainer.nnodes=1 \
|
| 39 |
+
trainer.save_freq=20 \
|
| 40 |
+
trainer.test_freq=5 \
|
| 41 |
+
trainer.total_epochs=100 $@
|
verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
# Example runnable on H20 * 8
|
| 4 |
+
|
| 5 |
+
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
|
| 6 |
+
|
| 7 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 8 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 9 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 10 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 11 |
+
|
| 12 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 13 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 14 |
+
|
| 15 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 16 |
+
algorithm.adv_estimator=gae \
|
| 17 |
+
data.train_files="$train_files" \
|
| 18 |
+
data.val_files="$test_files" \
|
| 19 |
+
data.train_batch_size=1024 \
|
| 20 |
+
data.max_prompt_length=1024 \
|
| 21 |
+
data.max_response_length=512 \
|
| 22 |
+
data.filter_overlong_prompts=True \
|
| 23 |
+
data.truncation='error' \
|
| 24 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 25 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 26 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 27 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 28 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \
|
| 29 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \
|
| 30 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 31 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 32 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 33 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 34 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 35 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \
|
| 36 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \
|
| 37 |
+
critic.optim.lr=1e-5 \
|
| 38 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 39 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 40 |
+
algorithm.use_kl_in_reward=False \
|
| 41 |
+
trainer.critic_warmup=0 \
|
| 42 |
+
trainer.logger='["console","wandb"]' \
|
| 43 |
+
trainer.project_name='verl_ppo_gsm8k_math_examples' \
|
| 44 |
+
trainer.experiment_name='deepseek_llm_7b_megatron' \
|
| 45 |
+
trainer.n_gpus_per_node=8 \
|
| 46 |
+
trainer.nnodes=1 \
|
| 47 |
+
trainer.save_freq=20 \
|
| 48 |
+
trainer.test_freq=5 \
|
| 49 |
+
trainer.total_epochs=100 $@
|
verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron_nsys.sh
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
# Example runnable on H20 * 8
|
| 4 |
+
|
| 5 |
+
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
|
| 6 |
+
|
| 7 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 8 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 9 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 10 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 11 |
+
|
| 12 |
+
train_files=${train_files:-"$gsm8k_train_path"}
|
| 13 |
+
test_files=${test_files:-"$gsm8k_test_path"}
|
| 14 |
+
|
| 15 |
+
# Nsight profiling configuration
|
| 16 |
+
PROFILE_STEPS="[1]" # or [] or null
|
| 17 |
+
PROFILE_RANKS_ALL=False # or True
|
| 18 |
+
PROFILE_RANKS=[0,4]
|
| 19 |
+
DISCRETE=True # or True
|
| 20 |
+
|
| 21 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 22 |
+
algorithm.adv_estimator=gae \
|
| 23 |
+
data.train_files="$train_files" \
|
| 24 |
+
data.val_files="$test_files" \
|
| 25 |
+
data.train_batch_size=256 \
|
| 26 |
+
data.max_prompt_length=1024 \
|
| 27 |
+
data.max_response_length=512 \
|
| 28 |
+
data.filter_overlong_prompts=True \
|
| 29 |
+
data.truncation='error' \
|
| 30 |
+
actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 31 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 32 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
|
| 33 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 34 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \
|
| 35 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \
|
| 36 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 37 |
+
actor_rollout_ref.actor.profiler.enable=True \
|
| 38 |
+
actor_rollout_ref.actor.profiler.ranks=$PROFILE_RANKS \
|
| 39 |
+
actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \
|
| 40 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 41 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 42 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 43 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \
|
| 44 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \
|
| 45 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \
|
| 46 |
+
critic.optim.lr=1e-5 \
|
| 47 |
+
critic.model.path=deepseek-ai/deepseek-llm-7b-chat \
|
| 48 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 49 |
+
critic.profiler.enable=True \
|
| 50 |
+
critic.profiler.ranks=$PROFILE_RANKS \
|
| 51 |
+
critic.profiler.all_ranks=$PROFILE_RANKS_ALL \
|
| 52 |
+
algorithm.use_kl_in_reward=False \
|
| 53 |
+
trainer.critic_warmup=0 \
|
| 54 |
+
trainer.logger='["console","wandb"]' \
|
| 55 |
+
trainer.project_name='verl_ppo_gsm8k_math_examples' \
|
| 56 |
+
trainer.experiment_name='deepseek_llm_7b_megatron' \
|
| 57 |
+
trainer.n_gpus_per_node=8 \
|
| 58 |
+
trainer.nnodes=1 \
|
| 59 |
+
trainer.save_freq=-1 \
|
| 60 |
+
trainer.test_freq=-1 \
|
| 61 |
+
trainer.total_epochs=100 \
|
| 62 |
+
trainer.total_training_steps=1 \
|
| 63 |
+
global_profiler.tool=nsys \
|
| 64 |
+
global_profiler.steps=$PROFILE_STEPS \
|
| 65 |
+
global_profiler.global_tool_config.nsys.discrete=$DISCRETE $@
|
verl/examples/ppo_trainer/run_gemma.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
python3 -m verl.trainer.main_ppo \
|
| 4 |
+
algorithm.adv_estimator=gae \
|
| 5 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 6 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 7 |
+
data.train_batch_size=512 \
|
| 8 |
+
data.max_prompt_length=1024 \
|
| 9 |
+
data.max_response_length=512 \
|
| 10 |
+
data.filter_overlong_prompts=True \
|
| 11 |
+
data.truncation='error' \
|
| 12 |
+
actor_rollout_ref.model.path=google/gemma-2-2b-it \
|
| 13 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 14 |
+
actor_rollout_ref.model.use_remove_padding=False \
|
| 15 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 16 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 17 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 18 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 19 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 20 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 21 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 22 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 23 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 24 |
+
critic.optim.lr=1e-5 \
|
| 25 |
+
critic.model.use_remove_padding=False \
|
| 26 |
+
critic.model.path=google/gemma-2-2b-it \
|
| 27 |
+
critic.model.enable_gradient_checkpointing=False \
|
| 28 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 29 |
+
critic.model.fsdp_config.param_offload=False \
|
| 30 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 31 |
+
algorithm.use_kl_in_reward=False \
|
| 32 |
+
trainer.critic_warmup=0 \
|
| 33 |
+
trainer.logger='["console","wandb"]' \
|
| 34 |
+
trainer.project_name='verl_example' \
|
| 35 |
+
trainer.experiment_name='gemma2b_function_rm' \
|
| 36 |
+
trainer.n_gpus_per_node=2 \
|
| 37 |
+
trainer.nnodes=1 \
|
| 38 |
+
trainer.save_freq=20 \
|
| 39 |
+
trainer.test_freq=10 \
|
| 40 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_moonlight16b_a3b_gsm8k_megatron.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# 0. download the model
|
| 7 |
+
huggingface-cli download moonshotai/Moonlight-16B-A3B-Instruct
|
| 8 |
+
|
| 9 |
+
# 1. convert the model to mcore format
|
| 10 |
+
# change the HF_MODEL_PATH and DIST_CKPT_PATH to your own path
|
| 11 |
+
HF_MODEL_PATH=/data/models/moonshotai/Moonlight-16B-A3B-Instruct
|
| 12 |
+
DIST_CKPT_PATH=/data/mcore_ckpt/Moonlight-16B-A3B-Instruct
|
| 13 |
+
python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# 2. run the script
|
| 17 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 18 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 19 |
+
train_files=$gsm8k_train_path
|
| 20 |
+
test_files=$gsm8k_test_path
|
| 21 |
+
|
| 22 |
+
ALL_OFFLOAD=${ALL_OFFLOAD:-False}
|
| 23 |
+
COMMON_PARAM_OFFLOAD=${COMMON_PARAM_OFFLOAD:-$ALL_OFFLOAD}
|
| 24 |
+
COMMON_GRAD_OFFLOAD=${COMMON_GRAD_OFFLOAD:-$ALL_OFFLOAD}
|
| 25 |
+
COMMON_OPTIMIZER_OFFLOAD=${COMMON_OPTIMIZER_OFFLOAD:-$ALL_OFFLOAD}
|
| 26 |
+
|
| 27 |
+
ACTOR_PARAM_OFFLOAD=${ACTOR_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD}
|
| 28 |
+
ACTOR_GRAD_OFFLOAD=${ACTOR_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD}
|
| 29 |
+
ACTOR_OPTIMIZER_OFFLOAD=${ACTOR_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD}
|
| 30 |
+
REF_PARAM_OFFLOAD=${REF_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD}
|
| 31 |
+
CRITIC_PARAM_OFFLOAD=${CRITIC_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD}
|
| 32 |
+
CRITIC_GRAD_OFFLOAD=${CRITIC_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD}
|
| 33 |
+
CRITIC_OPTIMIZER_OFFLOAD=${CRITIC_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD}
|
| 34 |
+
RM_PARAM_OFFLOAD=${RM_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
NODES=4
|
| 38 |
+
PP=2
|
| 39 |
+
TP=8
|
| 40 |
+
EP=8
|
| 41 |
+
ETP=1
|
| 42 |
+
VLLM_TP=4
|
| 43 |
+
|
| 44 |
+
# RAY_ADDRESS='auto' ray job submit --working-dir . --
|
| 45 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 46 |
+
algorithm.adv_estimator=gae \
|
| 47 |
+
data.train_files="$train_files" \
|
| 48 |
+
data.val_files="$test_files" \
|
| 49 |
+
data.train_batch_size=1024 \
|
| 50 |
+
data.max_prompt_length=1024 \
|
| 51 |
+
data.max_response_length=512 \
|
| 52 |
+
data.filter_overlong_prompts=True \
|
| 53 |
+
data.truncation='error' \
|
| 54 |
+
data.trust_remote_code=True \
|
| 55 |
+
actor_rollout_ref.model.path=$LLM \
|
| 56 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 57 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 58 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 59 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 60 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \
|
| 61 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 62 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \
|
| 63 |
+
critic.optim.lr=1e-5 \
|
| 64 |
+
critic.model.path=$LLM \
|
| 65 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 66 |
+
algorithm.use_kl_in_reward=False \
|
| 67 |
+
trainer.critic_warmup=0 \
|
| 68 |
+
trainer.logger='["console","wandb"]' \
|
| 69 |
+
trainer.project_name='verl_megatron_gsm8k_examples' \
|
| 70 |
+
trainer.experiment_name='moonlight_16b_a3b_instruct_1node' \
|
| 71 |
+
trainer.n_gpus_per_node=8 \
|
| 72 |
+
trainer.nnodes=$NODES \
|
| 73 |
+
trainer.save_freq=-1 \
|
| 74 |
+
trainer.test_freq=5 \
|
| 75 |
+
actor_rollout_ref.model.trust_remote_code=True \
|
| 76 |
+
critic.model.trust_remote_code=True \
|
| 77 |
+
+actor_rollout_ref.actor.megatron.override_transformer_config.num_layers_in_last_pipeline_stage=13 \
|
| 78 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=$VLLM_TP \
|
| 79 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP \
|
| 80 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=$PP \
|
| 81 |
+
critic.megatron.pipeline_model_parallel_size=$PP \
|
| 82 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP \
|
| 83 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=$TP \
|
| 84 |
+
critic.megatron.tensor_model_parallel_size=$TP \
|
| 85 |
+
actor_rollout_ref.actor.megatron.expert_model_parallel_size=$EP \
|
| 86 |
+
actor_rollout_ref.ref.megatron.expert_model_parallel_size=$EP \
|
| 87 |
+
critic.megatron.expert_model_parallel_size=$EP \
|
| 88 |
+
actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=$ETP \
|
| 89 |
+
actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=$ETP \
|
| 90 |
+
critic.megatron.expert_tensor_parallel_size=$ETP \
|
| 91 |
+
actor_rollout_ref.actor.megatron.param_offload=${ACTOR_PARAM_OFFLOAD} \
|
| 92 |
+
actor_rollout_ref.actor.megatron.optimizer_offload=${ACTOR_OPTIMIZER_OFFLOAD} \
|
| 93 |
+
actor_rollout_ref.actor.megatron.grad_offload=${ACTOR_GRAD_OFFLOAD} \
|
| 94 |
+
actor_rollout_ref.ref.megatron.param_offload=${REF_PARAM_OFFLOAD} \
|
| 95 |
+
critic.megatron.param_offload=${CRITIC_PARAM_OFFLOAD} \
|
| 96 |
+
critic.megatron.optimizer_offload=${CRITIC_OPTIMIZER_OFFLOAD} \
|
| 97 |
+
critic.megatron.grad_offload=${CRITIC_GRAD_OFFLOAD} \
|
| 98 |
+
actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \
|
| 99 |
+
actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \
|
| 100 |
+
critic.megatron.use_dist_checkpointing=True \
|
| 101 |
+
actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 102 |
+
actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 103 |
+
critic.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 104 |
+
trainer.val_before_train=False \
|
| 105 |
+
trainer.total_epochs=100 $@
|
| 106 |
+
|
verl/examples/ppo_trainer/run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
|
| 4 |
+
|
| 5 |
+
# 0. download the model
|
| 6 |
+
#huggingface-cli download Qwen/Qwen1.5-MoE-A2.7B-Chat
|
| 7 |
+
|
| 8 |
+
# 1. convert the model to mcore format
|
| 9 |
+
# change the HF_MODEL_PATH and DIST_CKPT_PATH to your own path
|
| 10 |
+
HF_MODEL_PATH=/data/models/Qwen/Qwen1.5-MoE-A2.7B-Chat
|
| 11 |
+
DIST_CKPT_PATH=/data/mcore_ckpt/Qwen1.5-MoE-A2.7B-Chat
|
| 12 |
+
python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH
|
| 13 |
+
|
| 14 |
+
# 2. run the script
|
| 15 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 16 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 17 |
+
train_files=$gsm8k_train_path
|
| 18 |
+
test_files=$gsm8k_test_path
|
| 19 |
+
|
| 20 |
+
NODES=4
|
| 21 |
+
PP=2
|
| 22 |
+
TP=4
|
| 23 |
+
CP=1
|
| 24 |
+
VLLM_TP=4
|
| 25 |
+
|
| 26 |
+
# RAY_ADDRESS='auto' ray job submit --working-dir . --
|
| 27 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 28 |
+
algorithm.adv_estimator=gae \
|
| 29 |
+
data.train_files="$train_files" \
|
| 30 |
+
data.val_files="$test_files" \
|
| 31 |
+
data.train_batch_size=1024 \
|
| 32 |
+
data.max_prompt_length=1024 \
|
| 33 |
+
data.max_response_length=512 \
|
| 34 |
+
data.filter_overlong_prompts=True \
|
| 35 |
+
data.truncation='error' \
|
| 36 |
+
actor_rollout_ref.model.path=$HF_MODEL_PATH \
|
| 37 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 38 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 39 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 40 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 41 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP \
|
| 42 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP \
|
| 43 |
+
actor_rollout_ref.actor.megatron.context_parallel_size=$CP \
|
| 44 |
+
actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \
|
| 45 |
+
actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 46 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=$TP \
|
| 47 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=$PP \
|
| 48 |
+
actor_rollout_ref.ref.megatron.context_parallel_size=$CP \
|
| 49 |
+
actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \
|
| 50 |
+
actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 51 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 52 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \
|
| 53 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \
|
| 54 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=$VLLM_TP \
|
| 55 |
+
critic.optim.lr=1e-5 \
|
| 56 |
+
critic.model.path=$HF_MODEL_PATH \
|
| 57 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 58 |
+
critic.megatron.tensor_model_parallel_size=$TP \
|
| 59 |
+
critic.megatron.pipeline_model_parallel_size=$PP \
|
| 60 |
+
critic.megatron.context_parallel_size=$CP \
|
| 61 |
+
critic.megatron.use_dist_checkpointing=True \
|
| 62 |
+
critic.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \
|
| 63 |
+
algorithm.use_kl_in_reward=False \
|
| 64 |
+
trainer.critic_warmup=0 \
|
| 65 |
+
trainer.logger='["console","wandb"]' \
|
| 66 |
+
trainer.project_name='verl_megatron_gsm8k_examples' \
|
| 67 |
+
trainer.experiment_name='qwen1.5_moe_nochat' \
|
| 68 |
+
trainer.n_gpus_per_node=8 \
|
| 69 |
+
trainer.nnodes=$NODES \
|
| 70 |
+
trainer.save_freq=20 \
|
| 71 |
+
trainer.test_freq=5 \
|
| 72 |
+
trainer.total_epochs=100 $@
|
| 73 |
+
|
verl/examples/ppo_trainer/run_qwen2-7b_math_gsm8k_megatron.sh
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping
|
| 4 |
+
|
| 5 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 6 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 7 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 8 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 9 |
+
|
| 10 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 11 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 12 |
+
|
| 13 |
+
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\
|
| 14 |
+
algorithm.adv_estimator=gae \
|
| 15 |
+
data.train_files="$train_files" \
|
| 16 |
+
data.val_files="$test_files" \
|
| 17 |
+
data.train_batch_size=1024 \
|
| 18 |
+
data.max_prompt_length=1024 \
|
| 19 |
+
data.max_response_length=512 \
|
| 20 |
+
data.filter_overlong_prompts=True \
|
| 21 |
+
data.truncation='error' \
|
| 22 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 23 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 25 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
|
| 26 |
+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \
|
| 27 |
+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \
|
| 28 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 29 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
|
| 30 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 31 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 32 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
|
| 33 |
+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \
|
| 34 |
+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \
|
| 35 |
+
critic.optim.lr=1e-5 \
|
| 36 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 37 |
+
critic.ppo_micro_batch_size_per_gpu=4 \
|
| 38 |
+
algorithm.use_kl_in_reward=False \
|
| 39 |
+
trainer.critic_warmup=0 \
|
| 40 |
+
trainer.logger='["console","wandb"]' \
|
| 41 |
+
trainer.project_name='verl_ppo_gsm8k_math_examples' \
|
| 42 |
+
trainer.experiment_name='qwen2_7b_megatron' \
|
| 43 |
+
trainer.n_gpus_per_node=8 \
|
| 44 |
+
trainer.nnodes=1 \
|
| 45 |
+
trainer.save_freq=20 \
|
| 46 |
+
trainer.test_freq=5 \
|
| 47 |
+
trainer.total_epochs=100 $@
|
verl/examples/ppo_trainer/run_qwen2-7b_rm.sh
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Discliamer: the model used in the script is only for academic purpose.
|
| 2 |
+
set -x
|
| 3 |
+
|
| 4 |
+
# Data preparation scripts are available in ``examples/data_preprocess``.
|
| 5 |
+
# Example usage:
|
| 6 |
+
#
|
| 7 |
+
# python3 examples/data_preprocess/math_dataset.py --local_dir ~/data/math
|
| 8 |
+
# python3 examples/data_preprocess/gsm8k.py --local_save_dir ~/data/gsm8k
|
| 9 |
+
|
| 10 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 11 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 12 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 13 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 14 |
+
|
| 15 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 16 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# prepare model ckpt
|
| 20 |
+
huggingface-cli download Qwen/Qwen2-7B-Instruct --local-dir $HOME/models/Qwen2-7B-Instruct &
|
| 21 |
+
huggingface-cli download sfairXC/FsfairX-LLaMA3-RM-v0.1 --local-dir $HOME/models/FsfairX-LLaMA3-RM-v0.1 &
|
| 22 |
+
wait
|
| 23 |
+
|
| 24 |
+
python3 -m verl.trainer.main_ppo \
|
| 25 |
+
algorithm.adv_estimator=gae \
|
| 26 |
+
data.train_files="$train_files" \
|
| 27 |
+
data.val_files="$test_files" \
|
| 28 |
+
data.train_batch_size=1024 \
|
| 29 |
+
data.max_prompt_length=1024 \
|
| 30 |
+
data.max_response_length=512 \
|
| 31 |
+
data.filter_overlong_prompts=True \
|
| 32 |
+
data.truncation='error' \
|
| 33 |
+
data.return_raw_chat=True \
|
| 34 |
+
actor_rollout_ref.model.path="$HOME/models/Qwen2-7B-Instruct" \
|
| 35 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 36 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 37 |
+
actor_rollout_ref.actor.optim.lr_warmup_steps_ratio=0.1 \
|
| 38 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 39 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 40 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 41 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 42 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 43 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 44 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \
|
| 45 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
|
| 46 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 47 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 48 |
+
critic.optim.lr=1e-5 \
|
| 49 |
+
critic.model.use_remove_padding=True \
|
| 50 |
+
critic.optim.lr_warmup_steps_ratio=0.05 \
|
| 51 |
+
critic.model.path="$HOME/models/Qwen2-7B-Instruct" \
|
| 52 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 53 |
+
critic.ppo_micro_batch_size_per_gpu=32 \
|
| 54 |
+
critic.model.fsdp_config.param_offload=False \
|
| 55 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 56 |
+
reward_model.enable=True \
|
| 57 |
+
reward_model.model.path="$HOME/models/FsfairX-LLaMA3-RM-v0.1" \
|
| 58 |
+
reward_model.model.use_remove_padding=True \
|
| 59 |
+
reward_model.model.fsdp_config.param_offload=True \
|
| 60 |
+
reward_model.micro_batch_size_per_gpu=32 \
|
| 61 |
+
algorithm.use_kl_in_reward=False \
|
| 62 |
+
trainer.critic_warmup=0 \
|
| 63 |
+
trainer.logger='["console","wandb"]' \
|
| 64 |
+
trainer.project_name='verl_example' \
|
| 65 |
+
trainer.val_before_train=False \
|
| 66 |
+
trainer.experiment_name='Qwen2-7B-Instruct_hybrid_rm' \
|
| 67 |
+
trainer.n_gpus_per_node=8 \
|
| 68 |
+
trainer.nnodes=1 \
|
| 69 |
+
trainer.save_freq=20 \
|
| 70 |
+
trainer.test_freq=5 \
|
| 71 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance.sh
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 9 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 10 |
+
|
| 11 |
+
python3 -m verl.trainer.main_ppo \
|
| 12 |
+
algorithm.adv_estimator=gae \
|
| 13 |
+
data.train_files="$train_files" \
|
| 14 |
+
data.val_files="$test_files" \
|
| 15 |
+
data.train_batch_size=4096 \
|
| 16 |
+
data.max_prompt_length=4096 \
|
| 17 |
+
data.max_response_length=4096 \
|
| 18 |
+
data.filter_overlong_prompts=True \
|
| 19 |
+
data.truncation='error' \
|
| 20 |
+
data.return_raw_chat=True \
|
| 21 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 25 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=512 \
|
| 26 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 27 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \
|
| 28 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 29 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 30 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 31 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 32 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 33 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 34 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \
|
| 35 |
+
critic.optim.lr=1e-5 \
|
| 36 |
+
critic.model.use_remove_padding=True \
|
| 37 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 38 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 39 |
+
critic.use_dynamic_bsz=True \
|
| 40 |
+
critic.ppo_max_token_len_per_gpu=98304 \
|
| 41 |
+
critic.model.fsdp_config.param_offload=False \
|
| 42 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 43 |
+
reward_model.enable=True \
|
| 44 |
+
reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\
|
| 45 |
+
reward_model.model.use_remove_padding=True \
|
| 46 |
+
reward_model.model.fsdp_config.param_offload=True \
|
| 47 |
+
reward_model.micro_batch_size_per_gpu=32 \
|
| 48 |
+
reward_model.use_dynamic_bsz=True \
|
| 49 |
+
reward_model.forward_max_token_len_per_gpu=98304 \
|
| 50 |
+
algorithm.use_kl_in_reward=False \
|
| 51 |
+
trainer.critic_warmup=0 \
|
| 52 |
+
trainer.logger='["console","wandb"]' \
|
| 53 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 54 |
+
trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing' \
|
| 55 |
+
trainer.n_gpus_per_node=8 \
|
| 56 |
+
trainer.val_before_train=False \
|
| 57 |
+
trainer.nnodes=1 \
|
| 58 |
+
trainer.save_freq=20 \
|
| 59 |
+
trainer.test_freq=5 \
|
| 60 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_fused_kernels.sh
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 9 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 10 |
+
|
| 11 |
+
FUSED_KERNEL_BACKEND=triton # or 'torch' for torch backend
|
| 12 |
+
|
| 13 |
+
python3 -m verl.trainer.main_ppo \
|
| 14 |
+
algorithm.adv_estimator=gae \
|
| 15 |
+
data.train_files="$train_files" \
|
| 16 |
+
data.val_files="$test_files" \
|
| 17 |
+
data.train_batch_size=4096 \
|
| 18 |
+
data.max_prompt_length=4096 \
|
| 19 |
+
data.max_response_length=4096 \
|
| 20 |
+
data.filter_overlong_prompts=True \
|
| 21 |
+
data.truncation='error' \
|
| 22 |
+
data.return_raw_chat=True \
|
| 23 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 24 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 25 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 26 |
+
actor_rollout_ref.model.use_fused_kernels=True \
|
| 27 |
+
actor_rollout_ref.model.fused_kernel_options.impl_backend=$FUSED_KERNEL_BACKEND \
|
| 28 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 29 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=512 \
|
| 30 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 31 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \
|
| 32 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 33 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 34 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 35 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 36 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 37 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 38 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \
|
| 39 |
+
critic.optim.lr=1e-5 \
|
| 40 |
+
critic.model.use_remove_padding=True \
|
| 41 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 42 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 43 |
+
critic.use_dynamic_bsz=True \
|
| 44 |
+
critic.ppo_max_token_len_per_gpu=98304 \
|
| 45 |
+
critic.model.fsdp_config.param_offload=False \
|
| 46 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 47 |
+
reward_model.enable=True \
|
| 48 |
+
reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\
|
| 49 |
+
reward_model.model.use_remove_padding=True \
|
| 50 |
+
reward_model.model.fsdp_config.param_offload=True \
|
| 51 |
+
reward_model.micro_batch_size_per_gpu=32 \
|
| 52 |
+
reward_model.use_dynamic_bsz=True \
|
| 53 |
+
reward_model.forward_max_token_len_per_gpu=98304 \
|
| 54 |
+
algorithm.use_kl_in_reward=False \
|
| 55 |
+
trainer.critic_warmup=0 \
|
| 56 |
+
trainer.logger='["console","wandb"]' \
|
| 57 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 58 |
+
trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing_fused_kernel' \
|
| 59 |
+
trainer.n_gpus_per_node=8 \
|
| 60 |
+
trainer.val_before_train=False \
|
| 61 |
+
trainer.nnodes=1 \
|
| 62 |
+
trainer.save_freq=20 \
|
| 63 |
+
trainer.test_freq=5 \
|
| 64 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_nsys.sh
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files=${train_files:-"$gsm8k_train_path"}
|
| 9 |
+
test_files=${test_files:-"$gsm8k_test_path"}
|
| 10 |
+
|
| 11 |
+
PROFILE_STEPS="[1,2,5]" # or [] or null
|
| 12 |
+
PROFILE_RANKS_ALL=False # or True
|
| 13 |
+
PROFILE_RANKS=[0,4]
|
| 14 |
+
DISCRETE=True # or True
|
| 15 |
+
|
| 16 |
+
python3 -m verl.trainer.main_ppo \
|
| 17 |
+
algorithm.adv_estimator=gae \
|
| 18 |
+
data.train_files="$train_files" \
|
| 19 |
+
data.val_files="$test_files" \
|
| 20 |
+
data.train_batch_size=4096 \
|
| 21 |
+
data.max_prompt_length=4096 \
|
| 22 |
+
data.max_response_length=4096 \
|
| 23 |
+
data.filter_overlong_prompts=True \
|
| 24 |
+
data.truncation='error' \
|
| 25 |
+
data.return_raw_chat=True \
|
| 26 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 27 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 28 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 29 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 30 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=512 \
|
| 31 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \
|
| 32 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 33 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=12000 \
|
| 34 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 35 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 36 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 37 |
+
actor_rollout_ref.actor.profiler.enable=True \
|
| 38 |
+
actor_rollout_ref.actor.profiler.ranks=$PROFILE_RANKS \
|
| 39 |
+
actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \
|
| 40 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 41 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 42 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 43 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \
|
| 44 |
+
critic.optim.lr=1e-5 \
|
| 45 |
+
critic.model.use_remove_padding=True \
|
| 46 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 47 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 48 |
+
critic.ppo_micro_batch_size_per_gpu=2 \
|
| 49 |
+
critic.use_dynamic_bsz=True \
|
| 50 |
+
critic.ppo_max_token_len_per_gpu=98304 \
|
| 51 |
+
critic.model.fsdp_config.param_offload=False \
|
| 52 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 53 |
+
critic.profiler.enable=True \
|
| 54 |
+
critic.profiler.ranks=$PROFILE_RANKS \
|
| 55 |
+
critic.profiler.all_ranks=$PROFILE_RANKS_ALL \
|
| 56 |
+
reward_model.enable=True \
|
| 57 |
+
reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\
|
| 58 |
+
reward_model.model.use_remove_padding=True \
|
| 59 |
+
reward_model.model.fsdp_config.param_offload=True \
|
| 60 |
+
reward_model.micro_batch_size_per_gpu=32 \
|
| 61 |
+
reward_model.use_dynamic_bsz=True \
|
| 62 |
+
reward_model.forward_max_token_len_per_gpu=98304 \
|
| 63 |
+
reward_model.profiler.enable=True \
|
| 64 |
+
reward_model.profiler.ranks=$PROFILE_RANKS \
|
| 65 |
+
reward_model.profiler.all_ranks=$PROFILE_RANKS_ALL \
|
| 66 |
+
algorithm.use_kl_in_reward=False \
|
| 67 |
+
trainer.critic_warmup=0 \
|
| 68 |
+
trainer.logger='["console","wandb"]' \
|
| 69 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 70 |
+
trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing' \
|
| 71 |
+
trainer.n_gpus_per_node=8 \
|
| 72 |
+
trainer.val_before_train=False \
|
| 73 |
+
trainer.nnodes=1 \
|
| 74 |
+
trainer.save_freq=-1 \
|
| 75 |
+
trainer.test_freq=-1 \
|
| 76 |
+
trainer.total_epochs=15 \
|
| 77 |
+
trainer.total_training_steps=6 \
|
| 78 |
+
global_profiler.profile_continuous_steps=True \
|
| 79 |
+
global_profiler.tool=nsys \
|
| 80 |
+
global_profiler.steps=$PROFILE_STEPS \
|
| 81 |
+
global_profiler.global_tool_config.nsys.discrete=$DISCRETE $@
|
verl/examples/ppo_trainer/run_qwen2-7b_seq_balance.sh
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 9 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 10 |
+
|
| 11 |
+
# For async rollout mode, dataset should return raw chat.
|
| 12 |
+
rollout_mode="sync"
|
| 13 |
+
if [ "$rollout_mode" = "async" ]; then
|
| 14 |
+
return_raw_chat="True"
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
python3 -m verl.trainer.main_ppo \
|
| 18 |
+
algorithm.adv_estimator=gae \
|
| 19 |
+
data.train_files="$train_files" \
|
| 20 |
+
data.val_files="$test_files" \
|
| 21 |
+
data.return_raw_chat=$return_raw_chat \
|
| 22 |
+
data.train_batch_size=4096 \
|
| 23 |
+
data.max_prompt_length=4096 \
|
| 24 |
+
data.max_response_length=4096 \
|
| 25 |
+
data.filter_overlong_prompts=True \
|
| 26 |
+
data.truncation='error' \
|
| 27 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 28 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 29 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 30 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 31 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=512 \
|
| 32 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 33 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \
|
| 34 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 35 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 36 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 37 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 38 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 39 |
+
actor_rollout_ref.rollout.mode=$rollout_mode \
|
| 40 |
+
actor_rollout_ref.rollout.multi_turn.format=hermes \
|
| 41 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 42 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \
|
| 43 |
+
critic.optim.lr=1e-5 \
|
| 44 |
+
critic.model.use_remove_padding=True \
|
| 45 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 46 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 47 |
+
critic.ppo_max_token_len_per_gpu=98304 \
|
| 48 |
+
critic.model.fsdp_config.param_offload=False \
|
| 49 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 50 |
+
algorithm.use_kl_in_reward=False \
|
| 51 |
+
trainer.critic_warmup=0 \
|
| 52 |
+
trainer.logger='["console","wandb"]' \
|
| 53 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 54 |
+
trainer.experiment_name='qwen2-7b_function_rm_bsz8k_p4k_r4k_seq_packing' \
|
| 55 |
+
trainer.n_gpus_per_node=8 \
|
| 56 |
+
trainer.val_before_train=False \
|
| 57 |
+
trainer.nnodes=1 \
|
| 58 |
+
trainer.save_freq=20 \
|
| 59 |
+
trainer.test_freq=5 \
|
| 60 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen2-7b_sglang_seq_balance.sh
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 9 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 10 |
+
|
| 11 |
+
python3 -m verl.trainer.main_ppo \
|
| 12 |
+
algorithm.adv_estimator=gae \
|
| 13 |
+
data.train_files="$train_files" \
|
| 14 |
+
data.val_files="$test_files" \
|
| 15 |
+
data.train_batch_size=4096 \
|
| 16 |
+
data.max_prompt_length=4096 \
|
| 17 |
+
data.max_response_length=4096 \
|
| 18 |
+
data.filter_overlong_prompts=True \
|
| 19 |
+
data.truncation='error' \
|
| 20 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 21 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 22 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 23 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=512 \
|
| 25 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 26 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \
|
| 27 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 28 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 29 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 30 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 31 |
+
actor_rollout_ref.rollout.name=sglang \
|
| 32 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 33 |
+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \
|
| 34 |
+
critic.optim.lr=1e-5 \
|
| 35 |
+
critic.model.use_remove_padding=True \
|
| 36 |
+
critic.model.path=Qwen/Qwen2-7B-Instruct \
|
| 37 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 38 |
+
critic.ppo_max_token_len_per_gpu=98304 \
|
| 39 |
+
critic.model.fsdp_config.param_offload=False \
|
| 40 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 41 |
+
algorithm.use_kl_in_reward=False \
|
| 42 |
+
trainer.critic_warmup=0 \
|
| 43 |
+
trainer.logger='["console","wandb"]' \
|
| 44 |
+
trainer.project_name='verl_example_gsm8k' \
|
| 45 |
+
trainer.experiment_name='qwen2-7b_function_rm_bsz8k_p4k_r4k_seq_packing' \
|
| 46 |
+
trainer.n_gpus_per_node=8 \
|
| 47 |
+
trainer.val_before_train=False \
|
| 48 |
+
trainer.nnodes=1 \
|
| 49 |
+
trainer.save_freq=20 \
|
| 50 |
+
trainer.test_freq=5 \
|
| 51 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen2.5-32b.sh
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 4 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 5 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 6 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 7 |
+
|
| 8 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 9 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 10 |
+
|
| 11 |
+
python3 -m verl.trainer.main_ppo \
|
| 12 |
+
algorithm.adv_estimator=gae \
|
| 13 |
+
data.train_files="$train_files" \
|
| 14 |
+
data.val_files="$test_files" \
|
| 15 |
+
data.train_batch_size=1024 \
|
| 16 |
+
data.max_prompt_length=1024 \
|
| 17 |
+
data.max_response_length=1024 \
|
| 18 |
+
data.filter_overlong_prompts=True \
|
| 19 |
+
data.truncation='error' \
|
| 20 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-32B-Instruct \
|
| 21 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=False \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 25 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=8 \
|
| 26 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 27 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 28 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 29 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 30 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \
|
| 31 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=4 \
|
| 32 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 33 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \
|
| 34 |
+
critic.optim.lr=1e-5 \
|
| 35 |
+
critic.model.use_remove_padding=True \
|
| 36 |
+
critic.model.path=Qwen/Qwen2.5-32B-Instruct \
|
| 37 |
+
critic.model.enable_gradient_checkpointing=False \
|
| 38 |
+
critic.ppo_micro_batch_size_per_gpu=8 \
|
| 39 |
+
critic.model.fsdp_config.param_offload=False \
|
| 40 |
+
critic.model.fsdp_config.optimizer_offload=False \
|
| 41 |
+
algorithm.use_kl_in_reward=False \
|
| 42 |
+
trainer.critic_warmup=0 \
|
| 43 |
+
trainer.logger='["console","wandb"]' \
|
| 44 |
+
trainer.project_name='verl_example' \
|
| 45 |
+
trainer.experiment_name='Qwen2.5-32B-Instruct_function_rm' \
|
| 46 |
+
trainer.n_gpus_per_node=8 \
|
| 47 |
+
trainer.nnodes=4 \
|
| 48 |
+
trainer.save_freq=20 \
|
| 49 |
+
trainer.test_freq=10 \
|
| 50 |
+
trainer.total_epochs=15 $@
|
verl/examples/ppo_trainer/run_qwen3-8b_npu.sh
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export VLLM_USE_V1=1
|
| 4 |
+
|
| 5 |
+
python3 -m verl.trainer.main_ppo \
|
| 6 |
+
algorithm.adv_estimator=gae \
|
| 7 |
+
data.train_files=$HOME/data/dapo-math-17k.parquet \
|
| 8 |
+
data.val_files=$HOME/data/dapo-math-17k.parquet \
|
| 9 |
+
data.train_batch_size=256 \
|
| 10 |
+
data.max_prompt_length=2000 \
|
| 11 |
+
data.max_response_length=12000 \
|
| 12 |
+
data.shuffle=False \
|
| 13 |
+
actor_rollout_ref.model.path=Qwen/Qwen3-8B \
|
| 14 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 15 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 16 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 17 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
|
| 18 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
|
| 19 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=True \
|
| 20 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=True \
|
| 21 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 22 |
+
actor_rollout_ref.actor.ulysses_sequence_parallel_size=2 \
|
| 23 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 24 |
+
actor_rollout_ref.actor.use_torch_compile=False \
|
| 25 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
|
| 26 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
|
| 27 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 28 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.9 \
|
| 29 |
+
actor_rollout_ref.rollout.max_num_batched_tokens=14000 \
|
| 30 |
+
actor_rollout_ref.rollout.max_num_seqs=64 \
|
| 31 |
+
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True \
|
| 32 |
+
actor_rollout_ref.rollout.enable_chunked_prefill=True \
|
| 33 |
+
actor_rollout_ref.rollout.enforce_eager=False \
|
| 34 |
+
critic.optim.lr=1e-5 \
|
| 35 |
+
critic.model.use_remove_padding=True \
|
| 36 |
+
critic.model.path=Qwen/Qwen3-8B \
|
| 37 |
+
critic.model.enable_gradient_checkpointing=True \
|
| 38 |
+
critic.ppo_micro_batch_size_per_gpu=1 \
|
| 39 |
+
critic.ulysses_sequence_parallel_size=2 \
|
| 40 |
+
critic.model.fsdp_config.param_offload=True \
|
| 41 |
+
critic.model.fsdp_config.optimizer_offload=True \
|
| 42 |
+
critic.use_dynamic_bsz=True \
|
| 43 |
+
trainer.critic_warmup=0 \
|
| 44 |
+
trainer.logger=console \
|
| 45 |
+
trainer.project_name='verl_example_dapo_math_17k' \
|
| 46 |
+
trainer.experiment_name='qwen3_8b_fsdp' \
|
| 47 |
+
trainer.n_gpus_per_node=8 \
|
| 48 |
+
trainer.nnodes=1 \
|
| 49 |
+
trainer.save_freq=20 \
|
| 50 |
+
trainer.test_freq=-1 \
|
| 51 |
+
trainer.val_before_train=False \
|
| 52 |
+
trainer.device=npu \
|
| 53 |
+
trainer.max_actor_ckpt_to_keep=1 \
|
| 54 |
+
trainer.max_critic_ckpt_to_keep=1 \
|
| 55 |
+
trainer.total_training_steps=100 $@
|
verl/examples/ray/tutorial.ipynb
ADDED
|
@@ -0,0 +1,963 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "0ddc582b",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# VeRL Ray API Tutorial"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"cell_type": "markdown",
|
| 13 |
+
"id": "71fe3b94",
|
| 14 |
+
"metadata": {},
|
| 15 |
+
"source": [
|
| 16 |
+
"## Chapter 1: Ray Basics"
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"cell_type": "code",
|
| 21 |
+
"execution_count": 144,
|
| 22 |
+
"id": "1347d381",
|
| 23 |
+
"metadata": {
|
| 24 |
+
"tags": []
|
| 25 |
+
},
|
| 26 |
+
"outputs": [],
|
| 27 |
+
"source": [
|
| 28 |
+
"import os"
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"cell_type": "code",
|
| 33 |
+
"execution_count": 145,
|
| 34 |
+
"id": "e75b9d44",
|
| 35 |
+
"metadata": {
|
| 36 |
+
"tags": []
|
| 37 |
+
},
|
| 38 |
+
"outputs": [],
|
| 39 |
+
"source": [
|
| 40 |
+
"import warnings\n",
|
| 41 |
+
"\n",
|
| 42 |
+
"import ray\n",
|
| 43 |
+
"import torch\n",
|
| 44 |
+
"\n",
|
| 45 |
+
"warnings.filterwarnings(\"ignore\")"
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"cell_type": "code",
|
| 50 |
+
"execution_count": 146,
|
| 51 |
+
"id": "2e90ae00",
|
| 52 |
+
"metadata": {
|
| 53 |
+
"tags": []
|
| 54 |
+
},
|
| 55 |
+
"outputs": [
|
| 56 |
+
{
|
| 57 |
+
"name": "stderr",
|
| 58 |
+
"output_type": "stream",
|
| 59 |
+
"text": [
|
| 60 |
+
"2024-11-01 17:27:19,132\tINFO worker.py:1752 -- Started a local Ray instance.\n"
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"data": {
|
| 65 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 66 |
+
"model_id": "9cc9d2ccbdfb48918c8fd6cd13a0807a",
|
| 67 |
+
"version_major": 2,
|
| 68 |
+
"version_minor": 0
|
| 69 |
+
},
|
| 70 |
+
"text/html": [
|
| 71 |
+
"<div class=\"lm-Widget p-Widget lm-Panel p-Panel jp-Cell-outputWrapper\">\n",
|
| 72 |
+
" <div style=\"margin-left: 50px;display: flex;flex-direction: row;align-items: center\">\n",
|
| 73 |
+
" <div class=\"jp-RenderedHTMLCommon\" style=\"display: flex; flex-direction: row;\">\n",
|
| 74 |
+
" <svg viewBox=\"0 0 567 224\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" style=\"height: 3em;\">\n",
|
| 75 |
+
" <g clip-path=\"url(#clip0_4338_178347)\">\n",
|
| 76 |
+
" <path d=\"M341.29 165.561H355.29L330.13 129.051C345.63 123.991 354.21 112.051 354.21 94.2307C354.21 71.3707 338.72 58.1807 311.88 58.1807H271V165.561H283.27V131.661H311.8C314.25 131.661 316.71 131.501 319.01 131.351L341.25 165.561H341.29ZM283.29 119.851V70.0007H311.82C331.3 70.0007 342.34 78.2907 342.34 94.5507C342.34 111.271 331.34 119.861 311.82 119.861L283.29 119.851ZM451.4 138.411L463.4 165.561H476.74L428.74 58.1807H416L367.83 165.561H380.83L392.83 138.411H451.4ZM446.19 126.601H398L422 72.1407L446.24 126.601H446.19ZM526.11 128.741L566.91 58.1807H554.35L519.99 114.181L485.17 58.1807H472.44L514.01 129.181V165.541H526.13V128.741H526.11Z\" fill=\"var(--jp-ui-font-color0)\"/>\n",
|
| 77 |
+
" <path d=\"M82.35 104.44C84.0187 97.8827 87.8248 92.0678 93.1671 87.9146C98.5094 83.7614 105.083 81.5067 111.85 81.5067C118.617 81.5067 125.191 83.7614 130.533 87.9146C135.875 92.0678 139.681 97.8827 141.35 104.44H163.75C164.476 101.562 165.622 98.8057 167.15 96.2605L127.45 56.5605C121.071 60.3522 113.526 61.6823 106.235 60.3005C98.9443 58.9187 92.4094 54.9203 87.8602 49.0574C83.3109 43.1946 81.0609 35.8714 81.5332 28.4656C82.0056 21.0599 85.1679 14.0819 90.4252 8.8446C95.6824 3.60726 102.672 0.471508 110.08 0.0272655C117.487 -0.416977 124.802 1.86091 130.647 6.4324C136.493 11.0039 140.467 17.5539 141.821 24.8501C143.175 32.1463 141.816 39.6859 138 46.0505L177.69 85.7505C182.31 82.9877 187.58 81.4995 192.962 81.4375C198.345 81.3755 203.648 82.742 208.33 85.3976C213.012 88.0532 216.907 91.9029 219.616 96.5544C222.326 101.206 223.753 106.492 223.753 111.875C223.753 117.258 222.326 122.545 219.616 127.197C216.907 131.848 213.012 135.698 208.33 138.353C203.648 141.009 198.345 142.375 192.962 142.313C187.58 142.251 182.31 140.763 177.69 138L138 177.7C141.808 184.071 143.155 191.614 141.79 198.91C140.424 206.205 136.44 212.75 130.585 217.313C124.731 221.875 117.412 224.141 110.004 223.683C102.596 223.226 95.6103 220.077 90.3621 214.828C85.1139 209.58 81.9647 202.595 81.5072 195.187C81.0497 187.779 83.3154 180.459 87.878 174.605C92.4405 168.751 98.9853 164.766 106.281 163.401C113.576 162.035 121.119 163.383 127.49 167.19L167.19 127.49C165.664 124.941 164.518 122.182 163.79 119.3H141.39C139.721 125.858 135.915 131.673 130.573 135.826C125.231 139.98 118.657 142.234 111.89 142.234C105.123 142.234 98.5494 139.98 93.2071 135.826C87.8648 131.673 84.0587 125.858 82.39 119.3H60C58.1878 126.495 53.8086 132.78 47.6863 136.971C41.5641 141.163 34.1211 142.972 26.7579 142.059C19.3947 141.146 12.6191 137.574 7.70605 132.014C2.79302 126.454 0.0813599 119.29 0.0813599 111.87C0.0813599 104.451 2.79302 97.2871 7.70605 91.7272C12.6191 86.1673 19.3947 82.5947 26.7579 81.6817C34.1211 80.7686 41.5641 82.5781 47.6863 86.7696C53.8086 90.9611 58.1878 97.2456 60 104.44H82.35ZM100.86 204.32C103.407 206.868 106.759 208.453 110.345 208.806C113.93 209.159 117.527 208.258 120.522 206.256C123.517 204.254 125.725 201.276 126.771 197.828C127.816 194.38 127.633 190.677 126.253 187.349C124.874 184.021 122.383 181.274 119.205 179.577C116.027 177.88 112.359 177.337 108.826 178.042C105.293 178.746 102.113 180.654 99.8291 183.44C97.5451 186.226 96.2979 189.718 96.3 193.32C96.2985 195.364 96.7006 197.388 97.4831 199.275C98.2656 201.163 99.4132 202.877 100.86 204.32ZM204.32 122.88C206.868 120.333 208.453 116.981 208.806 113.396C209.159 109.811 208.258 106.214 206.256 103.219C204.254 100.223 201.275 98.0151 197.827 96.97C194.38 95.9249 190.676 96.1077 187.348 97.4873C184.02 98.8669 181.274 101.358 179.577 104.536C177.879 107.714 177.337 111.382 178.041 114.915C178.746 118.448 180.653 121.627 183.439 123.911C186.226 126.195 189.717 127.443 193.32 127.44C195.364 127.443 197.388 127.042 199.275 126.259C201.163 125.476 202.878 124.328 204.32 122.88ZM122.88 19.4205C120.333 16.8729 116.981 15.2876 113.395 14.9347C109.81 14.5817 106.213 15.483 103.218 17.4849C100.223 19.4868 98.0146 22.4654 96.9696 25.9131C95.9245 29.3608 96.1073 33.0642 97.4869 36.3922C98.8665 39.7202 101.358 42.4668 104.535 44.1639C107.713 45.861 111.381 46.4036 114.914 45.6992C118.447 44.9949 121.627 43.0871 123.911 40.301C126.195 37.515 127.442 34.0231 127.44 30.4205C127.44 28.3772 127.038 26.3539 126.255 24.4664C125.473 22.5788 124.326 20.8642 122.88 19.4205ZM19.42 100.86C16.8725 103.408 15.2872 106.76 14.9342 110.345C14.5813 113.93 15.4826 117.527 17.4844 120.522C19.4863 123.518 22.4649 125.726 25.9127 126.771C29.3604 127.816 33.0638 127.633 36.3918 126.254C39.7198 124.874 42.4664 122.383 44.1635 119.205C45.8606 116.027 46.4032 112.359 45.6988 108.826C44.9944 105.293 43.0866 102.114 40.3006 99.8296C37.5145 97.5455 34.0227 96.2983 30.42 96.3005C26.2938 96.3018 22.337 97.9421 19.42 100.86ZM100.86 100.86C98.3125 103.408 96.7272 106.76 96.3742 110.345C96.0213 113.93 96.9226 117.527 98.9244 120.522C100.926 123.518 103.905 125.726 107.353 126.771C110.8 127.816 114.504 127.633 117.832 126.254C121.16 124.874 123.906 122.383 125.604 119.205C127.301 116.027 127.843 112.359 127.139 108.826C126.434 105.293 124.527 102.114 121.741 99.8296C118.955 97.5455 115.463 96.2983 111.86 96.3005C109.817 96.299 107.793 96.701 105.905 97.4835C104.018 98.2661 102.303 99.4136 100.86 100.86Z\" fill=\"#00AEEF\"/>\n",
|
| 78 |
+
" </g>\n",
|
| 79 |
+
" <defs>\n",
|
| 80 |
+
" <clipPath id=\"clip0_4338_178347\">\n",
|
| 81 |
+
" <rect width=\"566.93\" height=\"223.75\" fill=\"white\"/>\n",
|
| 82 |
+
" </clipPath>\n",
|
| 83 |
+
" </defs>\n",
|
| 84 |
+
" </svg>\n",
|
| 85 |
+
"</div>\n",
|
| 86 |
+
"\n",
|
| 87 |
+
" <table class=\"jp-RenderedHTMLCommon\" style=\"border-collapse: collapse;color: var(--jp-ui-font-color1);font-size: var(--jp-ui-font-size1);\">\n",
|
| 88 |
+
" <tr>\n",
|
| 89 |
+
" <td style=\"text-align: left\"><b>Python version:</b></td>\n",
|
| 90 |
+
" <td style=\"text-align: left\"><b>3.9.2</b></td>\n",
|
| 91 |
+
" </tr>\n",
|
| 92 |
+
" <tr>\n",
|
| 93 |
+
" <td style=\"text-align: left\"><b>Ray version:</b></td>\n",
|
| 94 |
+
" <td style=\"text-align: left\"><b>2.10.0</b></td>\n",
|
| 95 |
+
" </tr>\n",
|
| 96 |
+
" \n",
|
| 97 |
+
"</table>\n",
|
| 98 |
+
"\n",
|
| 99 |
+
" </div>\n",
|
| 100 |
+
"</div>\n"
|
| 101 |
+
],
|
| 102 |
+
"text/plain": [
|
| 103 |
+
"RayContext(dashboard_url='', python_version='3.9.2', ray_version='2.10.0', ray_commit='09abba26b5bf2707639bb637c208d062a47b46f6')"
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
"execution_count": 146,
|
| 107 |
+
"metadata": {},
|
| 108 |
+
"output_type": "execute_result"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"name": "stdout",
|
| 112 |
+
"output_type": "stream",
|
| 113 |
+
"text": [
|
| 114 |
+
"\u001b[36m(GPUAccumulator pid=224400)\u001b[0m rank 0, value: tensor([1.], device='cuda:0')\n",
|
| 115 |
+
"\u001b[36m(GPUAccumulator pid=225234)\u001b[0m rank 2, value: tensor([3.], device='cuda:0')\n",
|
| 116 |
+
"\u001b[36m(GPUAccumulator pid=225607)\u001b[0m rank 0, value: tensor([2.], device='cuda:0')\n",
|
| 117 |
+
"\u001b[36m(GPUAccumulator pid=226423)\u001b[0m rank 1, value: tensor([3.], device='cuda:0')\n",
|
| 118 |
+
"\u001b[36m(GPUAccumulator pid=226857)\u001b[0m rank 3, value: tensor([6.], device='cuda:0')\n",
|
| 119 |
+
"\u001b[36m(GPUAccumulatorDecorator pid=227475)\u001b[0m 10\n",
|
| 120 |
+
"\u001b[36m(GPUAccumulatorDecorator pid=227475)\u001b[0m rank 0, value: tensor([10.], device='cuda:0')\n",
|
| 121 |
+
"\u001b[36m(GPUAccumulatorDecorator pid=227655)\u001b[0m rank 1, value: tensor([11.], device='cuda:0')\n"
|
| 122 |
+
]
|
| 123 |
+
}
|
| 124 |
+
],
|
| 125 |
+
"source": [
|
| 126 |
+
"# Build a local ray cluster. The head node and worker node are on this machine\n",
|
| 127 |
+
"ray.init()"
|
| 128 |
+
]
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"cell_type": "markdown",
|
| 132 |
+
"id": "a127e4e4",
|
| 133 |
+
"metadata": {},
|
| 134 |
+
"source": [
|
| 135 |
+
"Implement an Accumulator class."
|
| 136 |
+
]
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"cell_type": "code",
|
| 140 |
+
"execution_count": 147,
|
| 141 |
+
"id": "20e7b9a3",
|
| 142 |
+
"metadata": {
|
| 143 |
+
"tags": []
|
| 144 |
+
},
|
| 145 |
+
"outputs": [],
|
| 146 |
+
"source": [
|
| 147 |
+
"@ray.remote\n",
|
| 148 |
+
"class Accumulator:\n",
|
| 149 |
+
" def __init__(self):\n",
|
| 150 |
+
" self.value = 0\n",
|
| 151 |
+
"\n",
|
| 152 |
+
" def add(self, x):\n",
|
| 153 |
+
" self.value += x\n",
|
| 154 |
+
"\n",
|
| 155 |
+
" def get_value(self):\n",
|
| 156 |
+
" return self.value"
|
| 157 |
+
]
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"cell_type": "code",
|
| 161 |
+
"execution_count": 148,
|
| 162 |
+
"id": "3b80098c",
|
| 163 |
+
"metadata": {
|
| 164 |
+
"tags": []
|
| 165 |
+
},
|
| 166 |
+
"outputs": [],
|
| 167 |
+
"source": [
|
| 168 |
+
"# Instantiate an accumulator. Accumulator can be viewed as a process, acting as an RPC service.\n",
|
| 169 |
+
"accumulator = Accumulator.remote()"
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"cell_type": "code",
|
| 174 |
+
"execution_count": 149,
|
| 175 |
+
"id": "b14b1009",
|
| 176 |
+
"metadata": {
|
| 177 |
+
"tags": []
|
| 178 |
+
},
|
| 179 |
+
"outputs": [
|
| 180 |
+
{
|
| 181 |
+
"name": "stdout",
|
| 182 |
+
"output_type": "stream",
|
| 183 |
+
"text": [
|
| 184 |
+
"0\n"
|
| 185 |
+
]
|
| 186 |
+
}
|
| 187 |
+
],
|
| 188 |
+
"source": [
|
| 189 |
+
"value_ref = accumulator.get_value.remote() # Check the current value. Note that this function returns immediately and does not actually wait for the remote execution to complete.\n",
|
| 190 |
+
"# Get the value\n",
|
| 191 |
+
"value = ray.get(value_ref)\n",
|
| 192 |
+
"print(value)"
|
| 193 |
+
]
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"cell_type": "code",
|
| 197 |
+
"execution_count": 150,
|
| 198 |
+
"id": "513a84b3",
|
| 199 |
+
"metadata": {
|
| 200 |
+
"tags": []
|
| 201 |
+
},
|
| 202 |
+
"outputs": [
|
| 203 |
+
{
|
| 204 |
+
"name": "stdout",
|
| 205 |
+
"output_type": "stream",
|
| 206 |
+
"text": [
|
| 207 |
+
"10\n"
|
| 208 |
+
]
|
| 209 |
+
}
|
| 210 |
+
],
|
| 211 |
+
"source": [
|
| 212 |
+
"# Accumulate, then check the result.\n",
|
| 213 |
+
"accumulator.add.remote(10) # Similarly, the 'add' here will return immediately.\n",
|
| 214 |
+
"new_value = ray.get(accumulator.get_value.remote())\n",
|
| 215 |
+
"print(new_value)"
|
| 216 |
+
]
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"cell_type": "markdown",
|
| 220 |
+
"id": "3c332fe0",
|
| 221 |
+
"metadata": {},
|
| 222 |
+
"source": [
|
| 223 |
+
"## Chapter 2: Resource Pool and RayWorkerGroup\n",
|
| 224 |
+
"In the previous example, it was a simple single-process worker. \n",
|
| 225 |
+
"In this example, we implement a worker with a GPU and form a RayWorkerGroup. Within this RayWorkerGroup, we implement a simple operation of an accumulator."
|
| 226 |
+
]
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"cell_type": "code",
|
| 230 |
+
"execution_count": 151,
|
| 231 |
+
"id": "04229afb",
|
| 232 |
+
"metadata": {
|
| 233 |
+
"tags": []
|
| 234 |
+
},
|
| 235 |
+
"outputs": [],
|
| 236 |
+
"source": [
|
| 237 |
+
"from verl.single_controller.base import Worker\n",
|
| 238 |
+
"from verl.single_controller.ray.base import RayClassWithInitArgs, RayResourcePool, RayWorkerGroup, merge_resource_pool"
|
| 239 |
+
]
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"cell_type": "code",
|
| 243 |
+
"execution_count": 152,
|
| 244 |
+
"id": "0d0dbd58",
|
| 245 |
+
"metadata": {
|
| 246 |
+
"tags": []
|
| 247 |
+
},
|
| 248 |
+
"outputs": [],
|
| 249 |
+
"source": [
|
| 250 |
+
"resource_pool = RayResourcePool([4], use_gpu=True)"
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"cell_type": "code",
|
| 255 |
+
"execution_count": 153,
|
| 256 |
+
"id": "68f6838a",
|
| 257 |
+
"metadata": {
|
| 258 |
+
"tags": []
|
| 259 |
+
},
|
| 260 |
+
"outputs": [],
|
| 261 |
+
"source": [
|
| 262 |
+
"@ray.remote\n",
|
| 263 |
+
"class GPUAccumulator(Worker):\n",
|
| 264 |
+
" def __init__(self) -> None:\n",
|
| 265 |
+
" super().__init__()\n",
|
| 266 |
+
" # The initial value of each rank is the same as the rank\n",
|
| 267 |
+
" self.value = torch.zeros(size=(1,), device=\"cuda\") + self.rank\n",
|
| 268 |
+
"\n",
|
| 269 |
+
" def add(self, x):\n",
|
| 270 |
+
" self.value += x\n",
|
| 271 |
+
" print(f\"rank {self.rank}, value: {self.value}\")\n",
|
| 272 |
+
" return self.value.cpu()"
|
| 273 |
+
]
|
| 274 |
+
},
|
| 275 |
+
{
|
| 276 |
+
"cell_type": "code",
|
| 277 |
+
"execution_count": 154,
|
| 278 |
+
"id": "23aad8fe",
|
| 279 |
+
"metadata": {
|
| 280 |
+
"tags": []
|
| 281 |
+
},
|
| 282 |
+
"outputs": [
|
| 283 |
+
{
|
| 284 |
+
"name": "stdout",
|
| 285 |
+
"output_type": "stream",
|
| 286 |
+
"text": [
|
| 287 |
+
"[tensor([1.]), tensor([2.]), tensor([3.]), tensor([4.])]\n"
|
| 288 |
+
]
|
| 289 |
+
}
|
| 290 |
+
],
|
| 291 |
+
"source": [
|
| 292 |
+
"# Each worker's initial value is its rank, and then each rank's value is incremented by 1, so the values obtained on each rank are [1, 2, 3, 4]\n",
|
| 293 |
+
"class_with_args = RayClassWithInitArgs(cls=GPUAccumulator)\n",
|
| 294 |
+
"worker_group = RayWorkerGroup(resource_pool, class_with_args)\n",
|
| 295 |
+
"print(worker_group.execute_all_sync(\"add\", x=[1, 1, 1, 1]))"
|
| 296 |
+
]
|
| 297 |
+
},
|
| 298 |
+
{
|
| 299 |
+
"cell_type": "markdown",
|
| 300 |
+
"id": "e6705284",
|
| 301 |
+
"metadata": {},
|
| 302 |
+
"source": [
|
| 303 |
+
"The principle of parameter passing: The input parameter is a list of length world_size, where each element in the list is dispatched respectively to each worker in the RayWorkerGroup. \n",
|
| 304 |
+
"The return parameter is also a list, corresponding to the return value of each worker."
|
| 305 |
+
]
|
| 306 |
+
},
|
| 307 |
+
{
|
| 308 |
+
"cell_type": "markdown",
|
| 309 |
+
"id": "d25c2412",
|
| 310 |
+
"metadata": {},
|
| 311 |
+
"source": [
|
| 312 |
+
"### GPU Resource Sharing"
|
| 313 |
+
]
|
| 314 |
+
},
|
| 315 |
+
{
|
| 316 |
+
"cell_type": "markdown",
|
| 317 |
+
"id": "f74f6d24",
|
| 318 |
+
"metadata": {},
|
| 319 |
+
"source": [
|
| 320 |
+
"RayWorkerGroups mapped to the same resource pool share the GPU. In this example, we implement three resource pools: the first occupies 4 GPUs, the second also occupies 4 GPUs, and the last occupies all 8 GPUs. Among them, the first resource pool reuses the resource pool mentioned above."
|
| 321 |
+
]
|
| 322 |
+
},
|
| 323 |
+
{
|
| 324 |
+
"cell_type": "code",
|
| 325 |
+
"execution_count": 155,
|
| 326 |
+
"id": "49f9c06f",
|
| 327 |
+
"metadata": {
|
| 328 |
+
"tags": []
|
| 329 |
+
},
|
| 330 |
+
"outputs": [],
|
| 331 |
+
"source": [
|
| 332 |
+
"# Create a new resource pool and then merge the newly created resource pool with the previous one.\n",
|
| 333 |
+
"resource_pool_1 = RayResourcePool([4], use_gpu=True, name_prefix=\"a\")\n",
|
| 334 |
+
"resource_pool_merge = merge_resource_pool(resource_pool, resource_pool_1)"
|
| 335 |
+
]
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
"cell_type": "code",
|
| 339 |
+
"execution_count": 156,
|
| 340 |
+
"id": "05c2e305",
|
| 341 |
+
"metadata": {
|
| 342 |
+
"tags": []
|
| 343 |
+
},
|
| 344 |
+
"outputs": [],
|
| 345 |
+
"source": [
|
| 346 |
+
"# Establish a RayWorkerGroup on the newly created resource pool.\n",
|
| 347 |
+
"worker_group_1 = RayWorkerGroup(resource_pool_1, class_with_args)\n",
|
| 348 |
+
"worker_group_merge = RayWorkerGroup(resource_pool_merge, class_with_args)"
|
| 349 |
+
]
|
| 350 |
+
},
|
| 351 |
+
{
|
| 352 |
+
"cell_type": "code",
|
| 353 |
+
"execution_count": 157,
|
| 354 |
+
"id": "6b9b13f4",
|
| 355 |
+
"metadata": {
|
| 356 |
+
"tags": []
|
| 357 |
+
},
|
| 358 |
+
"outputs": [
|
| 359 |
+
{
|
| 360 |
+
"name": "stdout",
|
| 361 |
+
"output_type": "stream",
|
| 362 |
+
"text": [
|
| 363 |
+
"[tensor([2.]), tensor([3.]), tensor([4.]), tensor([5.])]\n"
|
| 364 |
+
]
|
| 365 |
+
}
|
| 366 |
+
],
|
| 367 |
+
"source": [
|
| 368 |
+
"# Run 'add' on the second set of 4 GPUs; the result should be [2, 3, 4, 5].\n",
|
| 369 |
+
"output_1 = worker_group_1.execute_all_sync(\"add\", x=[2, 2, 2, 2])\n",
|
| 370 |
+
"print(output_1)"
|
| 371 |
+
]
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"cell_type": "code",
|
| 375 |
+
"execution_count": 158,
|
| 376 |
+
"id": "d856d030",
|
| 377 |
+
"metadata": {
|
| 378 |
+
"tags": []
|
| 379 |
+
},
|
| 380 |
+
"outputs": [
|
| 381 |
+
{
|
| 382 |
+
"name": "stdout",
|
| 383 |
+
"output_type": "stream",
|
| 384 |
+
"text": [
|
| 385 |
+
"[tensor([3.]), tensor([4.]), tensor([5.]), tensor([6.]), tensor([7.]), tensor([8.]), tensor([9.]), tensor([10.])]\n"
|
| 386 |
+
]
|
| 387 |
+
}
|
| 388 |
+
],
|
| 389 |
+
"source": [
|
| 390 |
+
"# Run 'add' on the merged set of 8 GPUs; the result should be [3, 4, 5, 6, 7, 8, 9, 10].\n",
|
| 391 |
+
"output_merge = worker_group_merge.execute_all_sync(\"add\", x=[3, 3, 3, 3, 3, 3, 3, 3])\n",
|
| 392 |
+
"print(output_merge)"
|
| 393 |
+
]
|
| 394 |
+
},
|
| 395 |
+
{
|
| 396 |
+
"cell_type": "code",
|
| 397 |
+
"execution_count": 159,
|
| 398 |
+
"id": "33a4628c",
|
| 399 |
+
"metadata": {
|
| 400 |
+
"tags": []
|
| 401 |
+
},
|
| 402 |
+
"outputs": [
|
| 403 |
+
{
|
| 404 |
+
"name": "stdout",
|
| 405 |
+
"output_type": "stream",
|
| 406 |
+
"text": [
|
| 407 |
+
"4 4 8\n"
|
| 408 |
+
]
|
| 409 |
+
}
|
| 410 |
+
],
|
| 411 |
+
"source": [
|
| 412 |
+
"print(worker_group.world_size, worker_group_1.world_size, worker_group_merge.world_size)"
|
| 413 |
+
]
|
| 414 |
+
},
|
| 415 |
+
{
|
| 416 |
+
"cell_type": "markdown",
|
| 417 |
+
"id": "3df19d13",
|
| 418 |
+
"metadata": {},
|
| 419 |
+
"source": [
|
| 420 |
+
"## Chapter 3: Data Dispatch, Execution and Collection"
|
| 421 |
+
]
|
| 422 |
+
},
|
| 423 |
+
{
|
| 424 |
+
"cell_type": "markdown",
|
| 425 |
+
"id": "acb22d9d",
|
| 426 |
+
"metadata": {},
|
| 427 |
+
"source": [
|
| 428 |
+
"In the above example, we used the `execute_all_sync` function in the RayWorkerGroup to dispatch data from the driver to each worker. This is very inconvenient for coding. \n",
|
| 429 |
+
"In this chapter, we use the form of function decorators to allow RayWorkerGroup to directly call functions written in the Worker, and to greatly simplify parameter passing."
|
| 430 |
+
]
|
| 431 |
+
},
|
| 432 |
+
{
|
| 433 |
+
"cell_type": "code",
|
| 434 |
+
"execution_count": 160,
|
| 435 |
+
"id": "35237432",
|
| 436 |
+
"metadata": {
|
| 437 |
+
"tags": []
|
| 438 |
+
},
|
| 439 |
+
"outputs": [],
|
| 440 |
+
"source": [
|
| 441 |
+
"from verl.single_controller.base.decorator import Dispatch, Execute, register"
|
| 442 |
+
]
|
| 443 |
+
},
|
| 444 |
+
{
|
| 445 |
+
"cell_type": "code",
|
| 446 |
+
"execution_count": 161,
|
| 447 |
+
"id": "88b8ba3b",
|
| 448 |
+
"metadata": {
|
| 449 |
+
"tags": []
|
| 450 |
+
},
|
| 451 |
+
"outputs": [],
|
| 452 |
+
"source": [
|
| 453 |
+
"@ray.remote\n",
|
| 454 |
+
"class GPUAccumulatorDecorator(Worker):\n",
|
| 455 |
+
" def __init__(self) -> None:\n",
|
| 456 |
+
" super().__init__()\n",
|
| 457 |
+
" # The initial value of each rank is the same as the rank\n",
|
| 458 |
+
" self.value = torch.zeros(size=(1,), device=\"cuda\") + self.rank\n",
|
| 459 |
+
"\n",
|
| 460 |
+
" # map from a single input to all the worker\n",
|
| 461 |
+
" @register(Dispatch.ONE_TO_ALL)\n",
|
| 462 |
+
" def add(self, x):\n",
|
| 463 |
+
" print(x)\n",
|
| 464 |
+
" self.value = self.value + x\n",
|
| 465 |
+
" print(f\"rank {self.rank}, value: {self.value}\")\n",
|
| 466 |
+
" return self.value.cpu()"
|
| 467 |
+
]
|
| 468 |
+
},
|
| 469 |
+
{
|
| 470 |
+
"cell_type": "code",
|
| 471 |
+
"execution_count": 162,
|
| 472 |
+
"id": "eddaa043",
|
| 473 |
+
"metadata": {
|
| 474 |
+
"tags": []
|
| 475 |
+
},
|
| 476 |
+
"outputs": [],
|
| 477 |
+
"source": [
|
| 478 |
+
"class_with_args = RayClassWithInitArgs(cls=GPUAccumulatorDecorator)\n",
|
| 479 |
+
"gpu_accumulator_decorator = RayWorkerGroup(resource_pool_merge, class_with_args)"
|
| 480 |
+
]
|
| 481 |
+
},
|
| 482 |
+
{
|
| 483 |
+
"cell_type": "code",
|
| 484 |
+
"execution_count": 163,
|
| 485 |
+
"id": "10087c91",
|
| 486 |
+
"metadata": {
|
| 487 |
+
"tags": []
|
| 488 |
+
},
|
| 489 |
+
"outputs": [
|
| 490 |
+
{
|
| 491 |
+
"name": "stdout",
|
| 492 |
+
"output_type": "stream",
|
| 493 |
+
"text": [
|
| 494 |
+
"[tensor([10.]), tensor([11.]), tensor([12.]), tensor([13.]), tensor([14.]), tensor([15.]), tensor([16.]), tensor([17.])]\n"
|
| 495 |
+
]
|
| 496 |
+
}
|
| 497 |
+
],
|
| 498 |
+
"source": [
|
| 499 |
+
"# As we can see, 10 is automatically dispatched to each Worker in this RayWorkerGroup.\n",
|
| 500 |
+
"print(gpu_accumulator_decorator.add(x=10))"
|
| 501 |
+
]
|
| 502 |
+
},
|
| 503 |
+
{
|
| 504 |
+
"cell_type": "markdown",
|
| 505 |
+
"id": "540ee6ad",
|
| 506 |
+
"metadata": {},
|
| 507 |
+
"source": [
|
| 508 |
+
"### Custom Dispatch, Collection\n",
|
| 509 |
+
"Users can customize `dispatch` and `collection` function. You only need to write the `dispatch_fn` and `collect_fn` functions yourself. We also support executing RPC only on rank_zero, with specific examples provided below."
|
| 510 |
+
]
|
| 511 |
+
},
|
| 512 |
+
{
|
| 513 |
+
"cell_type": "code",
|
| 514 |
+
"execution_count": 164,
|
| 515 |
+
"id": "8e041270",
|
| 516 |
+
"metadata": {
|
| 517 |
+
"tags": []
|
| 518 |
+
},
|
| 519 |
+
"outputs": [],
|
| 520 |
+
"source": [
|
| 521 |
+
"from verl.single_controller.base.decorator import Dispatch, collect_all_to_all, register"
|
| 522 |
+
]
|
| 523 |
+
},
|
| 524 |
+
{
|
| 525 |
+
"cell_type": "code",
|
| 526 |
+
"execution_count": 165,
|
| 527 |
+
"id": "43b5be31",
|
| 528 |
+
"metadata": {
|
| 529 |
+
"tags": []
|
| 530 |
+
},
|
| 531 |
+
"outputs": [],
|
| 532 |
+
"source": [
|
| 533 |
+
"def two_to_all_dispatch_fn(worker_group, *args, **kwargs):\n",
|
| 534 |
+
" \"\"\"\n",
|
| 535 |
+
" Assume the input is a list of 2. Duplicate the input interleaved and pass to each worker.\n",
|
| 536 |
+
" \"\"\"\n",
|
| 537 |
+
" for arg in args:\n",
|
| 538 |
+
" assert len(arg) == 2\n",
|
| 539 |
+
" for i in range(worker_group.world_size - 2):\n",
|
| 540 |
+
" arg.append(arg[i % 2])\n",
|
| 541 |
+
" for k, v in kwargs.items():\n",
|
| 542 |
+
" assert len(v) == 2\n",
|
| 543 |
+
" for i in range(worker_group.world_size - 2):\n",
|
| 544 |
+
" v.append(v[i % 2])\n",
|
| 545 |
+
" return args, kwargs\n",
|
| 546 |
+
"\n",
|
| 547 |
+
"\n",
|
| 548 |
+
"@ray.remote\n",
|
| 549 |
+
"class TestActor(Worker):\n",
|
| 550 |
+
" # TODO: pass *args and **kwargs is bug prone and not very convincing\n",
|
| 551 |
+
" def __init__(self, x) -> None:\n",
|
| 552 |
+
" super().__init__()\n",
|
| 553 |
+
" self._x = x\n",
|
| 554 |
+
"\n",
|
| 555 |
+
" def foo(self, y):\n",
|
| 556 |
+
" return self._x + y\n",
|
| 557 |
+
"\n",
|
| 558 |
+
" @register(dispatch_mode=Dispatch.ALL_TO_ALL, execute_mode=Execute.RANK_ZERO)\n",
|
| 559 |
+
" def foo_rank_zero(self, x, y):\n",
|
| 560 |
+
" return self._x + y + x\n",
|
| 561 |
+
"\n",
|
| 562 |
+
" @register(dispatch_mode={\"dispatch_fn\": two_to_all_dispatch_fn, \"collect_fn\": collect_all_to_all})\n",
|
| 563 |
+
" def foo_custom(self, x, y):\n",
|
| 564 |
+
" return self._x + y + x"
|
| 565 |
+
]
|
| 566 |
+
},
|
| 567 |
+
{
|
| 568 |
+
"cell_type": "code",
|
| 569 |
+
"execution_count": 166,
|
| 570 |
+
"id": "83ec6609",
|
| 571 |
+
"metadata": {
|
| 572 |
+
"tags": []
|
| 573 |
+
},
|
| 574 |
+
"outputs": [],
|
| 575 |
+
"source": [
|
| 576 |
+
"class_with_args = RayClassWithInitArgs(cls=TestActor, x=2)\n",
|
| 577 |
+
"worker_group = RayWorkerGroup(resource_pool, class_with_args)"
|
| 578 |
+
]
|
| 579 |
+
},
|
| 580 |
+
{
|
| 581 |
+
"cell_type": "code",
|
| 582 |
+
"execution_count": 167,
|
| 583 |
+
"id": "62c58d8a",
|
| 584 |
+
"metadata": {
|
| 585 |
+
"tags": []
|
| 586 |
+
},
|
| 587 |
+
"outputs": [],
|
| 588 |
+
"source": [
|
| 589 |
+
"output_ref = worker_group.foo_custom(x=[1, 2], y=[5, 6])\n",
|
| 590 |
+
"assert output_ref == [8, 10, 8, 10]\n",
|
| 591 |
+
"\n",
|
| 592 |
+
"output_ref = worker_group.foo_rank_zero(x=1, y=2)\n",
|
| 593 |
+
"assert output_ref == 5"
|
| 594 |
+
]
|
| 595 |
+
},
|
| 596 |
+
{
|
| 597 |
+
"cell_type": "code",
|
| 598 |
+
"execution_count": 168,
|
| 599 |
+
"id": "14689353",
|
| 600 |
+
"metadata": {
|
| 601 |
+
"tags": []
|
| 602 |
+
},
|
| 603 |
+
"outputs": [
|
| 604 |
+
{
|
| 605 |
+
"name": "stdout",
|
| 606 |
+
"output_type": "stream",
|
| 607 |
+
"text": [
|
| 608 |
+
"8\n"
|
| 609 |
+
]
|
| 610 |
+
}
|
| 611 |
+
],
|
| 612 |
+
"source": [
|
| 613 |
+
"print(gpu_accumulator_decorator.world_size)"
|
| 614 |
+
]
|
| 615 |
+
},
|
| 616 |
+
{
|
| 617 |
+
"cell_type": "code",
|
| 618 |
+
"execution_count": 169,
|
| 619 |
+
"id": "2c80bbf4",
|
| 620 |
+
"metadata": {
|
| 621 |
+
"tags": []
|
| 622 |
+
},
|
| 623 |
+
"outputs": [],
|
| 624 |
+
"source": [
|
| 625 |
+
"# Shutdown ray cluster\n",
|
| 626 |
+
"ray.shutdown()"
|
| 627 |
+
]
|
| 628 |
+
},
|
| 629 |
+
{
|
| 630 |
+
"cell_type": "markdown",
|
| 631 |
+
"id": "a5c8151c",
|
| 632 |
+
"metadata": {},
|
| 633 |
+
"source": [
|
| 634 |
+
"## Chapter 4: NVMegatronRayWorkerGroup"
|
| 635 |
+
]
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
"cell_type": "markdown",
|
| 639 |
+
"id": "cd5680e9",
|
| 640 |
+
"metadata": {},
|
| 641 |
+
"source": [
|
| 642 |
+
"Due to the Ray issue, we can only support max_colocate_count=1 in RayResourcePool for now. \n",
|
| 643 |
+
"This means that each GPU can only have one process.\n",
|
| 644 |
+
"We can support max_colocate > 1 when applying this pull request: https://github.com/ray-project/ray/pull/44385"
|
| 645 |
+
]
|
| 646 |
+
},
|
| 647 |
+
{
|
| 648 |
+
"cell_type": "markdown",
|
| 649 |
+
"id": "92724419",
|
| 650 |
+
"metadata": {},
|
| 651 |
+
"source": [
|
| 652 |
+
"Therefore, we need to restart the ray and initialize a new resource_pool to demonstrate the **NVMegatronRayWorkerGroup**"
|
| 653 |
+
]
|
| 654 |
+
},
|
| 655 |
+
{
|
| 656 |
+
"cell_type": "code",
|
| 657 |
+
"execution_count": null,
|
| 658 |
+
"id": "9b038538",
|
| 659 |
+
"metadata": {
|
| 660 |
+
"tags": []
|
| 661 |
+
},
|
| 662 |
+
"outputs": [],
|
| 663 |
+
"source": [
|
| 664 |
+
"# Build a local ray cluster. The head node and worker node are on this machine\n",
|
| 665 |
+
"ray.init()"
|
| 666 |
+
]
|
| 667 |
+
},
|
| 668 |
+
{
|
| 669 |
+
"cell_type": "markdown",
|
| 670 |
+
"id": "ebfd8798",
|
| 671 |
+
"metadata": {},
|
| 672 |
+
"source": [
|
| 673 |
+
"Finally, we implement a `NVMegatronRayWorkerGroup`, within which we create a Megatron and then run a tensor parallel (tp) split Llama mlp layer. Here, we use a complex dispatch mode, `Megatron_COMPUTE`. This dispatch mode assumes that user passes the data partitioned by DP dimension. The data is dispatched to all tp/pp ranks within the same dp group, and ultimately only collects output data from tp=0 and the last pp. In this way, for users that only write code on the driver, the Megatron behind the RPC becomes transparent."
|
| 674 |
+
]
|
| 675 |
+
},
|
| 676 |
+
{
|
| 677 |
+
"cell_type": "code",
|
| 678 |
+
"execution_count": 171,
|
| 679 |
+
"id": "5a032154",
|
| 680 |
+
"metadata": {
|
| 681 |
+
"tags": []
|
| 682 |
+
},
|
| 683 |
+
"outputs": [
|
| 684 |
+
{
|
| 685 |
+
"name": "stdout",
|
| 686 |
+
"output_type": "stream",
|
| 687 |
+
"text": [
|
| 688 |
+
"/opt/tiger/Megatron-LM\n",
|
| 689 |
+
"/opt/tiger/Megatron-LM/megatron/__init__.py\n"
|
| 690 |
+
]
|
| 691 |
+
}
|
| 692 |
+
],
|
| 693 |
+
"source": [
|
| 694 |
+
"import sys\n",
|
| 695 |
+
"\n",
|
| 696 |
+
"current_pythonpath = os.environ.get(\"PYTHONPATH\", \"\")\n",
|
| 697 |
+
"\n",
|
| 698 |
+
"new_path = \"/opt/tiger/Megatron-LM\"\n",
|
| 699 |
+
"\n",
|
| 700 |
+
"new_pythonpath = f\"{new_path}:{current_pythonpath}\" if current_pythonpath else new_path\n",
|
| 701 |
+
"\n",
|
| 702 |
+
"os.environ[\"PYTHONPATH\"] = new_pythonpath\n",
|
| 703 |
+
"\n",
|
| 704 |
+
"print(new_path)\n",
|
| 705 |
+
"sys.path.append(new_path)\n",
|
| 706 |
+
"\n",
|
| 707 |
+
"import megatron\n",
|
| 708 |
+
"\n",
|
| 709 |
+
"print(megatron.__file__)"
|
| 710 |
+
]
|
| 711 |
+
},
|
| 712 |
+
{
|
| 713 |
+
"cell_type": "code",
|
| 714 |
+
"execution_count": 172,
|
| 715 |
+
"id": "8c84cd5a",
|
| 716 |
+
"metadata": {
|
| 717 |
+
"tags": []
|
| 718 |
+
},
|
| 719 |
+
"outputs": [],
|
| 720 |
+
"source": [
|
| 721 |
+
"from megatron.core import parallel_state as mpu\n",
|
| 722 |
+
"from omegaconf import OmegaConf\n",
|
| 723 |
+
"\n",
|
| 724 |
+
"from verl.single_controller.base.decorator import Dispatch, Execute, register\n",
|
| 725 |
+
"from verl.single_controller.base.megatron.worker import MegatronWorker\n",
|
| 726 |
+
"from verl.single_controller.ray.base import RayClassWithInitArgs, RayResourcePool, RayWorkerGroup\n",
|
| 727 |
+
"from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup"
|
| 728 |
+
]
|
| 729 |
+
},
|
| 730 |
+
{
|
| 731 |
+
"cell_type": "code",
|
| 732 |
+
"execution_count": 173,
|
| 733 |
+
"id": "1b1debcc",
|
| 734 |
+
"metadata": {
|
| 735 |
+
"tags": []
|
| 736 |
+
},
|
| 737 |
+
"outputs": [],
|
| 738 |
+
"source": [
|
| 739 |
+
"resource_pool = RayResourcePool([4], use_gpu=True, max_colocate_count=1)"
|
| 740 |
+
]
|
| 741 |
+
},
|
| 742 |
+
{
|
| 743 |
+
"cell_type": "code",
|
| 744 |
+
"execution_count": 174,
|
| 745 |
+
"id": "bccbe081",
|
| 746 |
+
"metadata": {
|
| 747 |
+
"tags": []
|
| 748 |
+
},
|
| 749 |
+
"outputs": [],
|
| 750 |
+
"source": [
|
| 751 |
+
"@ray.remote\n",
|
| 752 |
+
"class MLPLayerWorker(MegatronWorker):\n",
|
| 753 |
+
" def __init__(self):\n",
|
| 754 |
+
" super().__init__()\n",
|
| 755 |
+
" rank = int(os.environ[\"LOCAL_RANK\"])\n",
|
| 756 |
+
" torch.distributed.init_process_group(backend=\"nccl\")\n",
|
| 757 |
+
" torch.cuda.set_device(rank)\n",
|
| 758 |
+
"\n",
|
| 759 |
+
" mpu.initialize_model_parallel(\n",
|
| 760 |
+
" tensor_model_parallel_size=4,\n",
|
| 761 |
+
" pipeline_model_parallel_size=1,\n",
|
| 762 |
+
" virtual_pipeline_model_parallel_size=None,\n",
|
| 763 |
+
" pipeline_model_parallel_split_rank=None,\n",
|
| 764 |
+
" use_sharp=False,\n",
|
| 765 |
+
" context_parallel_size=1,\n",
|
| 766 |
+
" expert_model_parallel_size=1,\n",
|
| 767 |
+
" nccl_communicator_config_path=None,\n",
|
| 768 |
+
" )\n",
|
| 769 |
+
" from megatron.core import tensor_parallel\n",
|
| 770 |
+
"\n",
|
| 771 |
+
" tensor_parallel.model_parallel_cuda_manual_seed(10)\n",
|
| 772 |
+
"\n",
|
| 773 |
+
" @register(Dispatch.ONE_TO_ALL)\n",
|
| 774 |
+
" def init_model(self, config):\n",
|
| 775 |
+
" from omegaconf import OmegaConf\n",
|
| 776 |
+
"\n",
|
| 777 |
+
" from verl.models.llama.megatron.layers import ParallelLlamaMLP\n",
|
| 778 |
+
" from verl.utils.megatron_utils import init_model_parallel_config\n",
|
| 779 |
+
"\n",
|
| 780 |
+
" megatron_config = OmegaConf.create(\n",
|
| 781 |
+
" {\n",
|
| 782 |
+
" \"sequence_parallel\": False,\n",
|
| 783 |
+
" \"param_dtype\": \"fp32\",\n",
|
| 784 |
+
" \"tensor_model_parallel_size\": mpu.get_tensor_model_parallel_world_size(),\n",
|
| 785 |
+
" \"pipeline_model_parallel_rank\": mpu.get_pipeline_model_parallel_rank(),\n",
|
| 786 |
+
" \"pipeline_model_parallel_size\": mpu.get_pipeline_model_parallel_world_size(),\n",
|
| 787 |
+
" \"virtual_pipeline_model_parallel_rank\": mpu.get_virtual_pipeline_model_parallel_rank(),\n",
|
| 788 |
+
" \"virtual_pipeline_model_parallel_size\": mpu.get_virtual_pipeline_model_parallel_world_size(),\n",
|
| 789 |
+
" }\n",
|
| 790 |
+
" )\n",
|
| 791 |
+
"\n",
|
| 792 |
+
" megatron_config = init_model_parallel_config(megatron_config)\n",
|
| 793 |
+
" self.parallel_layer = ParallelLlamaMLP(config=config, megatron_config=megatron_config)\n",
|
| 794 |
+
"\n",
|
| 795 |
+
" @register(Dispatch.ONE_TO_ALL)\n",
|
| 796 |
+
" def get_weights(self):\n",
|
| 797 |
+
" output = {}\n",
|
| 798 |
+
" for key, val in self.parallel_layer.named_parameters():\n",
|
| 799 |
+
" output[key] = val\n",
|
| 800 |
+
" return output\n",
|
| 801 |
+
"\n",
|
| 802 |
+
" @register(Dispatch.MEGATRON_COMPUTE)\n",
|
| 803 |
+
" def run_layer(self, x):\n",
|
| 804 |
+
" x = x.to(\"cuda\")\n",
|
| 805 |
+
" y = self.parallel_layer(x)\n",
|
| 806 |
+
" return y"
|
| 807 |
+
]
|
| 808 |
+
},
|
| 809 |
+
{
|
| 810 |
+
"cell_type": "code",
|
| 811 |
+
"execution_count": 175,
|
| 812 |
+
"id": "a655271d",
|
| 813 |
+
"metadata": {
|
| 814 |
+
"tags": []
|
| 815 |
+
},
|
| 816 |
+
"outputs": [],
|
| 817 |
+
"source": [
|
| 818 |
+
"layer_cls = RayClassWithInitArgs(cls=MLPLayerWorker)\n",
|
| 819 |
+
"layer_worker_group = NVMegatronRayWorkerGroup(\n",
|
| 820 |
+
" resource_pool=resource_pool,\n",
|
| 821 |
+
" ray_cls_with_init=layer_cls,\n",
|
| 822 |
+
")"
|
| 823 |
+
]
|
| 824 |
+
},
|
| 825 |
+
{
|
| 826 |
+
"cell_type": "code",
|
| 827 |
+
"execution_count": 176,
|
| 828 |
+
"id": "f105ebee",
|
| 829 |
+
"metadata": {
|
| 830 |
+
"tags": []
|
| 831 |
+
},
|
| 832 |
+
"outputs": [
|
| 833 |
+
{
|
| 834 |
+
"name": "stdout",
|
| 835 |
+
"output_type": "stream",
|
| 836 |
+
"text": [
|
| 837 |
+
"4 4 1 1\n"
|
| 838 |
+
]
|
| 839 |
+
}
|
| 840 |
+
],
|
| 841 |
+
"source": [
|
| 842 |
+
"print(layer_worker_group.world_size, layer_worker_group.tp_size, layer_worker_group.pp_size, layer_worker_group.dp_size)"
|
| 843 |
+
]
|
| 844 |
+
},
|
| 845 |
+
{
|
| 846 |
+
"cell_type": "code",
|
| 847 |
+
"execution_count": 177,
|
| 848 |
+
"id": "38655091",
|
| 849 |
+
"metadata": {
|
| 850 |
+
"tags": []
|
| 851 |
+
},
|
| 852 |
+
"outputs": [],
|
| 853 |
+
"source": [
|
| 854 |
+
"ffn_hidden_size = 11008\n",
|
| 855 |
+
"batch_size = 16\n",
|
| 856 |
+
"seq_len = 2048\n",
|
| 857 |
+
"hidden_size = 4096\n",
|
| 858 |
+
"\n",
|
| 859 |
+
"config = OmegaConf.create(\n",
|
| 860 |
+
" {\n",
|
| 861 |
+
" \"hidden_size\": hidden_size,\n",
|
| 862 |
+
" \"intermediate_size\": ffn_hidden_size,\n",
|
| 863 |
+
" \"hidden_act\": \"silu\",\n",
|
| 864 |
+
" \"pretraining_tp\": 1,\n",
|
| 865 |
+
" \"tp\": layer_worker_group.tp_size,\n",
|
| 866 |
+
" }\n",
|
| 867 |
+
")"
|
| 868 |
+
]
|
| 869 |
+
},
|
| 870 |
+
{
|
| 871 |
+
"cell_type": "code",
|
| 872 |
+
"execution_count": 178,
|
| 873 |
+
"id": "a026efca",
|
| 874 |
+
"metadata": {
|
| 875 |
+
"tags": []
|
| 876 |
+
},
|
| 877 |
+
"outputs": [],
|
| 878 |
+
"source": [
|
| 879 |
+
"x = torch.rand(size=(seq_len, batch_size, hidden_size), dtype=torch.float32)"
|
| 880 |
+
]
|
| 881 |
+
},
|
| 882 |
+
{
|
| 883 |
+
"cell_type": "code",
|
| 884 |
+
"execution_count": 179,
|
| 885 |
+
"id": "f5fcaf13",
|
| 886 |
+
"metadata": {
|
| 887 |
+
"tags": []
|
| 888 |
+
},
|
| 889 |
+
"outputs": [
|
| 890 |
+
{
|
| 891 |
+
"data": {
|
| 892 |
+
"text/plain": [
|
| 893 |
+
"[None, None, None, None]"
|
| 894 |
+
]
|
| 895 |
+
},
|
| 896 |
+
"execution_count": 179,
|
| 897 |
+
"metadata": {},
|
| 898 |
+
"output_type": "execute_result"
|
| 899 |
+
}
|
| 900 |
+
],
|
| 901 |
+
"source": [
|
| 902 |
+
"layer_worker_group.init_model(config)"
|
| 903 |
+
]
|
| 904 |
+
},
|
| 905 |
+
{
|
| 906 |
+
"cell_type": "code",
|
| 907 |
+
"execution_count": 180,
|
| 908 |
+
"id": "3f5cc9b4",
|
| 909 |
+
"metadata": {
|
| 910 |
+
"tags": []
|
| 911 |
+
},
|
| 912 |
+
"outputs": [
|
| 913 |
+
{
|
| 914 |
+
"name": "stdout",
|
| 915 |
+
"output_type": "stream",
|
| 916 |
+
"text": [
|
| 917 |
+
"torch.Size([2048, 16, 4096])\n"
|
| 918 |
+
]
|
| 919 |
+
}
|
| 920 |
+
],
|
| 921 |
+
"source": [
|
| 922 |
+
"output = layer_worker_group.run_layer(\n",
|
| 923 |
+
" [x]\n",
|
| 924 |
+
") # This must be a list of size 1, ensuring that the input equals the data parallel (dp).\n",
|
| 925 |
+
"print(output[0].shape)"
|
| 926 |
+
]
|
| 927 |
+
},
|
| 928 |
+
{
|
| 929 |
+
"cell_type": "code",
|
| 930 |
+
"execution_count": 181,
|
| 931 |
+
"id": "49792210",
|
| 932 |
+
"metadata": {
|
| 933 |
+
"tags": []
|
| 934 |
+
},
|
| 935 |
+
"outputs": [],
|
| 936 |
+
"source": [
|
| 937 |
+
"# Shutdown ray cluster\n",
|
| 938 |
+
"ray.shutdown()"
|
| 939 |
+
]
|
| 940 |
+
}
|
| 941 |
+
],
|
| 942 |
+
"metadata": {
|
| 943 |
+
"kernelspec": {
|
| 944 |
+
"display_name": "Python 3 (ipykernel)",
|
| 945 |
+
"language": "python",
|
| 946 |
+
"name": "python3"
|
| 947 |
+
},
|
| 948 |
+
"language_info": {
|
| 949 |
+
"codemirror_mode": {
|
| 950 |
+
"name": "ipython",
|
| 951 |
+
"version": 3
|
| 952 |
+
},
|
| 953 |
+
"file_extension": ".py",
|
| 954 |
+
"mimetype": "text/x-python",
|
| 955 |
+
"name": "python",
|
| 956 |
+
"nbconvert_exporter": "python",
|
| 957 |
+
"pygments_lexer": "ipython3",
|
| 958 |
+
"version": "3.9.2"
|
| 959 |
+
}
|
| 960 |
+
},
|
| 961 |
+
"nbformat": 4,
|
| 962 |
+
"nbformat_minor": 5
|
| 963 |
+
}
|
verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 5 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 6 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 7 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 8 |
+
|
| 9 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 10 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 11 |
+
|
| 12 |
+
python3 -m verl.trainer.main_ppo \
|
| 13 |
+
algorithm.adv_estimator=reinforce_plus_plus \
|
| 14 |
+
data.train_files="$train_files" \
|
| 15 |
+
data.val_files="$test_files" \
|
| 16 |
+
data.train_batch_size=1024 \
|
| 17 |
+
data.max_prompt_length=1024 \
|
| 18 |
+
data.max_response_length=1024 \
|
| 19 |
+
data.filter_overlong_prompts=True \
|
| 20 |
+
data.truncation='error' \
|
| 21 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=3e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=1024 \
|
| 25 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 26 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 27 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 28 |
+
actor_rollout_ref.actor.kl_loss_type=mse \
|
| 29 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 30 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 31 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 32 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 33 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \
|
| 34 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 35 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 36 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 37 |
+
actor_rollout_ref.rollout.n=8 \
|
| 38 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \
|
| 39 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 40 |
+
algorithm.use_kl_in_reward=True \
|
| 41 |
+
trainer.critic_warmup=0 \
|
| 42 |
+
trainer.logger='["console","wandb"]' \
|
| 43 |
+
trainer.project_name='verl_grpo_example_gsm8k' \
|
| 44 |
+
trainer.experiment_name='qwen2_7b_function_rm' \
|
| 45 |
+
trainer.n_gpus_per_node=16 \
|
| 46 |
+
trainer.nnodes=1 \
|
| 47 |
+
trainer.save_freq=-1 \
|
| 48 |
+
trainer.test_freq=5 \
|
| 49 |
+
trainer.total_epochs=15 $@
|
verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf_baseline.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
gsm8k_train_path=$HOME/data/gsm8k/train.parquet
|
| 5 |
+
gsm8k_test_path=$HOME/data/gsm8k/test.parquet
|
| 6 |
+
math_train_path=$HOME/data/math/train.parquet
|
| 7 |
+
math_test_path=$HOME/data/math/test.parquet
|
| 8 |
+
|
| 9 |
+
train_files="['$gsm8k_train_path', '$math_train_path']"
|
| 10 |
+
test_files="['$gsm8k_test_path', '$math_test_path']"
|
| 11 |
+
|
| 12 |
+
python3 -m verl.trainer.main_ppo \
|
| 13 |
+
algorithm.adv_estimator=reinforce_plus_plus_baseline \
|
| 14 |
+
data.train_files="$train_files" \
|
| 15 |
+
data.val_files="$test_files" \
|
| 16 |
+
data.train_batch_size=1024 \
|
| 17 |
+
data.max_prompt_length=1024 \
|
| 18 |
+
data.max_response_length=1024 \
|
| 19 |
+
data.filter_overlong_prompts=True \
|
| 20 |
+
data.truncation='error' \
|
| 21 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 22 |
+
actor_rollout_ref.actor.optim.lr=3e-6 \
|
| 23 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 24 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=1024 \
|
| 25 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
|
| 26 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 27 |
+
actor_rollout_ref.actor.kl_loss_coef=0.001 \
|
| 28 |
+
actor_rollout_ref.actor.kl_loss_type=mse \
|
| 29 |
+
actor_rollout_ref.actor.entropy_coeff=0 \
|
| 30 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 31 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 32 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 33 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \
|
| 34 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 35 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 36 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 37 |
+
actor_rollout_ref.rollout.n=8 \
|
| 38 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \
|
| 39 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 40 |
+
algorithm.use_kl_in_reward=True \
|
| 41 |
+
trainer.critic_warmup=0 \
|
| 42 |
+
trainer.logger='["console","wandb"]' \
|
| 43 |
+
trainer.project_name='verl_grpo_example_gsm8k' \
|
| 44 |
+
trainer.experiment_name='qwen2_7b_function_rm' \
|
| 45 |
+
trainer.n_gpus_per_node=16 \
|
| 46 |
+
trainer.nnodes=1 \
|
| 47 |
+
trainer.save_freq=-1 \
|
| 48 |
+
trainer.test_freq=5 \
|
| 49 |
+
trainer.total_epochs=15 $@
|
verl/examples/remax_trainer/run_qwen2.5-3b_seq_balance.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export HF_DATASETS_OFFLINE=1
|
| 4 |
+
export TRANSFORMERS_OFFLINE=1
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
python3 -m verl.trainer.main_ppo \
|
| 8 |
+
algorithm.adv_estimator=remax \
|
| 9 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 10 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 11 |
+
data.train_batch_size=512 \
|
| 12 |
+
data.max_prompt_length=512 \
|
| 13 |
+
data.max_response_length=1024 \
|
| 14 |
+
data.filter_overlong_prompts=True \
|
| 15 |
+
data.truncation='error' \
|
| 16 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-3B-Instruct \
|
| 17 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 18 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 19 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=128 \
|
| 20 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 21 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=30000 \
|
| 22 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 23 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 24 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 25 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 26 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 27 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 28 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \
|
| 29 |
+
actor_rollout_ref.rollout.n=4 \
|
| 30 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 31 |
+
algorithm.use_kl_in_reward=True \
|
| 32 |
+
algorithm.kl_penalty=kl \
|
| 33 |
+
algorithm.kl_ctrl.kl_coef=0.001 \
|
| 34 |
+
trainer.critic_warmup=0 \
|
| 35 |
+
trainer.logger='["console","wandb"]' \
|
| 36 |
+
trainer.project_name='verl_remax_example_gsm8k' \
|
| 37 |
+
trainer.experiment_name='qwen2.5_3b_function_rm_kl1e-3' \
|
| 38 |
+
trainer.val_before_train=False \
|
| 39 |
+
trainer.n_gpus_per_node=8 \
|
| 40 |
+
trainer.nnodes=1 \
|
| 41 |
+
trainer.save_freq=-1 \
|
| 42 |
+
trainer.test_freq=5 \
|
| 43 |
+
trainer.total_epochs=5 $@
|
verl/examples/remax_trainer/run_qwen2.5-7b_seq_balance.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
export HF_DATASETS_OFFLINE=1
|
| 4 |
+
export TRANSFORMERS_OFFLINE=1
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
python3 -m verl.trainer.main_ppo \
|
| 8 |
+
algorithm.adv_estimator=remax \
|
| 9 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 10 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 11 |
+
data.train_batch_size=1024 \
|
| 12 |
+
data.max_prompt_length=512 \
|
| 13 |
+
data.max_response_length=1024 \
|
| 14 |
+
data.filter_overlong_prompts=True \
|
| 15 |
+
data.truncation='error' \
|
| 16 |
+
actor_rollout_ref.model.path=Qwen/Qwen2.5-7B-Instruct \
|
| 17 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 18 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 19 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 20 |
+
actor_rollout_ref.actor.use_dynamic_bsz=True \
|
| 21 |
+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \
|
| 22 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 23 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 24 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 25 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 26 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 27 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 28 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \
|
| 29 |
+
actor_rollout_ref.rollout.n=4 \
|
| 30 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 31 |
+
algorithm.use_kl_in_reward=True \
|
| 32 |
+
algorithm.kl_penalty=kl \
|
| 33 |
+
algorithm.kl_ctrl.kl_coef=0.001 \
|
| 34 |
+
trainer.critic_warmup=0 \
|
| 35 |
+
trainer.logger='["console","wandb"]' \
|
| 36 |
+
trainer.project_name='verl_remax_example_gsm8k' \
|
| 37 |
+
trainer.experiment_name='qwen2.5_7b_function_rm_kl1e-3' \
|
| 38 |
+
trainer.val_before_train=False \
|
| 39 |
+
trainer.n_gpus_per_node=8 \
|
| 40 |
+
trainer.nnodes=1 \
|
| 41 |
+
trainer.save_freq=-1 \
|
| 42 |
+
trainer.test_freq=5 \
|
| 43 |
+
trainer.total_epochs=10 $@
|
verl/examples/rloo_trainer/run_qwen2-7b.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
python3 -m verl.trainer.main_ppo \
|
| 5 |
+
algorithm.adv_estimator=rloo \
|
| 6 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 7 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 8 |
+
data.train_batch_size=1024 \
|
| 9 |
+
data.max_prompt_length=512 \
|
| 10 |
+
data.max_response_length=1024 \
|
| 11 |
+
data.filter_overlong_prompts=True \
|
| 12 |
+
data.truncation='error' \
|
| 13 |
+
actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \
|
| 14 |
+
actor_rollout_ref.actor.optim.lr=1e-6 \
|
| 15 |
+
actor_rollout_ref.model.use_remove_padding=True \
|
| 16 |
+
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
|
| 17 |
+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=80 \
|
| 18 |
+
actor_rollout_ref.actor.use_kl_loss=False \
|
| 19 |
+
actor_rollout_ref.model.enable_gradient_checkpointing=True \
|
| 20 |
+
actor_rollout_ref.actor.fsdp_config.param_offload=False \
|
| 21 |
+
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
|
| 22 |
+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=160 \
|
| 23 |
+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
|
| 24 |
+
actor_rollout_ref.rollout.name=vllm \
|
| 25 |
+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
|
| 26 |
+
actor_rollout_ref.rollout.n=5 \
|
| 27 |
+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=160 \
|
| 28 |
+
actor_rollout_ref.ref.fsdp_config.param_offload=True \
|
| 29 |
+
algorithm.use_kl_in_reward=True \
|
| 30 |
+
algorithm.kl_penalty=kl \
|
| 31 |
+
algorithm.kl_ctrl.kl_coef=0.001 \
|
| 32 |
+
trainer.critic_warmup=0 \
|
| 33 |
+
trainer.logger='["console","wandb"]' \
|
| 34 |
+
trainer.project_name='verl_rloo_example_gsm8k' \
|
| 35 |
+
trainer.experiment_name='qwen2_7b_function_rm' \
|
| 36 |
+
trainer.n_gpus_per_node=8 \
|
| 37 |
+
trainer.nnodes=1 \
|
| 38 |
+
trainer.save_freq=-1 \
|
| 39 |
+
trainer.test_freq=5 \
|
| 40 |
+
trainer.total_epochs=15 $@
|
verl/examples/sft/gsm8k/run_deepseek_6b7.sh
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_deepseek_6b7.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
data.prompt_dict_keys=['question'] \
|
| 21 |
+
+data.response_dict_keys=['answer'] \
|
| 22 |
+
data.micro_batch_size_per_gpu=4 \
|
| 23 |
+
model.partial_pretrain=deepseek-ai/deepseek-coder-6.7b-instruct \
|
| 24 |
+
trainer.default_local_dir=$save_path \
|
| 25 |
+
trainer.project_name=gsm8k-sft \
|
| 26 |
+
trainer.experiment_name=gsm8k-sft-deepseek-coder-6.7b-instruct \
|
| 27 |
+
trainer.total_epochs=4 \
|
| 28 |
+
trainer.logger='["console","wandb"]' $@
|
verl/examples/sft/gsm8k/run_gemma_2b.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Tested with 2 & 4 GPUs
|
| 2 |
+
|
| 3 |
+
set -x
|
| 4 |
+
|
| 5 |
+
if [ "$#" -lt 2 ]; then
|
| 6 |
+
echo "Usage: run_gemma_2b.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 7 |
+
exit 1
|
| 8 |
+
fi
|
| 9 |
+
|
| 10 |
+
nproc_per_node=$1
|
| 11 |
+
save_path=$2
|
| 12 |
+
|
| 13 |
+
# Shift the arguments so $@ refers to the rest
|
| 14 |
+
shift 2
|
| 15 |
+
|
| 16 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 17 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 18 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 19 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 20 |
+
data.prompt_key=extra_info \
|
| 21 |
+
data.response_key=extra_info \
|
| 22 |
+
data.prompt_dict_keys=['question'] \
|
| 23 |
+
+data.response_dict_keys=['answer'] \
|
| 24 |
+
data.micro_batch_size_per_gpu=4 \
|
| 25 |
+
model.partial_pretrain=google/gemma-2b-it \
|
| 26 |
+
trainer.default_local_dir=$save_path \
|
| 27 |
+
trainer.project_name=gsm8k-sft \
|
| 28 |
+
trainer.experiment_name=gsm8k-sft-gemma-2b-it \
|
| 29 |
+
trainer.total_epochs=2 \
|
| 30 |
+
trainer.logger='["console","wandb"]' $@
|
verl/examples/sft/gsm8k/run_gemma_7b.sh
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_gemma_7b.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
data.prompt_dict_keys=['question'] \
|
| 21 |
+
data.response_dict_keys=['answer'] \
|
| 22 |
+
data.micro_batch_size_per_gpu=4 \
|
| 23 |
+
model.partial_pretrain=google/gemma-1.1-7b-it \
|
| 24 |
+
trainer.default_local_dir=$save_path \
|
| 25 |
+
trainer.project_name=gsm8k-sft \
|
| 26 |
+
trainer.experiment_name=gsm8k-sft-gemma-1.1-7b-it \
|
| 27 |
+
trainer.total_epochs=4 \
|
| 28 |
+
trainer.logger='["console","wandb"]' $@
|
verl/examples/sft/gsm8k/run_qwen3_8b_sft_peft_sp2_npu.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_qwen3_8b_sft_peft_sp2_npu.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
optim.lr=1e-4 \
|
| 21 |
+
data.prompt_dict_keys=['question'] \
|
| 22 |
+
+data.response_dict_keys=['answer'] \
|
| 23 |
+
data.micro_batch_size_per_gpu=64 \
|
| 24 |
+
model.partial_pretrain=Qwen/Qwen3-8B \
|
| 25 |
+
trainer.default_local_dir=$save_path \
|
| 26 |
+
trainer.project_name=gsm8k-sft \
|
| 27 |
+
trainer.experiment_name=gsm8k-sft-qwen3-8b-instruct \
|
| 28 |
+
trainer.logger=console \
|
| 29 |
+
trainer.total_epochs=2 $@ \
|
| 30 |
+
model.lora_rank=32 \
|
| 31 |
+
model.lora_alpha=16 \
|
| 32 |
+
model.target_modules=all-linear \
|
| 33 |
+
model.strategy=fsdp \
|
| 34 |
+
ulysses_sequence_parallel_size=2 \
|
| 35 |
+
use_remove_padding=true \
|
| 36 |
+
trainer.device=npu
|
verl/examples/sft/gsm8k/run_qwen_05_peft.sh
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Tested with 2 & 4 GPUs
|
| 2 |
+
|
| 3 |
+
set -x
|
| 4 |
+
|
| 5 |
+
if [ "$#" -lt 2 ]; then
|
| 6 |
+
echo "Usage: run_qwen_05_peft.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 7 |
+
exit 1
|
| 8 |
+
fi
|
| 9 |
+
|
| 10 |
+
nproc_per_node=$1
|
| 11 |
+
save_path=$2
|
| 12 |
+
|
| 13 |
+
# Shift the arguments so $@ refers to the rest
|
| 14 |
+
shift 2
|
| 15 |
+
|
| 16 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 17 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 18 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 19 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 20 |
+
data.prompt_key=extra_info \
|
| 21 |
+
data.response_key=extra_info \
|
| 22 |
+
optim.lr=1e-4 \
|
| 23 |
+
data.prompt_dict_keys=['question'] \
|
| 24 |
+
+data.response_dict_keys=['answer'] \
|
| 25 |
+
data.micro_batch_size_per_gpu=4 \
|
| 26 |
+
model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \
|
| 27 |
+
trainer.default_local_dir=$save_path \
|
| 28 |
+
trainer.project_name=gsm8k-sft \
|
| 29 |
+
trainer.experiment_name=gsm8k-sft-qwen-2.5-0.5b-instruct \
|
| 30 |
+
trainer.logger=console \
|
| 31 |
+
trainer.total_epochs=1 $@ \
|
| 32 |
+
model.lora_rank=32\
|
| 33 |
+
model.lora_alpha=16 \
|
| 34 |
+
model.target_modules=all-linear
|
| 35 |
+
|
| 36 |
+
# Or you can do this:
|
| 37 |
+
# model.target_modules=[q_proj,v_proj] \
|
verl/examples/sft/gsm8k/run_qwen_05_sp2.sh
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_qwen_05_sp2.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
optim.lr=1e-4 \
|
| 21 |
+
data.prompt_dict_keys=['question'] \
|
| 22 |
+
+data.response_dict_keys=['answer'] \
|
| 23 |
+
data.micro_batch_size=4 \
|
| 24 |
+
model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \
|
| 25 |
+
trainer.default_local_dir=$save_path \
|
| 26 |
+
trainer.project_name=gsm8k-sft \
|
| 27 |
+
trainer.experiment_name=gsm8k-sft-qwen-2.5-0.5b-instruct-sp2 \
|
| 28 |
+
trainer.logger=console \
|
| 29 |
+
trainer.total_training_steps=1 $@ \
|
| 30 |
+
ulysses_sequence_parallel_size=2 \
|
| 31 |
+
use_remove_padding=true
|
verl/examples/sft/gsm8k/run_qwen_05_sp2_liger.sh
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_qwen_05_sp2.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
optim.lr=1e-4 \
|
| 21 |
+
data.prompt_dict_keys=['question'] \
|
| 22 |
+
+data.response_dict_keys=['answer'] \
|
| 23 |
+
data.micro_batch_size=4 \
|
| 24 |
+
model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \
|
| 25 |
+
model.use_liger=True \
|
| 26 |
+
trainer.default_local_dir=$save_path \
|
| 27 |
+
trainer.project_name=gsm8k-sft \
|
| 28 |
+
trainer.experiment_name=gsm8k-sft-qwen-2.5-0.5b-instruct-sp2-liger \
|
| 29 |
+
trainer.logger=console $@ \
|
| 30 |
+
ulysses_sequence_parallel_size=2 \
|
| 31 |
+
use_remove_padding=true
|
verl/examples/sft/gsm8k/run_seed_oss_36b_sft.sh
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set -x
|
| 2 |
+
|
| 3 |
+
if [ "$#" -lt 2 ]; then
|
| 4 |
+
echo "Usage: run_seed_oss_36b_sft.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 5 |
+
exit 1
|
| 6 |
+
fi
|
| 7 |
+
|
| 8 |
+
nproc_per_node=$1
|
| 9 |
+
save_path=$2
|
| 10 |
+
|
| 11 |
+
# Shift the arguments so $@ refers to the rest
|
| 12 |
+
shift 2
|
| 13 |
+
|
| 14 |
+
torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 15 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 16 |
+
data.train_files=$HOME/data/gsm8k/train.parquet \
|
| 17 |
+
data.val_files=$HOME/data/gsm8k/test.parquet \
|
| 18 |
+
data.prompt_key=extra_info \
|
| 19 |
+
data.response_key=extra_info \
|
| 20 |
+
optim.lr=1e-4 \
|
| 21 |
+
data.prompt_dict_keys=['question'] \
|
| 22 |
+
+data.response_dict_keys=['answer'] \
|
| 23 |
+
data.micro_batch_size=4 \
|
| 24 |
+
model.partial_pretrain=ByteDance-Seed/Seed-OSS-36B-Base \
|
| 25 |
+
trainer.default_local_dir=$save_path \
|
| 26 |
+
trainer.project_name=gsm8k-sft \
|
| 27 |
+
trainer.experiment_name=gsm8k-sft-seed-oss-36b \
|
| 28 |
+
trainer.logger=console \
|
| 29 |
+
trainer.total_training_steps=1 \
|
| 30 |
+
ulysses_sequence_parallel_size=2 \
|
| 31 |
+
use_remove_padding=true $@
|
verl/examples/sft/multiturn/run_qwen_05_sp2.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -x
|
| 3 |
+
|
| 4 |
+
if [ "$#" -lt 2 ]; then
|
| 5 |
+
echo "Usage: run_qwen_05_sp2.sh <nproc_per_node> <save_path> [other_configs...]"
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
nproc_per_node=$1
|
| 10 |
+
save_path=$2
|
| 11 |
+
|
| 12 |
+
# Shift the arguments so $@ refers to the rest
|
| 13 |
+
shift 2
|
| 14 |
+
|
| 15 |
+
torchrun --nnodes=1 --nproc_per_node=$nproc_per_node \
|
| 16 |
+
-m verl.trainer.fsdp_sft_trainer \
|
| 17 |
+
data.train_files=$HOME/data/multiturn/train.parquet \
|
| 18 |
+
data.val_files=$HOME/data/multiturn/test.parquet \
|
| 19 |
+
data.multiturn.enable=true \
|
| 20 |
+
data.multiturn.messages_key=messages \
|
| 21 |
+
data.micro_batch_size=4 \
|
| 22 |
+
model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \
|
| 23 |
+
trainer.default_local_dir=$save_path \
|
| 24 |
+
trainer.project_name=multiturn-sft \
|
| 25 |
+
trainer.experiment_name=multiturn-sft-qwen-2.5-0.5b-instruct-sp2 \
|
| 26 |
+
trainer.logger=console \
|
| 27 |
+
trainer.total_training_steps=1 $@ \
|
| 28 |
+
ulysses_sequence_parallel_size=2 \
|
| 29 |
+
use_remove_padding=true
|