vllm: [Bug]: llava inference result is wrong !
Your current environment
Collecting environment information...
PyTorch version: 2.1.2+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31
Python version: 3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-91-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 12.2.91
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A100-SXM4-80GB
Nvidia driver version: 535.129.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.0.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
架构: x86_64
CPU 运行模式: 32-bit, 64-bit
字节序: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU: 80
在线 CPU 列表: 0-79
每个核的线程数: 2
每个座的核数: 20
座: 2
NUMA 节点: 2
厂商 ID: GenuineIntel
CPU 系列: 6
型号: 85
型号名称: Intel(R) Xeon(R) Gold 6133 CPU @ 2.50GHz
步进: 4
CPU MHz: 1068.607
CPU 最大 MHz: 3000.0000
CPU 最小 MHz: 1000.0000
BogoMIPS: 5000.00
虚拟化: VT-x
L1d 缓存: 1.3 MiB
L1i 缓存: 1.3 MiB
L2 缓存: 40 MiB
L3 缓存: 55 MiB
NUMA 节点0 CPU: 0-19,40-59
NUMA 节点1 CPU: 20-39,60-79
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable
标记: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear flush_l1d arch_capabilities
Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] nvidia-nccl-cu12==2.18.1
[pip3] torch==2.1.2
[pip3] torchvision==0.16.2
[pip3] triton==2.1.0
[conda] numpy 1.26.3 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.18.1 pypi_0 pypi
[conda] torch 2.1.2 pypi_0 pypi
[conda] torchvision 0.16.2 pypi_0 pypi
[conda] triton 2.1.0 pypi_0 pypiROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: N/A
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X 20-39,60-79 1 N/A
Legend:
X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks
🐛 Describe the bug
I fine-tuned the llava-v1.5-7b model and saved it in the llava-1.5-7b-hf format (https://huggingface.co/llava-hf/llava-1.5-7b-hf). I compared the inference results of three different methods. One is using the original llava project code for inference, the second is using LlavaForConditionalGeneration from Hugging Face for inference, and the third is using vllm for inference. The results are as follows. Clearly, the inference results of the first two methods are correct, while the inference result of vllm is incorrect. Why does this happen? Hugging Face and vllm use the same model checkpoint ! Furthermore, I compared the weight values inside llava-v1.5-7b and llava-v1.5-7b-hf, and found that the values are identical.
result
1.original llava project inference result: The image depicts a whimsical and colorful scene, likely a part of a themed restaurant or store. The main focus is a large, white cat statue with a blue bow, which appears to be a mascot or decorative figure. The cat is positioned in front of a wooden door, which is part of a larger, castle-like structure. This structure is adorned with various mushroom-shaped decorations, adding to the fantasy theme.\n\nIn the background, there are several other mushroom-shaped decorations, some of which are hanging from the ceiling. The overall atmosphere of the scene is playful and imaginative, likely designed to attract the attention of children and adults alike. The presence of the cat statue and the castle-like structure suggests that this location could be a themed restaurant or a store that sells items related to fantasy or children’s entertainment
2.huggeningface LlavaForConditionalGeneration inference result :
desc the image in detail
ASSISTANT: The image is a detailed depiction of a whimsical, fantasy-themed restaurant. The entrance is adorned with a large, cartoonish cat statue, which is a playful and eye-catching feature. The restaurant’s interior is designed to evoke a sense of adventure and fantasy, with elements such as a castle-like structure, a mushroom, and a dragon. The use of vibrant colors and whimsical decorations creates a lively and engaging atmosphere for guests. The presence of a menu suggests that the restaurant serves food, and the overall design indicates that it is a themed dining establishment, likely catering to families and those seeking a fun and imaginative dining experience.
3.vllm llava inference result: The image depicts a lively street scene in a European city. The street is bustling with activity, featuring a diverse group of people engaged in various activities. Some individuals are walking, while others are interacting with each other. The presence of street vendors and the variety of shops along the street contribute to the vibrant atmosphere.
The architecture of the buildings is distinctly European, with a mix of modern and traditional styles. The street is well-lit, with street lamps and natural light from the sky. The overall scene captures the essence of a busy, culturally rich urban environment.
raw image
code
huggeningface
import requests
from PIL import Image
import torch
from transformers import AutoProcessor, LlavaForConditionalGeneration
import time
# model_id="/media/star/8T/model/gpt/llava/llava-hf/llava-1.5-7b-hf"
model_id="/media/star/disk2/model/llava/finetune/llava_lora_deepspeed_20240512_2220/llava_merged_model_fp16_hf"
prompt = "USER: <image>\ndesc the image in detail \nASSISTANT:"
model = LlavaForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
# use_flash_attention_2=True,
attn_implementation="flash_attention_2"
).to(0)
processor = AutoProcessor.from_pretrained(model_id)
#vllm
import argparse
import os
import subprocess
from PIL import Image
import torch
from PIL import Image
from vllm import LLM
from vllm.sequence import MultiModalData
from vllm import SamplingParams
# model_path="/media/star/8T/model/gpt/llava/llava-hf/llava-1.5-7b-hf"
model_path="/media/star/disk2/model/llava/finetune/llava_lora_deepspeed_20240512_2220/llava_merged_model_fp16_hf"
llm = LLM(
model= model_path,
image_input_type="pixel_values",
image_token_id=32000,
image_input_shape="1,3,336,336",
image_feature_size=576,
gpu_memory_utilization=0.3,
swap_space=8
)
from transformers import CLIPVisionModel, CLIPImageProcessor, CLIPVisionConfig
image_processor= CLIPImageProcessor.from_pretrained("/media/star/8T/model/clip/openai_clip/clip-vit-large-patch14-336")
image_path="/media/star/8T/tmp/gpt4v/1/8.png"
image_data = Image.open(image_path).convert("RGB")
image_tensor = image_processor.preprocess(image_data, return_tensors='pt')['pixel_values'].half().to("cuda")
print(image_tensor.shape)
question="desc the image in detail "
prompt = "<image>" * 576 + (
f"\n USER: desc the image in detail \nASSISTANT:")
sampling_params = SamplingParams(temperature=1, top_p=0.01,max_tokens=1024)
RequestOutput = llm.generate(prompt,sampling_params,
multi_modal_data=MultiModalData(
type=MultiModalData.Type.IMAGE, data=image_tensor))
print(RequestOutput[0].outputs[0].text)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (13 by maintainers)
Glad to help!