set -x

# 指定使用的GPU为0-7(共8卡)
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
# RTX 4000 系列显卡的硬件或驱动限制,不支持通过 P2P(Peer-to-Peer)或 IB(InfiniBand)进行 GPU 间的高速直接通信。
export NCCL_P2P_DISABLE=1
export NCCL_IB_DISABLE=1

# 权重打包缓存目录
export packing_cache=/swift/cache

# 单机8卡配置
nproc_per_node=8
model_path=/models/Qwen3-0.6B
dataset_path=swift/data
savedir=/swift/output/0809

dataset_name=$(basename "$dataset_path" .jsonl)

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

# 单机8卡启动训练(移除了多节点的--hostfile参数)
deepspeed --num_gpus=$nproc_per_node \
     $PACKAGE_PATH/cli/sft.py \
        --model $model_path \
        --dataset $dataset_path \
        --split_dataset_ratio 0 \
        --dataset_num_proc 20 \
        --loss_scale last_round_with_ignore_empty_think \
        --train_type full \
        --torch_dtype bfloat16 \
        --num_train_epochs 3 \
        --per_device_train_batch_size 1 \
        --learning_rate 1e-5 \
        --lr_scheduler_type 'cosine_with_min_lr' \
        --lr_scheduler_kwargs "{\"min_lr\": 1e-7}" \
        --gradient_accumulation_steps 3 \
        --save_steps 200 \
        --save_total_limit 5 \
        --save_only_model true \
        --logging_steps 5 \
        --max_length 32000 \
        --output_dir $savedir \
        --warmup_ratio 0.05 \
        --dataloader_num_workers 8 \
        --deepspeed zero2 \
        --sequence_parallel_size $nproc_per_node \
        --packing true \
        --use_liger_kernel false \
        --attn_impl flash_attn 2>&1| tee $savedir/log0_6b_test

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

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐