AutoModelForImageTextToText.from_pretrained
Load a Qwen3-VL model from a pretrained checkpoint using the Transformers library.Parameters
string
required
Model identifier from Hugging Face Hub or local path to model directory.Examples:
"Qwen/Qwen3-VL-235B-A22B-Instruct""Qwen/Qwen3-VL-30B-A3B-Instruct""Qwen/Qwen3-VL-32B-Instruct""Qwen/Qwen3-VL-8B-Instruct""Qwen/Qwen3-VL-4B-Instruct""Qwen/Qwen3-VL-2B-Instruct"
string | torch.dtype
default:"auto"
Data type for model weights. Controls precision and memory usage.Options:
"auto"- Automatically select optimal dtypetorch.bfloat16- Brain floating point 16-bit (recommended)torch.float16- Half precision floating pointtorch.float32- Full precision floating point
string | dict
default:"auto"
Device allocation strategy for model layers. Enables multi-GPU and CPU offloading.Options:
"auto"- Automatically distribute across available devices"cuda"- Load entire model on single GPU"cpu"- Load model on CPU- Custom dict mapping layers to devices
string
Attention mechanism implementation. Use Flash Attention 2 for better performance.Options:
"flash_attention_2"- Fast and memory-efficient attention (recommended)"eager"- Standard PyTorch attention"sdpa"- Scaled dot-product attention
- Compatible GPU (Ampere, Ada, Hopper architecture)
- dtype must be
torch.float16ortorch.bfloat16 - Install:
pip install -U flash-attn --no-build-isolation
Returns
Returns aQwen3VLForConditionalGeneration model instance ready for inference.
Example Usage
Notes
For multi-image and video scenarios, Flash Attention 2 is strongly recommended for better acceleration and memory efficiency.