Downloads · 30 days
0
onnx-community/Qwen3-4B-VL-ONNX
Qwen3-4B-VL-ONNX is a machine learning model from onnx-community. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Copyright (C) [2026] Advanced Micro Devices, Inc. All rights reserved. Portions of this file consist of AI generated content.
Downloads · 30 days
0
Access
Public
Updated Mar 3, 2026
Repo size
18.1 GB
Likes
1
Public
Click a slice to open those files.
.data8.3 GB · 46%
From the Hugging Face model README
Copyright (C) [2026] Advanced Micro Devices, Inc. All rights reserved. Portions of this file consist of AI generated content.
Convert Qwen3-VL checkpoints to ONNX Runtime GenAI format with dynamic image-size support, then run local multimodal inference.
This README is written in a model-card style so it can be moved into a Hugging Face repo with minimal changes.
qwen3vl-vision.onnx (vision encoder, FP32)qwen3vl-embedding.onnx (image-token embedding injector, FP32)model.onnx (text decoder, fp32/fp16/int4)genai_config.json for ONNX Runtime GenAI multimodal processor(...) flow.image_grid_thw input.Qwen/Qwen3-VL-2B-InstructQwen/Qwen3-VL-4B-InstructQwen/Qwen3-VL-8B-Instructonnxruntime-genai (built from source or installed)transformershuggingface_hubtorchpytorch_reference/modeling_qwen3_vl.py (already in this folder).Run commands from the onnxruntime-genai repo root:
cd examples/python/qwen3-vl
Download the patched modeling_qwen3_vl.py from Hugging Face and place it into
examples/python/qwen3-vl/pytorch_reference.
Also download builder.py and the inference script into examples/python/qwen3-vl:
mkdir ./pytorch_reference
hf download onnx-community/Qwen3-4B-VL-ONNX --include "modeling_qwen3_vl.py" --local-dir "./pytorch_reference"
hf download onnx-community/Qwen3-4B-VL-ONNX --include "builder.py" --local-dir "."
hf download onnx-community/Qwen3-4B-VL-ONNX --include "qwen3vl-oga-inference.py" --local-dir "."
hf download onnx-community/Qwen3-4B-VL-ONNX --include "test_images/*" --local-dir "./test_images"
Use either hf download (recommended) or huggingface-cli download.
hf download Qwen/Qwen3-VL-2B-Instruct --local-dir "./pytorch_2b"
hf download Qwen/Qwen3-VL-4B-Instruct --local-dir "./pytorch_4b"
hf download Qwen/Qwen3-VL-8B-Instruct --local-dir "./pytorch_8b"
& "python.exe" `
"builder.py" `
--input "./pytorch_4b" `
--reference "./pytorch_reference" `
--output "./qwen3-vl-4b-instruct-onnx-vision-fp32-text-fp32-cpu" `
--precision fp32
# 2B
& "python.exe" `
"builder.py" `
--input "./pytorch_2b" `
--reference "./pytorch_reference" `
--output "./qwen3-vl-2b-instruct-onnx-vision-fp32-text-int4-cpu" `
--precision int4
# 4B
& "python.exe" `
"builder.py" `
--input "./pytorch_4b" `
--reference "./pytorch_reference" `
--output "./qwen3-vl-4b-instruct-onnx-vision-fp32-text-int4-cpu" `
--precision int4
# 8B
& "python.exe" `
"builder.py" `
--input "./pytorch_8b" `
--reference "./pytorch_reference" `
--output "./qwen3-vl-8b-instruct-onnx-vision-fp32-text-int4-cpu" `
--precision int4
Run from the same folder:
& "python.exe" `
"qwen3vl-oga-inference.py" `
-m "./qwen3-vl-8b-instruct-onnx-vision-fp32-text-int4-cpu" `
-e follow_config `
--non-interactive `
-pr "Say hello in one short sentence."
Expected behavior: model loads and returns a short greeting (for example, Hello!).
& "python.exe" `
"qwen3vl-oga-inference.py" `
-m "./qwen3-vl-8b-instruct-onnx-vision-fp32-text-int4-cpu" `
-e follow_config `
--non-interactive `
--image_paths "./test_images/img_50.jpg" `
-pr "Describe this image in one sentence."
Expected behavior: model returns a one-sentence description for the image.
RuntimeError: Expected pixel_values in CHW format [C, H, W], got rank 4If you use Qwen3-VL models, please cite the Qwen technical reports and model cards from the Qwen team.
This workflow uses a local reference model file at:
examples/python/qwen3-vl/pytorch_reference/modeling_qwen3_vl.py
The exporter entrypoint is:
examples/python/qwen3-vl/builder.py (not export_for_oga.py)
with --reference ./pytorch_reference to load the patched class dynamically.
modeling_qwen3_vl.py patches for dynamic ONNX exportVision attention tracing path
Qwen3VLVisionAttention.forward: tracing branch bypasses Python split/loop path (lengths.tolist(), torch.split(...), per-chunk iteration) and runs tensor-only attention flow.RoPE tracing path
Qwen3VLVisionModel.rot_pos_emb: tracing branch computes rotary positions with tensor math only and requires token_count.Position embedding tracing fallback
Qwen3VLVisionModel.forward: tracing branch uses tensor-index fallback for positional embeddings instead of interpolation-heavy Python control flow.cu_seqlens dtype split for export/runtime
Qwen3VLVisionModel.forward: cu_seqlens uses grid_thw.dtype during tracing, torch.int32 otherwise.Tracing-safe image feature output
Qwen3VLModel.get_image_features: tracing returns raw tensors and skips torch.split(..., split_sizes.tolist()).Tracing-safe cache behavior
Qwen3VLTextModel.forward: DynamicCache is not created while tracing.Model-size portability in exporter
builder.py embedding export no longer hardcodes hidden width (2560); it uses embed_tokens.embedding_dim, enabling 2B/4B/8B export.These changes keep eager/runtime behavior intact while adding an export-safe tensor-only tracing path for dynamic image_grid_thw.