vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
29.85k stars 4.51k forks source link

[Bug]: AttributeError: 'NoneType' object has no attribute 'prefill_metadata' #5982

Closed lonngxiang closed 4 months ago

lonngxiang commented 4 months ago

Your current environment

The output of `python collect_env.py`

🐛 Describe the bug

run LLaVA-NeXT | llava-hf/llava-v1.6-mistral-7b-hf

python -m vllm.entrypoints.openai.api_server --model /ai/LLaVA-NeXT --image-token-id 32000 --image-input-shape 1,3,336,336 --image-input-type pixel_values --image-feature-size 65856 --chat-template template_llava.jinja --host 19*** --port 10860 --trust-remote-code --tensor-parallel-size 1 --dtype=half --disable-custom-all-reduce

image

DarkLight1337 commented 4 months ago

Please provide more information on your environment by running the command at the beginning of your post (under "Your current environment"). The issue seems to come from having incompatible packages installed so you might want to reset your Python environment.

tboser commented 4 months ago

Please provide more information on your environment by running the command at the beginning of your post (under "Your current environment"). The issue seems to come from having incompatible packages installed so you might want to reset your Python environment.

Hello, I've run into this same issue. Here's the the output of collect_env.py when I run it.

(michaelocr_ai) (dev_tools) [07/03/2024 09:54:17PM] [thomas:~/vllm]$ python collect_env.py
Collecting environment information...
WARNING 07-03 22:01:59 _custom_ops.py:14] Failed to import from vllm._C with ModuleNotFoundError("No module named 'vllm._C'")
PyTorch version: 2.3.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.30.0
Libc version: glibc-2.35

Python version: 3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.5.40
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3080
Nvidia driver version: 546.17
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             16
On-line CPU(s) list:                0-15
Vendor ID:                          GenuineIntel
Model name:                         11th Gen Intel(R) Core(TM) i9-11900KF @ 3.50GHz
CPU family:                         6
Model:                              167
Thread(s) per core:                 2
Core(s) per socket:                 8
Socket(s):                          1
Stepping:                           1
BogoMIPS:                           7007.99
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          384 KiB (8 instances)
L1i cache:                          256 KiB (8 instances)
L2 cache:                           4 MiB (8 instances)
L3 cache:                           16 MiB (1 instance)
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed:             Mitigation; Enhanced 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; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] torchvision==0.16.2
[pip3] transformers==4.42.3
[pip3] triton==2.3.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.0.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X                              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

FWIW, my deps are generated using pip compile with vllm pinned to vllm>=0.5.0.post1 so they should in theory be compatible with vllm. LMK if you see anything wrong/if I can share other outputs to help debug this. Thanks!

DarkLight1337 commented 4 months ago

How did you run vLLM? Can you show the command/code?

tboser commented 4 months ago

How did you run vLLM? Can you show the command/code?

Sure, here's the "model" code. It gets initialized in a webserver from which I want to serve the model:

from typing import Any

from PIL import Image
from vllm import LLM, SamplingParams

from ai.lib.py.models.model import ModelBase

class Llava(ModelBase):
    PROMPT = "[INST] <image>\ label this. [/INST]"

    def __init__(self) -> None:
        model_id = "llava-hf/llava-v1.6-mistral-7b-hf"
        self.llm = LLM(
            model=model_id,
            trust_remote_code=True,
            max_model_len=4096,
            tensor_parallel_size=1,
            image_input_type="pixel_values",
            image_token_id=32000,
            image_input_shape="1,3,640,760",
            image_feature_size=17752,
            dtype='half',
        )
        self.sampling_params = SamplingParams(
            temperature=0.1, top_p=0.95, max_tokens=2048
        )

    def predict(self, input: Any) -> str:
        image = Image.open(input).convert("RGB").resize((640, 760))
        outputs = self.llm.generate(
            {
                "prompt": self.PROMPT,
                "multi_modal_data": {"image": image},
            },
            sampling_params=self.sampling_params,
        )
        for o in outputs:
            generated_text = o.outputs[0].text
            print(generated_text)
        return " ".join([o.outputs[0].text for o in outputs])
DarkLight1337 commented 4 months ago

I got a similar issue recently and it turns out that it's because vLLM cannot allocate blocks for the model. Here, I think you set image_feature_size to a value that is too high (normally it should be around 2k or so, not 60k or 17k).

Anyways, the --image-feature-size argument has since been removed (it is now computed automatically by #6089) so you should not run into this issue anymore.

tboser commented 4 months ago

I got a similar issue recently and it turns out that it's because vLLM cannot allocate blocks for the model. Here, I think you set image_feature_size to a value that is too high (normally it should be around 2k or so, not 60k or 17k).

Anyways, the --image-feature-size argument has since been removed (it is now computed automatically by #6089) so you should not run into this issue anymore.

Yeah I noticed this was removed - I wasn't able to build from source unfortunately so I'm stuck on the older version. Not a huge deal, I can wait for the next pypi release. Appreciate you taking a look, thanks!

DarkLight1337 commented 4 months ago

The next release should be just around the corner! See #5806 for more details.