Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Can't load vision model microsoft/Phi-3.5-vision-instruct #7781

Closed
remiconnesson opened this issue Aug 22, 2024 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@remiconnesson
Copy link

Your current environment

The output of `python collect_env.py`
Collecting environment information...
PyTorch version: 2.4.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 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.2
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.0-35-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 550.78
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:                      43 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             64
On-line CPU(s) list:                0-63
Vendor ID:                          AuthenticAMD
Model name:                         AMD Ryzen Threadripper PRO 3975WX 32-Cores
CPU family:                         23
Model:                              49
Thread(s) per core:                 2
Core(s) per socket:                 32
Socket(s):                          1
Stepping:                           0
Frequency boost:                    enabled
CPU max MHz:                        4368.1641
CPU min MHz:                        2200.0000
BogoMIPS:                           6986.92
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sev sev_es
Virtualization:                     AMD-V
L1d cache:                          1 MiB (32 instances)
L1i cache:                          1 MiB (32 instances)
L2 cache:                           16 MiB (32 instances)
L3 cache:                           128 MiB (8 instances)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-63
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec rstack overflow: Mitigation; Safe RET
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-cupti-cu12==12.1.105
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.0.2.54
[pip3] nvidia-curand-cu12==10.3.2.106
[pip3] nvidia-cusolver-cu12==11.4.5.107
[pip3] nvidia-cusparse-cu12==12.1.0.106
[pip3] nvidia-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] nvidia-nvjitlink-cu12==12.3.101
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] pyzmq==24.0.1
[pip3] torch==2.4.0
[pip3] torchaudio==2.2.0
[pip3] torchvision==0.19.0
[pip3] transformers==4.44.1
[pip3] triton==3.0.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.4@4db5176d9758b720b05460c50ace3c01026eb158
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      0-63    0               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

Reproduction

from vllm import LLM
llm = LLM(
    model="microsoft/Phi-3.5-vision-instruct",
    trust_remote_code=True
)

Bug

ValueError: Attempted to assign 49 x 781 = 38269 image tokens to 129997 placeholders

Full Traceback

A new version of the following files was downloaded from https://huggingface.co/microsoft/Phi-3.5-vision-instruct:
- processing_phi3_v.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/image_processing_auto.py:513: FutureWarning: The image_processor_class argument is deprecated and will be removed in v4.42. Please use `slow_image_processor_class`, or `fast_image_processor_class` instead
  warnings.warn(
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[16], line 2
      1 if 'LLM_LOADED' not in globals():
----> 2     llm = LLM(
      3         model="microsoft/Phi-3.5-vision-instruct",
      4         trust_remote_code=True
      5     )
      6     LLM_LOADED = True

File /usr/local/lib/python3.10/dist-packages/vllm/entrypoints/llm.py:158, in LLM.__init__(self, model, tokenizer, tokenizer_mode, skip_tokenizer_init, trust_remote_code, tensor_parallel_size, dtype, quantization, revision, tokenizer_revision, seed, gpu_memory_utilization, swap_space, cpu_offload_gb, enforce_eager, max_context_len_to_capture, max_seq_len_to_capture, disable_custom_all_reduce, **kwargs)
    135     raise TypeError(
    136         "There is no need to pass vision-related arguments anymore.")
    137 engine_args = EngineArgs(
    138     model=model,
    139     tokenizer=tokenizer,
   (...)
    156     **kwargs,
    157 )
--> 158 self.llm_engine = LLMEngine.from_engine_args(
    159     engine_args, usage_context=UsageContext.LLM_CLASS)
    160 self.request_counter = Counter()

File /usr/local/lib/python3.10/dist-packages/vllm/engine/llm_engine.py:445, in LLMEngine.from_engine_args(cls, engine_args, usage_context, stat_loggers)
    443 executor_class = cls._get_executor_cls(engine_config)
    444 # Create the LLM engine.
--> 445 engine = cls(
    446     **engine_config.to_dict(),
    447     executor_class=executor_class,
    448     log_stats=not engine_args.disable_log_stats,
    449     usage_context=usage_context,
    450     stat_loggers=stat_loggers,
    451 )
    453 return engine

File /usr/local/lib/python3.10/dist-packages/vllm/engine/llm_engine.py:263, in LLMEngine.__init__(self, model_config, cache_config, parallel_config, scheduler_config, device_config, load_config, lora_config, multimodal_config, speculative_config, decoding_config, observability_config, prompt_adapter_config, executor_class, log_stats, usage_context, stat_loggers)
    249 self.model_executor = executor_class(
    250     model_config=model_config,
    251     cache_config=cache_config,
   (...)
    259     prompt_adapter_config=prompt_adapter_config,
    260 )
    262 if not self.model_config.embedding_mode:
--> 263     self._initialize_kv_caches()
    265 # If usage stat is enabled, collect relevant info.
    266 if is_usage_stats_enabled():

File /usr/local/lib/python3.10/dist-packages/vllm/engine/llm_engine.py:362, in LLMEngine._initialize_kv_caches(self)
    355 def _initialize_kv_caches(self) -> None:
    356     """Initialize the KV cache in the worker(s).
    357 
    358     The workers will determine the number of blocks in both the GPU cache
    359     and the swap CPU cache.
    360     """
    361     num_gpu_blocks, num_cpu_blocks = (
--> 362         self.model_executor.determine_num_available_blocks())
    364     if self.cache_config.num_gpu_blocks_override is not None:
    365         num_gpu_blocks_override = self.cache_config.num_gpu_blocks_override

File /usr/local/lib/python3.10/dist-packages/vllm/executor/gpu_executor.py:94, in GPUExecutor.determine_num_available_blocks(self)
     90 def determine_num_available_blocks(self) -> Tuple[int, int]:
     91     """Determine the number of available KV blocks by invoking the
     92     underlying worker.
     93     """
---> 94     return self.driver_worker.determine_num_available_blocks()

File /usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py:116, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    113 @functools.wraps(func)
    114 def decorate_context(*args, **kwargs):
    115     with ctx_factory():
--> 116         return func(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/vllm/worker/worker.py:179, in Worker.determine_num_available_blocks(self)
    175 torch.cuda.empty_cache()
    177 # Execute a forward pass with dummy inputs to profile the memory usage
    178 # of the model.
--> 179 self.model_runner.profile_run()
    181 # Calculate the number of blocks that can be allocated with the
    182 # profiled peak memory.
    183 torch.cuda.synchronize()

File /usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py:116, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    113 @functools.wraps(func)
    114 def decorate_context(*args, **kwargs):
    115     with ctx_factory():
--> 116         return func(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/vllm/worker/model_runner.py:940, in GPUModelRunnerBase.profile_run(self)
    935 if not get_pp_group().is_first_rank:
    936     intermediate_tensors = self.model.make_empty_intermediate_tensors(
    937         batch_size=batch_size,
    938         dtype=self.model_config.dtype,
    939         device=self.device)
--> 940 self.execute_model(model_input, kv_caches, intermediate_tensors)
    941 torch.cuda.synchronize()
    942 return

File /usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py:116, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    113 @functools.wraps(func)
    114 def decorate_context(*args, **kwargs):
    115     with ctx_factory():
--> 116         return func(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/vllm/worker/model_runner.py:1363, in ModelRunner.execute_model(self, model_input, kv_caches, intermediate_tensors, num_steps)
   1358 multi_modal_kwargs = model_input.multi_modal_kwargs or {}
   1359 seqlen_agnostic_kwargs = {
   1360     "finished_requests_ids": model_input.finished_requests_ids,
   1361     "request_ids_to_seq_ids": model_input.request_ids_to_seq_ids,
   1362 } if self.has_seqlen_agnostic else {}
-> 1363 hidden_or_intermediate_states = model_executable(
   1364     input_ids=model_input.input_tokens,
   1365     positions=model_input.input_positions,
   1366     kv_caches=kv_caches,
   1367     attn_metadata=model_input.attn_metadata,
   1368     intermediate_tensors=intermediate_tensors,
   1369     **MultiModalInputs.as_kwargs(multi_modal_kwargs,
   1370                                  device=self.device),
   1371     **seqlen_agnostic_kwargs)
   1373 # Compute the logits in the last pipeline stage.
   1374 if not get_pp_group().is_last_rank:

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
   1551     return self._compiled_call_impl(*args, **kwargs)  # type: ignore[misc]
   1552 else:
-> 1553     return self._call_impl(*args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
   1557 # If we don't have any hooks, we want to skip the rest of the logic in
   1558 # this function, and just call forward.
   1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
   1560         or _global_backward_pre_hooks or _global_backward_hooks
   1561         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562     return forward_call(*args, **kwargs)
   1564 try:
   1565     result = None

File /usr/local/lib/python3.10/dist-packages/vllm/model_executor/models/phi3v.py:532, in Phi3VForCausalLM.forward(self, input_ids, positions, kv_caches, attn_metadata, intermediate_tensors, **kwargs)
    529     vision_embeddings = self.vision_embed_tokens(
    530         image_input["data"], image_input["image_sizes"])
    531     inputs_embeds = self.model.get_input_embeddings(input_ids)
--> 532     inputs_embeds = merge_vision_embeddings(input_ids, inputs_embeds,
    533                                             vision_embeddings,
    534                                             self.image_token_id)
    535     input_ids = None
    536 else:

File /usr/local/lib/python3.10/dist-packages/vllm/model_executor/models/utils.py:29, in merge_vision_embeddings(input_ids, inputs_embeds, vision_embeddings, image_token_id)
     27     if num_expected_tokens != total_tokens:
     28         expr = f"{batch_size} x {batch_tokens}"
---> 29         raise ValueError(
     30             f"Attempted to assign {expr} = {total_tokens} "
     31             f"image tokens to {num_expected_tokens} placeholders")
     33     inputs_embeds[mask] = vision_embeddings.view(total_tokens, embed_dim)
     34 else:

ValueError: Attempted to assign 49 x 781 = 38269 image tokens to 129997 placeholders
@remiconnesson remiconnesson added the bug Something isn't working label Aug 22, 2024
@Isotr0py
Copy link
Collaborator

This issue should have been fixed by #7710.
You can try to install the nightly wheel which include this fix:

export VLLM_VERSION=0.5.4 # vLLM's main branch version is currently set to latest released tag
pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/nightly/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl
# You can also access a specific commit
# export VLLM_COMMIT=...
# pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/${VLLM_COMMIT}/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl

@JamesDarschewskiJr
Copy link

I also had this error when trying to start up Phi 3.5 in the CLI running vllm serve microsoft/Phi-3.5-vision-instruct --tensor-parallel-size=2 --disable-log-stats --disable-log-requests --trust-remote-code --max-model-len 4096, any fixes for that?

@Gokul10272001
Copy link

This issue should have been fixed by #7710. You can try to install the nightly wheel which include this fix:

export VLLM_VERSION=0.5.4 # vLLM's main branch version is currently set to latest released tag
pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/nightly/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl
# You can also access a specific commit
# export VLLM_COMMIT=...
# pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/${VLLM_COMMIT}/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl

It is working fine in custom VM but how to make it work in Serverless inference endpoint

@ywang96
Copy link
Member

ywang96 commented Sep 2, 2024

Closing as this is fixed on the main branch

@ywang96 ywang96 closed this as completed Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants