同样的数据、环境,参数设定。速度相比 LLama factory 慢很多
这是 LLama factory训练的耗时:
`CUDA_VISIBLE_DEVICES=1,2,3 torchrun --nnodes 1 --nproc_per_node 3 --master_port=25267 src/train.py
--deepspeed /llm/wjw/LLaMA-Factory-main/ds_zero2_no_offload.json
--stage sft
--model_name_or_path /llm/pretrain_models/Qwen/Qwen3-VL-4B-Instruct
--do_train
--dataset vlm_1216
--finetuning_type lora
--output_dir checkpoints/Qwen3-VL-4B-Instruct-12-16
--overwrite_cache
--per_device_train_batch_size 1
--gradient_accumulation_steps 8
--lr_scheduler_type cosine
--logging_steps 10
--save_steps 300
--learning_rate 5e-6
--num_train_epochs 3.0
--cutoff_len 4096
--bf16 true
--use_dora false
--plot_loss
--lora_rank 8
--lora_alpha 16
--lora_dropout 0.1
--lora_target all
--template qwen3_vl_nothink
--flash_attn auto
--loraplus_lr_ratio 16.0
--preprocessing_num_workers 60
--overwrite_output_dir
--val_size 0.05
--per_device_eval_batch_size 1
--eval_strategy steps
--eval_steps 50
`
这是本项目的训练的耗时
CUDA_VISIBLE_DEVICES=1,2,3 MAX_PIXELS=1605632 swift sft \ --model /llm/pretrain_models/Qwen/Qwen3-VL-4B-Instruct \ --dataset /llm/wjw/LLM_train/LLaMA-Factory/data/vlm_1216.json \ --train_type lora \ --lorap_lr_ratio 10 \ --freeze_vit false \ --freeze_aligner false \ --freeze_llm false \ --per_device_train_batch_size 1 \ --per_device_eval_batch_size 1 \ --split_dataset_ratio 0.1 \ --output_dir output_dir/ \ --num_train_epochs 3 \ --save_steps 20 \ --eval_steps 20 \ --save_total_limit 2 \ --logging_steps 10 \ --seed 42 \ --learning_rate 5e-5 \ --init_weights true \ --lora_rank 8 \ --lora_alpha 16 \ --adam_beta1 0.9 \ --adam_beta2 0.95 \ --adam_epsilon 1e-08 \ --weight_decay 0.1 \ --gradient_accumulation_steps 16 \ --max_grad_norm 1 \ --lr_scheduler_type cosine \ --warmup_ratio 0.05 \ --warmup_steps 0 \ --gradient_checkpointing false
如上,参数配置几乎一致
https://swift.readthedocs.io/zh-cn/latest/BestPractices/Qwen3-VL-Best-Practice.html
NPROC_PER_NODE=4
我觉得大概率是token长度不一样导致的。llama factory的图像它会自动阉割到一个比较小的分辨率,ms-swift你需要自己设定大小。图像分辨率小的话训练速度会快好几倍。
我已经固定到相同size,1344-768
---原始邮件--- 发件人: @.> 发送时间: 2025年12月22日(周一) 晚上8:32 收件人: @.>; 抄送: @.@.>; 主题: Re: [modelscope/ms-swift] 同样的数据、环境,参数设定。速度相比 LLama factory 慢很多 (Issue #7153)
651961 left a comment (modelscope/ms-swift#7153)
我觉得大概率是token长度不一样导致的。llama factory的图像它会自动阉割到一个比较小的分辨率,ms-swift你需要自己设定大小。图像分辨率小的话训练速度会快好几倍。
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
我单卡24g,我想即便我再加一张卡,他的时间也不会缩短很多。
---原始邮件--- 发件人: @.> 发送时间: 2025年12月22日(周一) 晚上7:54 收件人: @.>; 抄送: @.@.>; 主题: Re: [modelscope/ms-swift] 同样的数据、环境,参数设定。速度相比 LLama factory 慢很多 (Issue #7153)
Jintao-Huang left a comment (modelscope/ms-swift#7153)
NPROC_PER_NODE=4
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
没有设NPROC_PER_NODE 单模型在跑
那如果不是分辨率的问题,那可能真的是你在单个GPU训练,你没设NPROC_PER_NODE,这个参数决定有几个GPU训练。可以在训练脚本开头加个NPROC_PER_NODE=3。@OKC13
NPROC_PER_NODE=3 \
CUDA_VISIBLE_DEVICES=1,2,3 \
MAX_PIXELS=1605632 \
swift sft \
--model /llm/pretrain_models/Qwen/Qwen3-VL-4B-Instruct \
--dataset /llm/wjw/LLM_train/LLaMA-Factory/data/vlm_1216.json \
--train_type lora \
--lorap_lr_ratio 10 \
--freeze_vit false \
--freeze_aligner false \
--freeze_llm false \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--split_dataset_ratio 0.1 \
--output_dir output_dir/ \
--num_train_epochs 3 \
--save_steps 20 \
--eval_steps 20 \
--save_total_limit 2 \
--logging_steps 10 \
--seed 42 \
--learning_rate 5e-5 \
--init_weights true \
--lora_rank 8 \
--lora_alpha 16 \
--adam_beta1 0.9 \
--adam_beta2 0.95 \
--adam_epsilon 1e-08 \
--weight_decay 0.1 \
--gradient_accumulation_steps 16 \
--max_grad_norm 1 \
--lr_scheduler_type cosine \
--warmup_ratio 0.05 \
--warmup_steps 0 \
--gradient_checkpointing false
非常感谢,已解决。最新脚本分享给大家:
CUDA_VISIBLE_DEVICES=1,2,3 NPROC_PER_NODE=3 MAX_PIXELS=451584 swift sft
--model /llm/pretrain_models/Qwen/Qwen3-VL-4B-Instruct
--dataset /llm/wjw/LLM_train/LLaMA-Factory/data/vlm_1216.json
--train_type lora
--lorap_lr_ratio 10
--freeze_vit false
--freeze_aligner false
--freeze_llm false
--per_device_train_batch_size 2
--per_device_eval_batch_size 1
--split_dataset_ratio 0.05
--output_dir output_dir/
--num_train_epochs 3
--save_steps 100
--eval_steps 100
--save_total_limit 2
--logging_steps 10
--seed 42
--learning_rate 5e-5
--init_weights true
--lora_rank 8
--lora_alpha 16
--adam_beta1 0.9
--adam_beta2 0.95
--adam_epsilon 1e-08
--weight_decay 0.1
--gradient_accumulation_steps 8
--max_grad_norm 1
--lr_scheduler_type cosine
--warmup_ratio 0.05
--warmup_steps 0
--report_to swanlab
--deepspeed zero2
--padding_free true
--attn_impl flash_attention_2
--gradient_checkpointing true