Skip to content

[TPU][V1][Bugfix] Fix chunked prefill with padding #15037

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

NickLucche
Copy link
Contributor

@NickLucche NickLucche commented Mar 18, 2025

Currently if you run:

VLLM_USE_V1=1 vllm serve llava-hf/llava-1.5-7b-hf --max-model-len 2512 --max-num-seqs 16 --max-num-batched-tokens 128 --chat-template examples/template_llava.jinja --enforce-eager &

# query 
python examples/online_serving/openai_chat_completion_client_for_multimodal.py


[ ... ]
ERROR 03-18 13:12:42 [core.py:340]   File "/home/nick/work/vllm/vllm/v1/worker/tpu_model_runner.py", line 564, in execute_model
ERROR 03-18 13:12:42 [core.py:340]     inputs_embeds = self.model.get_input_embeddings(
ERROR 03-18 13:12:42 [core.py:340]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-18 13:12:42 [core.py:340]   File "/home/nick/work/vllm/vllm/v1/worker/tpu_model_runner.py", line 862, in get_input_embeddings
ERROR 03-18 13:12:42 [core.py:340]     return self.model.get_input_embeddings(*args, **kwargs)
ERROR 03-18 13:12:42 [core.py:340]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-18 13:12:42 [core.py:340]   File "/home/nick/work/vllm/vllm/model_executor/models/llava.py", line 779, in get_input_embeddings
ERROR 03-18 13:12:42 [core.py:340]     inputs_embeds = merge_multimodal_embeddings(
ERROR 03-18 13:12:42 [core.py:340]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-18 13:12:42 [core.py:340]   File "/home/nick/work/vllm/vllm/model_executor/models/utils.py", line 455, in merge_multimodal_embeddings
ERROR 03-18 13:12:42 [core.py:340]     return _merge_multimodal_embeddings(
ERROR 03-18 13:12:42 [core.py:340]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-18 13:12:42 [core.py:340]   File "/home/nick/work/vllm/vllm/model_executor/models/utils.py", line 371, in _merge_multimodal_embeddings
ERROR 03-18 13:12:42 [core.py:340]     raise ValueError(
ERROR 03-18 13:12:42 [core.py:340] ValueError: Attempted to assign 69 = 69 multimodal tokens to 113 placeholders
ERROR 03-18 13:12:42 [core.py:340] 
CRITICAL 03-18 13:12:42 [core_client.py:269] Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.
[1]    99083 killed     VLLM_USE_V1=1 vllm serve llava-hf/llava-1.5-7b-hf --max-model-len 2512  16   

I tried to summarize the issue in this (poorly drawn) diagram:

image

This is most noticeable with multimodal because spurious image tokens lingering on a re-used tensor will cause the server to crash, but the same happens with text-only.
Basically when we use CP in combination with padding, we must treat the last/terminal chunk carefully, otherwise it will contain values from previous iterations as the buffer (input_ids_cpu in this case) is re-used.

Signed-off-by: NickLucche <nlucches@redhat.com>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the v1 label Mar 18, 2025
@robertgshaw2-redhat robertgshaw2-redhat enabled auto-merge (squash) March 18, 2025 13:37
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 18, 2025
@DarkLight1337
Copy link
Member

Please fix the pre-commit failures

Signed-off-by: NickLucche <nlucches@redhat.com>
auto-merge was automatically disabled March 18, 2025 14:27

Head branch was pushed to by a user without write access

@vllm-bot vllm-bot merged commit af35d3a into vllm-project:main Mar 18, 2025
9 of 12 checks passed
gmarinho2 pushed a commit to gmarinho2/vllm that referenced this pull request Apr 1, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
Signed-off-by: NickLucche <nlucches@redhat.com>
Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
nishith-fujitsu pushed a commit to nishith-fujitsu/vllm that referenced this pull request Apr 9, 2025
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants