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]: Gemma3 Offline Batch Inference: Attempted to assign XXX multimodal tokens to YYY placeholders #14897

Closed
1 task done
BiEchi opened this issue Mar 16, 2025 · 18 comments · Fixed by #14980 or #15086
Closed
1 task done
Labels
bug Something isn't working

Comments

@BiEchi
Copy link

BiEchi commented Mar 16, 2025

Your current environment

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

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

Python version: 3.10.0 (default, Mar  3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-112-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3
GPU 2: NVIDIA H100 80GB HBM3
GPU 3: NVIDIA H100 80GB HBM3
GPU 4: NVIDIA H100 80GB HBM3
GPU 5: NVIDIA H100 80GB HBM3
GPU 6: NVIDIA H100 80GB HBM3
GPU 7: NVIDIA H100 80GB HBM3

Nvidia driver version: 550.90.07
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:                      46 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             104
On-line CPU(s) list:                0-103
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8470
CPU family:                         6
Model:                              143
Thread(s) per core:                 1
Core(s) per socket:                 52
Socket(s):                          2
Stepping:                           8
BogoMIPS:                           4000.00
Flags:                              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 tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl 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 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
L1d cache:                          4.9 MiB (104 instances)
L1i cache:                          3.3 MiB (104 instances)
L2 cache:                           208 MiB (104 instances)
L3 cache:                           210 MiB (2 instances)
NUMA node(s):                       8
NUMA node0 CPU(s):                  0-12
NUMA node1 CPU(s):                  13-25
NUMA node2 CPU(s):                  26-38
NUMA node3 CPU(s):                  39-51
NUMA node4 CPU(s):                  52-64
NUMA node5 CPU(s):                  65-77
NUMA node6 CPU(s):                  78-90
NUMA node7 CPU(s):                  91-103
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:             Not affected
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; BHI BHI_DIS_S
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] flashinfer-python==0.2.3+cu124torch2.6
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-cusparselt-cu12==0.6.2
[pip3] nvidia-ml-py==12.570.86
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] pynvml==12.0.0
[pip3] pyzmq==26.3.0
[pip3] torch==2.6.0
[pip3] torchaudio==2.6.0
[pip3] torchvision==0.21.0
[pip3] transformers==4.50.0.dev0
[pip3] triton==3.2.0
[conda] flashinfer-python         0.2.3+cu124torch2.6          pypi_0    pypi
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-cublas-cu12        12.4.5.8                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.4.127                 pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.1.0.70                 pypi_0    pypi
[conda] nvidia-cufft-cu12         11.2.1.3                 pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.5.147               pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.6.1.9                 pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.3.1.170               pypi_0    pypi
[conda] nvidia-cusparselt-cu12    0.6.2                    pypi_0    pypi
[conda] nvidia-ml-py              12.570.86                pypi_0    pypi
[conda] nvidia-nccl-cu12          2.21.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.4.127                 pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.4.127                 pypi_0    pypi
[conda] pynvml                    12.0.0                   pypi_0    pypi
[conda] pyzmq                     26.3.0                   pypi_0    pypi
[conda] torch                     2.6.0                    pypi_0    pypi
[conda] torchaudio                2.6.0                    pypi_0    pypi
[conda] torchvision               0.21.0                   pypi_0    pypi
[conda] transformers              4.50.0.dev0              pypi_0    pypi
[conda] triton                    3.2.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.7.4.dev477+g61c6a5a7
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    NIC0    NIC1    NIC2    NIC3    NIC4    NIC5    NIC6    NIC7    NIC8    NIC9      NIC10   NIC11   CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NV18    NV18    NV18    NV18    NV18    NV18    NV18    PIX     PIX     PIX     SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS     0-12    0               N/A
GPU1    NV18     X      NV18    NV18    NV18    NV18    NV18    NV18    SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS     26-38   2               N/A
GPU2    NV18    NV18     X      NV18    NV18    NV18    NV18    NV18    SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS       SYS     SYS     SYS     39-51   3               N/A
GPU3    NV18    NV18    NV18     X      NV18    NV18    NV18    NV18    SYS     SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS       SYS     SYS     SYS     13-25   1               N/A
GPU4    NV18    NV18    NV18    NV18     X      NV18    NV18    NV18    SYS     SYS     SYS     SYS     SYS     SYS     PIX     PIX     PIX       SYS     SYS     SYS     52-64   4               N/A
GPU5    NV18    NV18    NV18    NV18    NV18     X      NV18    NV18    SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS       PIX     SYS     SYS     78-90   6               N/A
GPU6    NV18    NV18    NV18    NV18    NV18    NV18     X      NV18    SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS       SYS     PIX     SYS     91-103  7               N/A
GPU7    NV18    NV18    NV18    NV18    NV18    NV18    NV18     X      SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS     PIX     65-77   5               N/A
NIC0    PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS      X      PIX     PIX     SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS
NIC1    PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     PIX      X      PIX     SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS
NIC2    PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     PIX     PIX      X      SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS
NIC3    SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS      X      SYS     SYS     SYS     SYS     SYS       SYS     SYS     SYS
NIC4    SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS      X      SYS     SYS     SYS     SYS       SYS     SYS     SYS
NIC5    SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS      X      SYS     SYS     SYS       SYS     SYS     SYS
NIC6    SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS      X      PIX     PIX       SYS     SYS     SYS
NIC7    SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     PIX      X      PIX       SYS     SYS     SYS
NIC8    SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     PIX     PIX      X        SYS     SYS     SYS
NIC9    SYS     SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS        X      SYS     SYS
NIC10   SYS     SYS     SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS       SYS      X      SYS
NIC11   SYS     SYS     SYS     SYS     SYS     SYS     SYS     PIX     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS     SYS       SYS     SYS      X 

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

NIC Legend:

  NIC0: mlx5_0
  NIC1: mlx5_1
  NIC2: mlx5_2
  NIC3: mlx5_3
  NIC4: mlx5_4
  NIC5: mlx5_5
  NIC6: mlx5_6
  NIC7: mlx5_7
  NIC8: mlx5_8
  NIC9: mlx5_9
  NIC10: mlx5_10
  NIC11: mlx5_11

NCCL_CUMEM_ENABLE=0
TORCHINDUCTOR_COMPILE_THREADS=1
CUDA_MODULE_LOADING=LAZY

🐛 Describe the bug

@WoosukKwon This error is likely a processor-related error.

The error happens for both llm.chat() and llm.generate(). It says Attempted to assign XXX multimodal tokens to YYY placeholders. This error only happens when there are image inputs, but is arbitrary to image (i.e. it remains when replacing images with other images). This error happens only when len(messages)>=32, i.e. if I input messages individually for len(messages) times or using a mini-batched version, it does not raise an error.

Minimum reproduction example:

from vllm import LLM, SamplingParams
import torch

if __name__ == '__main__':

    model = LLM(
                model="google/gemma-3-27b-it",
                max_model_len=8192,
                tensor_parallel_size=1,
                limit_mm_per_prompt={"image": 5},
                tokenizer_mode="auto"
            )
    sampling_params = SamplingParams(temperature=1,max_tokens=8192,stop_token_ids=None)
        
    messages = torch.load("messages.pt") # contanins 64 messages, the error does not matter whether you input any image or not

    response = model.chat(
        messages=messages,
        sampling_params=sampling_params,
        chat_template=None,
    )

    outputs = []
    for out in response:
        generated_text = out.outputs[0].text
        outputs.append(generated_text)
        
    print(outputs)

Error:

Using a slow image processor as `use_fast` is unset and a slow processor was saved with this model. `use_fast=True` will be the default behavior in v4.50, even if the model was saved with a slow processor. This will result in minor differences in outputs. You'll still be able to use a slow processor with `use_fast=False`.
Processed prompts:  47%|███████████▋             | 30/64 [00:10<00:12,  2.77it/s, est. speed input: 4163.14 toks/s, output: 481.12 toks/s]ERROR 03-16 12:28:39 [core.py:340] EngineCore hit an exception: Traceback (most recent call last):
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/engine/core.py", line 333, in run_engine_core
ERROR 03-16 12:28:39 [core.py:340]     engine_core.run_busy_loop()
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/engine/core.py", line 367, in run_busy_loop
ERROR 03-16 12:28:39 [core.py:340]     outputs = step_fn()
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/engine/core.py", line 192, in step
ERROR 03-16 12:28:39 [core.py:340]     output = self.model_executor.execute_model(scheduler_output)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/executor/abstract.py", line 80, in execute_model
ERROR 03-16 12:28:39 [core.py:340]     output = self.collective_rpc("execute_model",
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/executor/uniproc_executor.py", line 56, in collective_rpc
ERROR 03-16 12:28:39 [core.py:340]     answer = run_method(self.driver_worker, method, args, kwargs)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/utils.py", line 2216, in run_method
ERROR 03-16 12:28:39 [core.py:340]     return func(*args, **kwargs)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/miniconda3/envs/pae/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
ERROR 03-16 12:28:39 [core.py:340]     return func(*args, **kwargs)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/worker/gpu_worker.py", line 242, in execute_model
ERROR 03-16 12:28:39 [core.py:340]     output = self.model_runner.execute_model(scheduler_output)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/miniconda3/envs/pae/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
ERROR 03-16 12:28:39 [core.py:340]     return func(*args, **kwargs)
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/v1/worker/gpu_model_runner.py", line 961, in execute_model
ERROR 03-16 12:28:39 [core.py:340]     inputs_embeds = self.model.get_input_embeddings(
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/model_executor/models/gemma3_mm.py", line 502, in get_input_embeddings
ERROR 03-16 12:28:39 [core.py:340]     inputs_embeds = merge_multimodal_embeddings(
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/model_executor/models/utils.py", line 455, in merge_multimodal_embeddings
ERROR 03-16 12:28:39 [core.py:340]     return _merge_multimodal_embeddings(
ERROR 03-16 12:28:39 [core.py:340]   File "/home/agi/vllm/vllm/model_executor/models/utils.py", line 371, in _merge_multimodal_embeddings
ERROR 03-16 12:28:39 [core.py:340]     raise ValueError(
ERROR 03-16 12:28:39 [core.py:340] ValueError: Attempted to assign 256 + 74 = 330 multimodal tokens to 332 placeholders
ERROR 03-16 12:28:39 [core.py:340] 
CRITICAL 03-16 12:28:39 [core_client.py:269] Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.
Killed

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
@BiEchi BiEchi added the bug Something isn't working label Mar 16, 2025
@BiEchi BiEchi changed the title [Bug]: Gemma3 Offline Batch Inference: Attempted to assign abc multimodal tokens to ab(c+2) placeholders [Bug]: Gemma3 Offline Batch Inference: Attempted to assign XXX multimodal tokens to YYY placeholders Mar 16, 2025
@DarkLight1337
Copy link
Member

Does this only happen for the 27b model?

@smartdolphin
Copy link

@DarkLight1337 The same issue occurs in 12b as well.

@BiEchi
Copy link
Author

BiEchi commented Mar 17, 2025

Yes, I suppose it happens in all sizes.

@DarkLight1337
Copy link
Member

DarkLight1337 commented Mar 17, 2025

Does this happen on V0 (VLLM_USE_V1=0) or V1 (VLLM_USE_V1=1)? (Please note, the default on main branch has recently been changed to V1)

@BiEchi
Copy link
Author

BiEchi commented Mar 17, 2025

@DarkLight1337 this error only happens to V1

@WoosukKwon
Copy link
Collaborator

@BiEchi Would it be possible to share a reproducible example with inputs?

@gohar94
Copy link

gohar94 commented Mar 17, 2025

@WoosukKwon Observing the same with NVLM in V1.

@gohar94
Copy link

gohar94 commented Mar 17, 2025

@WoosukKwon Also observing this with NVLM in V0 when using --enable-chunked-prefill. My current hypothesis is that it happens with concurrent requests but not when I sequentially send the same requests so it is a little tricky to reproduce.

@DarkLight1337
Copy link
Member

DarkLight1337 commented Mar 17, 2025

Chunked prefill in general is not supported for multi-modal models in V0.

Did you also set temperature=1 for NVLM? Can you try lowering the temperature and see if it alleviates the issue?

@gohar94
Copy link

gohar94 commented Mar 17, 2025

@DarkLight1337 I was trying with temperature=0 and beta.chat.completions.parse (if that matters). I recently switched to V1 (without explicitly enabling chunked prefill but I think V1 has it enabled by default?) but still running into the same issue. Is there a temporary workaround you recommend?

@DarkLight1337
Copy link
Member

Chunked prefill is supported for multi-modal models in V1. Can you show the prompt which you are using?

@gohar94
Copy link

gohar94 commented Mar 17, 2025

@DarkLight1337 It seems to be non-deterministic. I think it depends on the batch of requests. Running the individually failing query separately does not result in any issues. So I am guess it has something to do with concurrency/batch size. Not sure what pointers I can provide to help reproduce it? My test case has a large number of requests that I go through with some degree of concurrency so it's a bit tricky to get the exact failing batch again.

@gohar94
Copy link

gohar94 commented Mar 17, 2025

I am not changing the batch size and upon launch, I see the following log: Chunked prefill is enabled with max_num_batched_tokens=2048.

Does it make sense to increase this? Default for NVLM is max_seq_len=98304 and I am specifying max_num_seqs=256.

@DarkLight1337
Copy link
Member

Can you try out #14980 and see if it can solve the problem?

@gohar94
Copy link

gohar94 commented Mar 18, 2025

Can you try out #14980 and see if it can solve the problem?

Sure, I can try today. Is that expected to help with NVLM too? Just making sure it's not just for Gemma3.

@DarkLight1337
Copy link
Member

No, that PR only fixes Gemma3

@gohar94
Copy link

gohar94 commented Mar 18, 2025

No, that PR only fixes Gemma3

Hmm -- I am running into a lot of these errors with NVLM as well on vLLM 0.8.0rc3.dev1+g5340b0e2. Hard to find a reproducible subset of queries but I'll try to find something.

@gohar94
Copy link

gohar94 commented Mar 19, 2025

@DarkLight1337 Gemma3 works fine so far on your bugfix branch.

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
5 participants