export NCCL_P2P_DISABLE=1 # 40系列
export NCCL_IB_DISABLE=1

NPROC_PER_NODE=8 \
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \

DATA_PATH=./data/dpo_train.jsonl \
MODEL_PATH="/sft/output/multi_Qwen3-0.6B" \

# 获取swift包路径
PACKAGE_PATH=$(python -c "import swift; print(swift.__path__[0])")

deepspeed --num_gpus=$NPROC_PER_NODE \
    $PACKAGE_PATH/cli/rlhf.py \
    --rlhf_type dpo \
    --model $MODEL_PATH \
    --model_type qwen3 \
    --train_type full \
    --dataset $DATA_PATH \
    --torch_dtype bfloat16 \
    --num_train_epochs 3 \
    --per_device_train_batch_size 3 \
    --learning_rate 1e-5 \
    --lr_scheduler_type 'cosine_with_min_lr' \
    --lr_scheduler_kwargs "{\"min_lr\": 1e-7}" \
    --gradient_accumulation_steps 1 \
    --save_steps 500 \
    --save_total_limit 5 \
    --logging_steps 5 \
    --max_length 16000 \
    --output_dir output \
    --warmup_ratio 0.05 \
    --save_only_model true \
    --dataloader_num_workers 8 \
    --dataset_num_proc 4 \
    --deepspeed zero3 \
    --attn_impl flash_attn \
    --rpo_alpha 0.1 \
    --padding_free true

ms-swift框架中文文档:Swift DOCUMENTATION — swift 3.8.0.dev0 文档

更多推荐