set -x

export NCCL_P2P_DISABLE=1

TEACHER_MODEL=/model/liziheng/hf-models/Qwen3-1.7B
#TEACHER_MODEL=/data/liziheng/checkpoints/verl/verl_grpo_math_qwen3/qwen3_1.7b_bs256_n8/global_step_150/actor
#TEACHER_MODEL=/model/liziheng/hf-models/DeepSeek-R1-Distill-Qwen-7B

python3 -m verl.trainer.main_ppo \
    algorithm.adv_estimator=grpo \
    data.train_files=./data/math345/train.parquet \
    data.val_files=./data/math345/test.parquet \
    data.train_batch_size=256 \
    data.max_prompt_length=1024 \
    data.max_response_length=2048 \
    data.filter_overlong_prompts=True \
    data.truncation='error' \
    +data.apply_template=False \
    actor_rollout_ref.model.path=/model/liziheng/hf-models/Qwen2.5-1.5B \
    actor_rollout_ref.model.use_liger=True \
    actor_rollout_ref.actor.optim.lr=1e-6 \
    actor_rollout_ref.model.use_remove_padding=True \
    actor_rollout_ref.actor.strategy=fsdp2 \
    actor_rollout_ref.actor.ppo_mini_batch_size=16 \
    actor_rollout_ref.actor.use_dynamic_bsz=True \
    actor_rollout_ref.actor.ppo_max_token_len_per_gpu=4096 \
    actor_rollout_ref.actor.use_kl_loss=True \
    actor_rollout_ref.actor.kl_loss_coef=0.01 \
    actor_rollout_ref.actor.kl_loss_type=low_var_kl \
    actor_rollout_ref.actor.sft_loss_coef=0 \
    actor_rollout_ref.actor.adaptive_kl_loss=False \
    actor_rollout_ref.actor.entropy_coeff=0 \
    actor_rollout_ref.model.enable_gradient_checkpointing=True \
    actor_rollout_ref.actor.fsdp_config.param_offload=False \
    actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
    actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
    actor_rollout_ref.rollout.name=vllm \
    actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
    actor_rollout_ref.rollout.n=8 \
    actor_rollout_ref.ref.fsdp_config.param_offload=True \
    +actor_rollout_ref.ref.model_path=$TEACHER_MODEL \
    algorithm.use_kl_in_reward=False \
    custom_reward_function.path=./verl/utils/reward_score/math_span.py \
    custom_val_reward_function.path=./verl/utils/reward_score/math_span.py \
    trainer.critic_warmup=0 \
    trainer.logger=['console','wandb'] \
    trainer.project_name='verl_grpo_math345' \
    trainer.experiment_name='math345_qwen2.5_1.5b_bs256_n8_distill_qwen3_1.7b_rkl1e-2' \
    trainer.n_gpus_per_node=8 \
    trainer.nnodes=1 \
    trainer.save_freq=25 \
    trainer.test_freq=5 \
    trainer.total_training_steps=500 $@

#actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
#actor_rollout_ref.model.path=/model/liziheng/hf-models/Qwen2.5-1.5B-Instruct \
