verl icon indicating copy to clipboard operation
verl copied to clipboard

Model output collapses into garbled text during GRPO + LoRA + Reward Model training

Open YANGZHOU66666 opened this issue 1 year ago • 2 comments

When training with the GRPO algorithm, LoRA enabled (lora_rank > 0), and a reward model, the model's generated output becomes completely meaningless garbled text (also known as '乱码' in Chinese) after the first few training steps. This issue does not occur during full fine-tuning (lora_rank=0) even when using the exact same reward model and other parameters. Attempts to resolve this by adjusting the actor's learning rate (testing values from 1e-6 to 5e-5) or the actor's lora rank (testing values from 16 to 64) have been unsuccessful.

Environment

OS: Ubuntu 22.04 on AutoDL

VeRL Version: 0e15c9b11c4b3f230fbc7ce75548d589635744d1

Python Version: 3.10.18

PyTorch Version: 2.6.0

CUDA Version: 12.8

Steps to Reproduce

  1. Environment Setup:
  • Install verl and its dependencies in a Conda environment.
  • Download the base model for the Actor/Critic/Reference: Qwen/Qwen2.5-0.5B-Instruct
  • Download the Reward Model: Skywork/Skywork-Reward-V2-Qwen3-0.6B
  • Prepare the GSM8K dataset using the provided preprocessing scripts.
  1. About the command
PYTHONUNBUFFERED=1 python3 -m verl.trainer.main_ppo \
 data.train_files=$HOME/data/gsm8k/train.parquet \
 data.val_files=$HOME/data/gsm8k/test.parquet \
 data.train_batch_size=256 \
 data.max_prompt_length=512 \
 data.max_response_length=256 \
 data.return_raw_chat=True \
 actor_rollout_ref.model.path=/root/autodl-tmp/Qwen2.5-0.5B-Instruct \
 actor_rollout_ref.model.lora_rank=16 \
 actor_rollout_ref.model.lora_alpha=32 \
 actor_rollout_ref.model.target_modules=all-linear \
 actor_rollout_ref.actor.optim.lr=1e-6 \
 actor_rollout_ref.actor.ppo_mini_batch_size=64 \
 actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
 actor_rollout_ref.actor.use_kl_loss=True \
 actor_rollout_ref.rollout.name=vllm \
 actor_rollout_ref.rollout.n=4 \
 actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
 actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
 actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
 critic.optim.lr=1e-5 \
 critic.model.path=/root/autodl-tmp/Qwen2.5-0.5B-Instruct \
 critic.ppo_micro_batch_size_per_gpu=4 \
 algorithm.adv_estimator=grpo \
 algorithm.kl_ctrl.kl_coef=0.001 \
 trainer.logger=[console,wandb] \
 trainer.val_before_train=False \
 trainer.n_gpus_per_node=2 \
 trainer.nnodes=1 \
 trainer.save_freq=10 \
 trainer.test_freq=10 \
 trainer.total_epochs=15 \
 reward_model.enable=True \
 reward_model.model.path=/root/autodl-tmp/Skywork-Reward-V2-Qwen3-0.6B \
 reward_model.micro_batch_size_per_gpu=8 \
 2>&1 | tee verl_grpo_rm_lora_2gpu_demo.log
  1. About the results

Before the model's first updating, it generated a correct output:

Image

However, after a batch, the model generated garbled text:

Image

If I do not use lora with other parameters the same, this problem will not appear:

PYTHONUNBUFFERED=1 python3 -m verl.trainer.main_ppo \
 data.train_files=$HOME/data/gsm8k/train.parquet \
 data.val_files=$HOME/data/gsm8k/test.parquet \
 data.train_batch_size=256 \
 data.max_prompt_length=512 \
 data.max_response_length=256 \
 data.return_raw_chat=True \
 actor_rollout_ref.model.path=/root/autodl-tmp/Qwen2.5-0.5B-Instruct \
 actor_rollout_ref.actor.optim.lr=1e-6 \
 actor_rollout_ref.actor.ppo_mini_batch_size=64 \
 actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
 actor_rollout_ref.actor.use_kl_loss=True \
 actor_rollout_ref.rollout.name=vllm \
 actor_rollout_ref.rollout.n=4 \
 actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
 actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
 actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
 critic.optim.lr=1e-5 \
 critic.model.path=/root/autodl-tmp/Qwen2.5-0.5B-Instruct \
 critic.ppo_micro_batch_size_per_gpu=4 \
 algorithm.adv_estimator=grpo \
 algorithm.kl_ctrl.kl_coef=0.001 \
 trainer.logger=[console,wandb] \
 trainer.val_before_train=False \
 trainer.n_gpus_per_node=2 \
 trainer.nnodes=1 \
 trainer.save_freq=10 \
 trainer.test_freq=10 \
 trainer.total_epochs=15 \
 reward_model.enable=True \
 reward_model.model.path=/root/autodl-tmp/Skywork-Reward-V2-Qwen3-0.6B \
 reward_model.micro_batch_size_per_gpu=8 \
 2>&1 | tee verl_grpo_rm_4gpu_demo.log

YANGZHOU66666 avatar Aug 26 '25 12:08 YANGZHOU66666

Add actor_rollout_ref.rollout.load_format="safetensors" to the script and I guess the problem will disappear.

lvshangke avatar Aug 27 '25 13:08 lvshangke

Add actor_rollout_ref.rollout.load_format="safetensors" to the script and I guess the problem will disappear.

Unfortunately, it seemed this method did not work. However, I tried the solution shared by kfallah at https://github.com/volcengine/verl/issues/3159#issuecomment-3222380324, and it seemed to work.

YANGZHOU66666 avatar Aug 29 '25 08:08 YANGZHOU66666