metadata
tags:
- vllm
- vision
- w4a16
license: apache-2.0
license_link: >-
https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md
language:
- en
base_model: Qwen/Qwen2-VL-72B-Instruct
library_name: transformers
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
Evaluation Commands
Accuracy
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 | Model | Average Cost Reduction | Latency (s) | QPD | Latency (s)th> | QPD | Latency (s) | QPD |
A100x4 | Qwen/Qwen2-VL-72B-Instruct | 6.5 | 77 | 4.6 | 110 | 4.4 | 113 | |
A100x2 | neuralmagic/Qwen2-VL-72B-Instruct-quantized.w8a8 | 1.85 | 7.2 | 139 | 4.9 | 206 | 4.8 | 211 |
A100x1 | neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 | 3.32 | 10.0 | 202 | 5.0 | 398 | 4.8 | 419 |
H100x4 | Qwen/Qwen2-VL-72B-Instruct | 4.4 | 66 | 3.0 | 97 | 2.9 | 99 | |
H100x2 | neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic | 1.79 | 4.7 | 119 | 3.3 | 173 | 3.2 | 177 |
H100x1 | neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 | 2.60 | 6.4 | 172 | 4.3 | 253 | 4.2 | 259 |
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 | |
A100x2 | neuralmagic/Qwen2-VL-72B-Instruct-quantized.w8a8 | 1.84 | 0.6 | 293 | 2.0 | 1021 | 2.3 | 1135 |
A100x1 | neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 | 2.73 | 0.6 | 314 | 3.2 | 1591 | 4.0 | 2019 |
H100x4 | Qwen/Qwen2-VL-72B-Instruct | 0.5 | 137 | 1.2 | 356 | 1.3 | 377 | |
neuralmagic/Qwen2-VL-72B-Instruct-FP8-Dynamic | H100x2 | 1.70 | 0.8 | 236 | 2.2 | 623 | 2.4 | 669 |
neuralmagic/Qwen2-VL-72B-Instruct-quantized.w4a16 | H100x1 | 2.35 | 1.3 | 350 | 3.3 | 910 | 3.6 | 994 |