Qwen2-VL-72B-Instruct-quantized-w4a16

Model Overview

  • Model Architecture: Qwen/Qwen2-VL-72B-Instruct
    • Input: Vision-Text
    • Output: Text
  • Model Optimizations:
    • Weight quantization: FP8
    • Activation quantization: FP8
  • Release Date: 2/24/2025
  • Version: 1.0
  • Model Developers: Neural Magic

Quantized version of Qwen/Qwen2-VL-72B-Instruct.

Model Optimizations

This model was obtained by quantizing the weights of Qwen/Qwen2-VL-72B-Instruct to FP8 data type, ready for inference with vLLM >= 0.5.2.

Deployment

Use with vLLM

This model can be deployed efficiently using the vLLM backend, as shown in the example below.

from vllm.assets.image import ImageAsset
from vllm import LLM, SamplingParams

# prepare model
llm = LLM(
    model="neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16",
    trust_remote_code=True,
    max_model_len=4096,
    max_num_seqs=2,
)

# prepare inputs
question = "What is the content of this image?"
inputs = {
    "prompt": f"<|user|>\n<|image_1|>\n{question}<|end|>\n<|assistant|>\n",
    "multi_modal_data": {
        "image": ImageAsset("cherry_blossom").pil_image.convert("RGB")
    },
}

# generate response
print("========== SAMPLE GENERATION ==============")
outputs = llm.generate(inputs, SamplingParams(temperature=0.2, max_tokens=64))
print(f"PROMPT  : {outputs[0].prompt}")
print(f"RESPONSE: {outputs[0].outputs[0].text}")
print("==========================================")

vLLM also supports OpenAI-compatible serving. See the documentation for more details.

Creation

This model was created with llm-compressor by running the code snippet below as part a multimodal announcement blog.

Model Creation Code
from transformers import AutoProcessor, Qwen2VLForConditionalGeneration

from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.transformers import oneshot, wrap_hf_model_class

MODEL_ID = "Qwen/Qwen2-VL-72B-Instruct"

# Load model.
model_class = wrap_hf_model_class(Qwen2VLForConditionalGeneration)
model = model_class.from_pretrained(MODEL_ID, device_map="auto", torch_dtype="auto")
processor = AutoProcessor.from_pretrained(MODEL_ID)

# Configure the quantization algorithm and scheme.
# In this case, we:
#   * quantize the weights to fp8 with per channel via ptq
#   * quantize the activations to fp8 with dynamic per token
recipe = QuantizationModifier(
    targets="Linear",
    scheme="FP8_DYNAMIC",
    ignore=["re:.*lm_head", "re:visual.*"],
)

# Apply quantization and save to disk in compressed-tensors format.
SAVE_DIR = MODEL_ID.split("/")[1] + "-FP8-dynamic"
oneshot(model=model, recipe=recipe, output_dir=SAVE_DIR)
processor.save_pretrained(SAVE_DIR)

# Confirm generations of the quantized model look sane.
print("========== SAMPLE GENERATION ==============")
input_ids = processor(text="Hello my name is", return_tensors="pt").input_ids.to("cuda")
output = model.generate(input_ids, max_new_tokens=20)
print(processor.decode(output[0]))
print("==========================================")

Evaluation

The model was evaluated using mistral-evals for vision-related tasks and using lm_evaluation_harness for select text-based benchmarks. The evaluations were conducted using the following commands:

Evaluation Commands

Vision Tasks

  • vqav2
  • docvqa
  • mathvista
  • mmmu
  • chartqa
vllm serve neuralmagic/pixtral-12b-quantized.w8a8 --tensor_parallel_size 1 --max_model_len 25000 --trust_remote_code --max_num_seqs 8 --gpu_memory_utilization 0.9 --dtype float16 --limit_mm_per_prompt image=7

python -m eval.run eval_vllm \
        --model_name neuralmagic/pixtral-12b-quantized.w8a8 \
        --url http://0.0.0.0:8000 \
        --output_dir ~/tmp \
        --eval_name <vision_task_name>

Text-based Tasks

MMLU

lm_eval \
  --model vllm \
  --model_args pretrained="<model_name>",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=<n>,gpu_memory_utilization=0.8,enable_chunked_prefill=True,trust_remote_code=True \
  --tasks mmlu \
  --num_fewshot 5 \
  --batch_size auto \
  --output_path output_dir

MGSM

lm_eval \
  --model vllm \
  --model_args pretrained="<model_name>",dtype=auto,max_model_len=4096,max_gen_toks=2048,max_num_seqs=128,tensor_parallel_size=<n>,gpu_memory_utilization=0.9 \
  --tasks mgsm_cot_native \
  --num_fewshot 0 \
  --batch_size auto \
  --output_path output_dir

Accuracy

Category Metric Qwen/Qwen2-VL-72B-Instruct neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic Recovery (%)
Vision MMMU (val, CoT)
explicit_prompt_relaxed_correctness
62.11 60.67 97.68%
VQAv2 (val)
vqa_match
82.51 82.44 99.91%
DocVQA (val)
anls
95.01 95.10 100.09%
ChartQA (test, CoT)
anywhere_in_answer_relaxed_correctness
83.40 83.68 100.34%
Mathvista (testmini, CoT)
explicit_prompt_relaxed_correctness
66.57 67.07 100.75%
Average Score 77.12 77.39 100.35%
Text MGSM (CoT) 68.60 67.78 98.80%
MMLU (5-shot) 82.70 82.60 99.88%

Inference Performance

This model achieves up to xxx speedup in single-stream deployment and up to xxx speedup in multi-stream asynchronous deployment, depending on hardware and use-case scenario. The following performance benchmarks were conducted with vLLM version 0.7.2, and GuideLLM.

Benchmarking Command ``` guidellm --model neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic --target "http://localhost:8000/v1" --data-type emulated --data prompt_tokens=,generated_tokens=,images=,width=,height= --max seconds 120 --backend aiohttp_server ```

Single-stream performance (measured with vLLM version 0.7.2)

Document Visual Question Answering
1680W x 2240H
64/128
Visual Reasoning
640W x 480H
128/128
Image Captioning
480W x 360H
0/128
Hardware Number of GPUs Model Average Cost Reduction Latency (s) QPD Latency (s)th> QPD Latency (s) QPD
A100 4 Qwen/Qwen2-VL-72B-Instruct 6.5 77 4.6 110 4.4 113
2 neuralmagic/Qwen2-VL-72B-Instruct-quantized.w8a8 1.85 7.2 139 4.9 206 4.8 211
1 neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 3.32 10.0 202 5.0 398 4.8 419
H100 4 Qwen/Qwen2-VL-72B-Instruct 4.4 66 3.0 97 2.9 99
2 neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic 1.79 4.7 119 3.3 173 3.2 177
1 neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 2.60 6.4 172 4.3 253 4.2 259

**Use case profiles: Image Size (WxH) / prompt tokens / generation tokens

**QPD: Queries per dollar, based on on-demand cost at Lambda Labs (observed on 2/18/2025).

Multi-stream asynchronous performance (measured with vLLM version 0.7.2)

Document Visual Question Answering
1680W x 2240H
64/128
Visual Reasoning
640W x 480H
128/128
Image Captioning
480W x 360H
0/128
Hardware Model Average Cost Reduction Maximum throughput (QPS) QPD Maximum throughput (QPS) QPD Maximum throughput (QPS) QPD
A100x4 Qwen/Qwen2-VL-72B-Instruct 0.3 169 1.1 538 1.2 595
neuralmagic/Qwen2-VL-72B-Instruct-quantized.w8a8 1.84 1.2 586 4.0 2042 4.6 2270
neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 2.73 2.4 1256 12.8 6364 16.0 8076
H100x4 Qwen/Qwen2-VL-72B-Instruct 0.5 137 1.2 356 1.3 377
neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic 1.70 1.6 457 4.4 1207 4.8 1296
neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 2.35 5.2 1400 13.2 3640 14.4 3976

**Use case profiles: Image Size (WxH) / prompt tokens / generation tokens

**QPS: Queries per second.

**QPD: Queries per dollar, based on on-demand cost at Lambda Labs (observed on 2/18/2025).

Downloads last month
934
Safetensors
Model size
73.4B params
Tensor type
BF16
·
F8_E4M3
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.

Model tree for nm-testing/Qwen2-VL-72B-Instruct-FP8-dynamic

Base model

Qwen/Qwen2-VL-72B
Quantized
(19)
this model