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]: Paligemma does not work with tensor parallelism #6910

Closed
siddvenk opened this issue Jul 29, 2024 · 7 comments · Fixed by #6930
Closed

[Bug]: Paligemma does not work with tensor parallelism #6910

siddvenk opened this issue Jul 29, 2024 · 7 comments · Fixed by #6930
Assignees
Labels
bug Something isn't working

Comments

@siddvenk
Copy link

Your current environment

Collecting environment information...
PyTorch version: 2.3.1+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.1
Libc version: glibc-2.35

Python version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.0-1022-aws-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.4.131
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA L4
GPU 1: NVIDIA L4
GPU 2: NVIDIA L4
GPU 3: NVIDIA L4

Nvidia driver version: 535.183.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.1.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.1.0
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:                      48 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             48
On-line CPU(s) list:                0-47
Vendor ID:                          AuthenticAMD
Model name:                         AMD EPYC 7R13 Processor
CPU family:                         25
Model:                              1
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          1
Stepping:                           1
BogoMIPS:                           5300.00
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 tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch topoext invpcid_single ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr rdpru wbnoinvd arat npt nrip_save vaes vpclmulqdq rdpid
Hypervisor vendor:                  KVM
Virtualization type:                full
L1d cache:                          768 KiB (24 instances)
L1i cache:                          768 KiB (24 instances)
L2 cache:                           12 MiB (24 instances)
L3 cache:                           96 MiB (3 instances)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-47
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: Vulnerable: Safe RET, no microcode
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; IBRS_FW; 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] flashinfer==0.0.9+cu121torch2.3
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] onnx==1.16.1
[pip3] onnxruntime-gpu==1.18.0
[pip3] sentence-transformers==3.0.1
[pip3] torch==2.3.1+cu121
[pip3] torchvision==0.18.1+cu121
[pip3] transformers==4.43.2
[pip3] triton==2.3.1
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.3.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0	GPU1	GPU2	GPU3	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	SYS	SYS	SYS	0-47	0		N/A
GPU1	SYS	 X 	SYS	SYS	0-47	0		N/A
GPU2	SYS	SYS	 X 	SYS	0-47	0		N/A
GPU3	SYS	SYS	SYS	 X 	0-47	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

Model: google/paligemma-3b-mix-448

Issue: There is an issue during the warmup phase when using tensor parallelism.

Reproducible example:

from vllm import LLM

llm = LLM(model="google/paligemma-3b-mix-448", tensor_parallel_size=2)

Exception:

INFO 07-29 19:25:16 model_runner.py:692] Loading model weights took 3.2067 GB
(VllmWorkerProcess pid=161) INFO 07-29 19:25:18 model_runner.py:692] Loading model weights took 3.2067 GB
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226] Exception in worker VllmWorkerProcess while processing method determine_num_available_blocks: shape mismatch: value tensor of shape [8192, 1024] cannot be broadcast to indexing result of shape [8192, 2048], Traceback (most recent call last):
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/executor/multiproc_worker_utils.py", line 223, in _run_worker_process
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     output = executor(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     return func(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/worker.py", line 179, in determine_num_available_blocks
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     self.model_runner.profile_run()
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     return func(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/model_runner.py", line 896, in profile_run
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     self.execute_model(model_input, kv_caches, intermediate_tensors)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     return func(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/model_runner.py", line 1314, in execute_model
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     hidden_or_intermediate_states = model_executable(
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     return self._call_impl(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1541, in _call_impl
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     return forward_call(*args, **kwargs)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/models/paligemma.py", line 259, in forward
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     inputs_embeds = merge_vision_embeddings(
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]   File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/models/utils.py", line 33, in merge_vision_embeddings
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226]     inputs_embeds[mask] = vision_embeddings.view(total_tokens, embed_dim)
(VllmWorkerProcess pid=161) ERROR 07-29 19:25:19 multiproc_worker_utils.py:226] RuntimeError: shape mismatch: value tensor of shape [8192, 1024] cannot be broadcast to indexing result of shape [8192, 2048]

This model works when not using tensor parallelism, but any level of tensor parallelism causes the issue above.

@lanking520
Copy link

@ywang96

@ywang96
Copy link
Member

ywang96 commented Jul 29, 2024

Hey @siddvenk Thanks for reporting this issue! I will look into this.

Just to confirm: The same model works with TP=1 but not TP=2, correct? (I can verify this later myself too was just wondering if I can get a quick answer)

@ywang96 ywang96 self-assigned this Jul 29, 2024
@lanking520
Copy link

@ywang96 we tested on TP=4 and doesn't work. We didn't test on TP2

@ywang96
Copy link
Member

ywang96 commented Jul 29, 2024

@ywang96 we tested on TP=4 and doesn't work. We didn't test on TP2

Got it - there might have been some changes in distributed ops that I wasn't aware of - I will look into this and patch a fix. Sorry for the trouble!

@siddvenk
Copy link
Author

@ywang96 I also tested with TP=2 and it doesn't work. It's the same error as with TP=4, just different numbers in the broadcast exception

@ywang96
Copy link
Member

ywang96 commented Jul 30, 2024

Hey @lanking520 @siddvenk! This bug was due to an oversight of us using a TP-sharded layer in the multimodal projector when we haven't supported sharding it, and should be fixed by #6930. It wasn't caught previously because we don't have a TP test for VLMs but we should definitely add one when we have more credits for CI. Sorry for the inconvenience!

@siddvenk
Copy link
Author

Appreciate the quick investigation and fix here!

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

Successfully merging a pull request may close this issue.

3 participants