Skip to content

[Bug]: KeyError in multi-modal cache when using DP #17284

@xiaosu-zhu

Description

@xiaosu-zhu

Your current environment

The output of `python collect_env.py`
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.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.31.4
Libc version: glibc-2.35

Python version: 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 14:17:24) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-5.10.134-007.ali5000.al8.x86_64-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: 12.4.131
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
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, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          96
On-line CPU(s) list:             0-95
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
CPU family:                      6
Model:                           85
Thread(s) per core:              2
Core(s) per socket:              24
Socket(s):                       2
Stepping:                        4
CPU max MHz:                     3100.0000
CPU min MHz:                     1000.0000
BogoMIPS:                        5000.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 cdp_l3 invpcid_single 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
Virtualization:                  VT-x
L1d cache:                       1.5 MiB (48 instances)
L1i cache:                       1.5 MiB (48 instances)
L2 cache:                        48 MiB (48 instances)
L3 cache:                        66 MiB (2 instances)
NUMA node(s):                    1
NUMA node0 CPU(s):               0-95
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:          Vulnerable
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:          Vulnerable
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:        Vulnerable, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB filling, PBRSB-eIBRS: Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] flashinfer-python==0.2.4+cu124torch2.6
[pip3] numpy==2.2.2
[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-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] optree==0.14.0
[pip3] pyzmq==26.4.0
[pip3] torch==2.6.0+cu124
[pip3] torchaudio==2.6.0+cu124
[pip3] torchelastic==0.2.2
[pip3] torchvision==0.21.0+cu124
[pip3] transformers==4.51.3
[pip3] triton==3.2.0
[conda] flashinfer-python         0.2.4+cu124torch2.6          pypi_0    pypi
[conda] numpy                     2.2.2           py311h5d046bc_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-cusparselt-cu12    0.6.2                    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.14.0                   pypi_0    pypi
[conda] pyzmq                     26.4.0                   pypi_0    pypi
[conda] torch                     2.6.0+cu124              pypi_0    pypi
[conda] torchaudio                2.6.0+cu124              pypi_0    pypi
[conda] torchelastic              0.2.2                    pypi_0    pypi
[conda] torchvision               0.21.0+cu124             pypi_0    pypi
[conda] transformers              4.51.3                   pypi_0    pypi
[conda] triton                    3.2.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.8.4
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
Could not collect

NVIDIA_VISIBLE_DEVICES=all
NCCL_ALGO=Tree
NVIDIA_REQUIRE_CUDA=cuda>=12.4 brand=tesla,driver>=470,driver<471 brand=unknown,driver>=470,driver<471 brand=nvidia,driver>=470,driver<471 brand=nvidiartx,driver>=470,driver<471 brand=geforce,driver>=470,driver<471 brand=geforcertx,driver>=470,driver<471 brand=quadro,driver>=470,driver<471 brand=quadrortx,driver>=470,driver<471 brand=titan,driver>=470,driver<471 brand=titanrtx,driver>=470,driver<471 brand=tesla,driver>=525,driver<526 brand=unknown,driver>=525,driver<526 brand=nvidia,driver>=525,driver<526 brand=nvidiartx,driver>=525,driver<526 brand=geforce,driver>=525,driver<526 brand=geforcertx,driver>=525,driver<526 brand=quadro,driver>=525,driver<526 brand=quadrortx,driver>=525,driver<526 brand=titan,driver>=525,driver<526 brand=titanrtx,driver>=525,driver<526 brand=tesla,driver>=535,driver<536 brand=unknown,driver>=535,driver<536 brand=nvidia,driver>=535,driver<536 brand=nvidiartx,driver>=535,driver<536 brand=geforce,driver>=535,driver<536 brand=geforcertx,driver>=535,driver<536 brand=quadro,driver>=535,driver<536 brand=quadrortx,driver>=535,driver<536 brand=titan,driver>=535,driver<536 brand=titanrtx,driver>=535,driver<536
NCCL_VERSION=2.21.5-1
NVIDIA_DRIVER_CAPABILITIES=compute,utility
NCCL_P2P_LEVEL=NVL
VLLM_WORKER_MULTIPROC_METHOD=spawn
NVIDIA_PRODUCT_NAME=CUDA
NVIDIA_CPU_ONLY=1
CUDA_DEVICE_ORDER=PCI_BUS_ID
CUDA_VERSION=12.4.1
PYTORCH_VERSION=2.6.0
CUDACXX=/usr/local/cuda/bin/nvcc
MAX_JOBS=32
LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
OMP_NUM_THREADS=32
NCCL_CUMEM_ENABLE=0
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1

🐛 Describe the bug

As tracked in #16875 , The latest vllm still faces KeyError using DP configs:

VLLM_ENABLE_V1_MULTIPROCESSING=0 USE_FASTSAFETENSOR=true VLLM_USE_V1=1 python api_server.py --model Qwen/Qwen-2.5-VL-7B-Instruct --max_model_len 32768 --limit-mm-per-prompt image=1,video=1 -tp 1 -dp 8 --port 8002

It throws KeyError during mm_cache retrieval when there is more than 1 mm_inputs in the request queue.

Error output, same as #16875
ERROR 04-19 17:04:00 [core.py:387] EngineCore hit an exception: Traceback (most recent call last):
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/cachetools/__init__.py", line 68, in __getitem__
ERROR 04-19 17:04:00 [core.py:387]     return self.__data[key]
ERROR 04-19 17:04:00 [core.py:387]            ~~~~~~~~~~~^^^^^
ERROR 04-19 17:04:00 [core.py:387] KeyError: 'baeea367ef018cb2850dd6bc6b4e4cf2a8f2ed5866cf651a8a987e18f54868ba'
ERROR 04-19 17:04:00 [core.py:387] 
ERROR 04-19 17:04:00 [core.py:387] During handling of the above exception, another exception occurred:
ERROR 04-19 17:04:00 [core.py:387] 
ERROR 04-19 17:04:00 [core.py:387] Traceback (most recent call last):
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 380, in run_engine_core
ERROR 04-19 17:04:00 [core.py:387]     engine_core.run_busy_loop()
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 400, in run_busy_loop
ERROR 04-19 17:04:00 [core.py:387]     self._process_input_queue()
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 425, in _process_input_queue
ERROR 04-19 17:04:00 [core.py:387]     self._handle_client_request(*req)
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 441, in _handle_client_request
ERROR 04-19 17:04:00 [core.py:387]     self.add_request(request)
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 177, in add_request
ERROR 04-19 17:04:00 [core.py:387]     request.mm_inputs = self.mm_input_cache_server.get_and_update_p1(
ERROR 04-19 17:04:00 [core.py:387]                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/mm_input_cache.py", line 76, in get_and_update_p1
ERROR 04-19 17:04:00 [core.py:387]     mm_input = self.mm_cache[mm_hash]
ERROR 04-19 17:04:00 [core.py:387]                ~~~~~~~~~~~~~^^^^^^^^^
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/cachetools/__init__.py", line 211, in __getitem__
ERROR 04-19 17:04:00 [core.py:387]     value = cache_getitem(self, key)
ERROR 04-19 17:04:00 [core.py:387]             ^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/cachetools/__init__.py", line 70, in __getitem__
ERROR 04-19 17:04:00 [core.py:387]     return self.__missing__(key)
ERROR 04-19 17:04:00 [core.py:387]            ^^^^^^^^^^^^^^^^^^^^^
ERROR 04-19 17:04:00 [core.py:387]   File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/cachetools/__init__.py", line 97, in __missing__
ERROR 04-19 17:04:00 [core.py:387]     raise KeyError(key)
ERROR 04-19 17:04:00 [core.py:387] KeyError: 'baeea367ef018cb2850dd6bc6b4e4cf2a8f2ed5866cf651a8a987e18f54868ba'
ERROR 04-19 17:04:00 [core.py:387] 
INFO:     127.0.0.1:55430 - "POST /v1/chat/completions HTTP/1.1" 200 OK
--- Logging error ---
Traceback (most recent call last):
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1164, in emit
    self.flush()
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1144, in flush
    self.stream.flush()
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
Call stack:
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/entrypoints/openai/api_server.py", line 1121, in <module>
    uvloop.run(run_server(args))
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/uvloop/__init__.py", line 109, in run
    return __asyncio.run(
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
    await response(scope, receive, send)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/responses.py", line 150, in __call__
    await send(
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/_exception_handler.py", line 39, in sender
    await send(message)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/_exception_handler.py", line 39, in sender
    await send(message)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/starlette/middleware/errors.py", line 162, in _send
    await send(message)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 476, in send
    self.access_logger.info(
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1539, in info
    self._log(INFO, msg, args, **kwargs)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1684, in _log
    self.handle(record)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1700, in handle
    self.callHandlers(record)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
    hdlr.handle(record)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1028, in handle
    self.emit(record)
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1164, in emit
    self.flush()
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/logging/__init__.py", line 1144, in flush
    self.stream.flush()
  File "/root/anaconda3/envs/vllm_latest/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 359, in sigusr1_handler
    logger.fatal("Got fatal signal from worker processes, shutting "
Message: 'Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.'
Arguments: ()

The issue is fixed when setting -tp n -dp 1.

As @DarkLight1337 denotes, for DP use case, this issue may be caused by the syncing of mm_cache between different workers, @youkaichao @njhill could it be fixed?

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

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions