Skip to main content

Complete Training Script

Here’s the complete training script with full parameter documentation:
launch_training.sh

Parameter Categories

The script accepts arguments in three main categories:

Model Arguments

Training Arguments

Component Training Flags

When training with both image and video data, set --tune_mm_vision False to avoid instability.

Precision & Memory

Learning Rate Configuration

The suggested learning rate range is from 1e-6 to 2e-7. Start with 2e-7 for stable training.

Sequence Configuration

Data Arguments

Dataset Selection

Data Processing

  • data_flatten=True means data in a batch are concatenated into one sequence
  • data_packing=True requires preprocessing with tools/pack_data.py

Image Processing

Video Processing

Training resolution is critical for model performance. Ensure --max_pixels and --min_pixels are properly set for your use case.

Training Schedule

Logging & Checkpoints

Advanced Options

DeepSpeed Configuration

Provide a DeepSpeed configuration file for distributed training optimization.
The Qwen3VL MoE model does not support DeepSpeed with ZeRO-3. Additionally, Hugging Face’s official implementation does not include support for load balancing loss currently.

Flash Attention

To enable Flash Attention 2, add the following to your model’s config.json:
config.json

Hardware Requirements

Training Qwen2.5-VL-3B

Minimum requirements:
  • 4x GPUs with 24GB VRAM (e.g., RTX 3090, RTX 4090)
  • With DeepSpeed ZeRO-3 and gradient checkpointing

Training Qwen2.5-VL-32B

Recommended configuration:
  • 8x 80GB GPUs (e.g., A100, H100)
  • Refer to scripts/sft_32b.sh for configuration

Example Usage

Basic Training

Single GPU Training

Multi-node Training

On the master node:
On worker nodes:

Monitoring Training

Monitor your training progress:

Troubleshooting

Try these solutions:
  1. Reduce --per_device_train_batch_size
  2. Increase --gradient_accumulation_steps
  3. Reduce --model_max_length
  4. Enable gradient checkpointing in DeepSpeed config
  5. Use DeepSpeed ZeRO-3 for larger models
Optimize performance:
  1. Enable Flash Attention 2 in config.json
  2. Use --data_packing True with preprocessed data
  3. Ensure --bf16 is enabled on Ampere+ GPUs
  4. Check if GPU utilization is at 100%
  5. Increase batch size if memory allows
If you see NaN losses or diverging training:
  1. Lower the learning rate (try 1e-7 or 5e-8)
  2. Set --tune_mm_vision False when using mixed image/video data
  3. Increase warmup ratio to 0.05 or 0.1
  4. Check data for corrupted images or invalid annotations
  5. Reduce --max_pixels if processing very large images