Views
No views yet
1from vllm.assets.image import ImageAsset
2from vllm import LLM, SamplingParams
3
4# prepare model
5llm = LLM(
6 model="neuralmagic/Qwen2.5-VL-72B-Instruct-FP8-Dynamic",
7 trust_remote_code=True,
8 max_model_len=4096,
9 max_num_seqs=2,
10)
11
12# prepare inputs
13question = "What is the content of this image?"
14inputs = {
15 "prompt": f"<|user|>\n<|image_1|>\n{question}<|end|>\n<|assistant|>\n",
16 "multi_modal_data": {
17 "image": ImageAsset("cherry_blossom").pil_image.convert("RGB")
18 },
19}
20
21# generate response
22print("========== SAMPLE GENERATION ==============")
23outputs = llm.generate(inputs, SamplingParams(temperature=0.2, max_tokens=64))
24print(f"PROMPT : {outputs[0].prompt}")
25print(f"RESPONSE: {outputs[0].outputs[0].text}")
26print("==========================================")1import requests
2import torch
3from PIL import Image
4from transformers import AutoProcessor
5from llmcompressor.transformers import oneshot
6from llmcompressor.transformers.tracing import (
7 TraceableQwen2_5_VLForConditionalGeneration,
8)
9from llmcompressor.modifiers.quantization import QuantizationModifier
10
11# Load model.
12model_id = Qwen/Qwen2.5-VL-72B-Instruct
13model = TraceableQwen2_5_VLForConditionalGeneration.from_pretrained(
14 model_id, device_map="auto", torch_dtype="auto"
15)
16processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
17
18# Recipe
19recipe = [
20 QuantizationModifier(
21 targets="Linear",
22 scheme="FP8_DYNAMIC",
23 sequential_targets=["MistralDecoderLayer"],
24 ignore=["re:.*lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
25 ),
26]
27
28SAVE_DIR=f"{model_id.split('/')[1]}-FP8-Dynamic"
29
30# Perform oneshot
31oneshot(
32 model=model,
33 recipe=recipe,
34 trust_remote_code_model=True,
35 output_dir=SAVE_DIR
36)
37
38vllm 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>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
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 \
--apply_chat_template \
--num_fewshot 0 \
--batch_size auto \
--output_path output_dir
| Category | Metric | Qwen/Qwen2.5-VL-72B-Instruct | neuralmagic/Qwen2.5-VL-72B-Instruct-FP8-Dynamic | Recovery (%) |
|---|---|---|---|---|
| Vision | MMMU (val, CoT) explicit_prompt_relaxed_correctness | 64.33 | 66.88 | 103.96% |
| VQAv2 (val) vqa_match | 81.94 | 81.94 | 100.00% | |
| DocVQA (val) anls | 94.71 | 94.64 | 99.93% | |
| ChartQA (test, CoT) anywhere_in_answer_relaxed_correctness | 88.96 | 89.04 | 100.09% | |
| Mathvista (testmini, CoT) explicit_prompt_relaxed_correctness | 78.18 | 77.78 | 99.49% | |
| Average Score | 81.62 | 81.86 | 100.29% | |
| Text | MGSM (CoT) | 75.45 | 75.29 | 99.79% |
| MMLU (5-shot) | 86.16 | 86.12 | 99.95% |
| 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) | Queries Per Dollar | Latency (s)th> | Queries Per Dollar | Latency (s) | Queries Per Dollar |
| A100 | 4 | Qwen/Qwen2.5-VL-72B-Instruct | 6.4 | 78 | 4.5 | 111 | 4.4 | 113 | |
| 2 | neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w8a8 | 1.85 | 7.0 | 143 | 4.9 | 205 | 4.8 | 211 | |
| 1 | neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w4a16 | 3.33 | 9.4 | 213 | 5.1 | 396 | 4.8 | 420 | |
| H100 | 4 | Qwen/Qwen2.5-VL-72B-Instruct | 4.3 | 68 | 3.0 | 97 | 2.9 | 100 | |
| 2 | neuralmagic/Qwen2.5-VL-72B-Instruct-FP8-Dynamic | 1.79 | 4.6 | 122 | 3.3 | 173 | 3.2 | 177 | |
| 1 | neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w4a16 | 5.66 | 4.3 | 252 | 4.4 | 251 | 4.2 | 259 |
| 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) | Queries Per Dollar | Maximum throughput (QPS) | Queries Per Dollar | Maximum throughput (QPS) | Queries Per Dollar |
| A100x4 | Qwen/Qwen2.5-VL-72B-Instruct | 0.4 | 180 | 1.1 | 539 | 1.2 | 595 | |
| neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w8a8 | 1.80 | 0.6 | 289 | 2.0 | 1020 | 2.3 | 1133 | |
| neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w4a16 | 2.75 | 0.7 | 341 | 3.2 | 1588 | 4.1 | 2037 | |
| H100x4 | Qwen/Qwen2.5-VL-72B-Instruct | 0.5 | 134 | 1.2 | 357 | 1.3 | 379 | |
| neuralmagic/Qwen2.5-VL-72B-Instruct-FP8-Dynamic | 1.73 | 0.9 | 247 | 2.2 | 621 | 2.4 | 669 | |
| neuralmagic/Qwen2.5-VL-72B-Instruct-quantized.w4a16 | 8.27 | 3.3 | 913 | 3.3 | 898 | 3.6 | 991 |