Skip to content

[Bug]: LLama 3.2 vision focuses only on first image #10983

@hrodruck

Description

@hrodruck

Your current environment

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

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: Could not collect
Clang version: Could not collect
CMake version: version 3.30.5
Libc version: glibc-2.35                                                                                                
Python version: 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0] (64-bit runtime)         Python platform: Linux-6.8.0-40-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 L40S                                                                        Nvidia driver version: 550.90.07
cuDNN version: Could not collect                                                                               [96/1442]
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):                               64
On-line CPU(s) list:                  0-63
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Silver 4314 CPU @ 2.40GHz                                        CPU family:                           6                                                                                 Model:                                106
Thread(s) per core:                   2
Core(s) per socket:                   16
Socket(s):                            2                                                                                 Stepping:                             6                                                                                 CPU max MHz:                          3400.0000
CPU min MHz:                          800.0000
BogoMIPS:                             4800.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 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 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad 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 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d
arch_capabilities                                                                                              [64/1442]
Virtualization:                       VT-x
L1d cache:                            1.5 MiB (32 instances)
L1i cache:                            1 MiB (32 instances)
L2 cache:                             40 MiB (32 instances)
L3 cache:                             48 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-15,32-47
NUMA node1 CPU(s):                    16-31,48-63
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected                                                                      Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected                                                                      Vulnerability Retbleed:               Not affected                                                                      Vulnerability Spec rstack overflow:   Not affected                                                                      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; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop                                                                                   Vulnerability Srbds:                  Not affected                                                                      Vulnerability Tsx async abort:        Not affected                                                                                                                                                                                              Versions of relevant libraries:                                                                                         [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                                                                             [32/1442][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-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127                                                                                       [pip3] pyzmq==26.2.0                                                                                                    [pip3] torch==2.5.1
[pip3] torchvision==0.20.1
[pip3] transformers==4.47.0
[pip3] triton==3.1.0
[conda] numpy                     2.1.2           py311h71ddf71_0    conda-forge
[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-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] optree                    0.13.0                   pypi_0    pypi
[conda] pyzmq                     26.2.0                   pypi_0    pypi
[conda] torch                     2.5.1+cu124              pypi_0    pypi
[conda] torchaudio                2.5.1+cu124              pypi_0    pypi
[conda] torchelastic              0.2.2                    pypi_0    pypi
[conda] torchvision               0.20.1+cu124             pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.4.post2.dev266+g7be15d93
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    NIC0    NIC1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      SYS     SYS     0-15,32-47      0               N/A
NIC0    SYS      X      PIX
NIC1    SYS     PIX      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

NVIDIA_VISIBLE_DEVICES=GPU-d6019853-74ce-0435-38f5-d106baeeef60
NVIDIA_DRIVER_CAPABILITIES=all
PYTORCH_VERSION=2.5.1
LD_LIBRARY_PATH=/root/vllm_1/lib/python3.11/site-packages/cv2/../../lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
CUDA_MODULE_LOADING=LAZY

Model Input Dumps

No response

🐛 Describe the bug

No matter what I do, llama3.2 vision focuses only on the first image, despite #9095. The tests at
vllm/tests/models/encoder_decoder/vision_language/test_mllama.py
nominally pass, but, if you print the model reponses, you do not get intended behavior.

The most direct way to reproduce this bug is by following the example in PR #9393
Serve the model

python -m vllm.entrypoints.openai.api_server \
    --device cuda \
    --model meta-llama/Llama-3.2-11B-Vision-Instruct \
    --api-key token-abc123 \
    --tokenizer meta-llama/Llama-3.2-11B-Vision-Instruct \
    --limit-mm-per-prompt image=2 \
    --max-model-len 32000 \
    --dtype=half  \
    --enforce-eager \
    --max-num-seqs 2

Then attempt a conversation

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="token-abc123")

conversation = []

def get_completion(prompt):
    conversation.append({"role": "user", "content": prompt})
    
    response = client.chat.completions.create(
        model="meta-llama/Llama-3.2-11B-Vision-Instruct",
        messages=conversation,
        max_tokens=150
    )
    
    assistant_response = response.choices[0].message.content
    conversation.append({"role": "assistant", "content": assistant_response})
    return assistant_response

chain_of_thought_steps = [
    [
      {"type": "image_url", "image_url": {"url": f"https://www.jampaper.com/media/wp-content/uploads/2014/04/cereal-box-e1397150195903.jpg"}},
      {"type": "text", "text": "Please describe this first image"},
    ],
    [
      {"type": "image_url", "image_url": {"url": f"https://cdn.awsli.com.br/600x450/1965/1965063/produto/17840338592397ef767.jpg"}},
      {"type": "text", "text": "Please describe this second image"},
    ],
    [
      {"type": "text", "text": "Compare the descriptions for the two images"},
    ],
]

for i, step in enumerate(chain_of_thought_steps):
    response = get_completion(step)
    print(f"Step {i + 1} Response: {response}")

What I get are two descriptions of cereal, despite the second image being of a doll.

I tried a myriad of other methods, such as sending both images in one message, to no avail. Would really appreciate help digging to the core of this bug.

Thank you

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions