Repository navigation
Add embedding input functionality for disabled modalities [remake] #32493
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
93b8678
change
ec8a28e
change
reaganjlee 79b122a
change
reaganjlee bd5ec6d
change
reaganjlee e5eaa36
change
reaganjlee 6a4a569
logger.debug + doc
reaganjlee ad36e65
change
f068bf0
Update vllm/multimodal/processing/context.py
reaganjlee 9f55509
e2e
edd409d
ruff
6842ab1
change
e107e82
rename
a8508a0
change + precommit
e33d537
mypy CI
dd2a342
precommit again
034dca2
RFC, change out unit test for more e2e-like
4eae106
respond
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import weakref | ||
|
|
||
| import pytest | ||
|
|
||
| from vllm import LLM, SamplingParams | ||
| from vllm.assets.image import ImageAsset | ||
| from vllm.distributed import cleanup_dist_env_and_memory | ||
|
|
||
| MODEL = "llava-hf/llava-1.5-7b-hf" | ||
| PROMPT = "USER: <image>\nDescribe this image briefly.\nASSISTANT:" | ||
| TEXT_ONLY_PROMPT = "USER: What is 2 + 2?\nASSISTANT:" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def llm(): | ||
| """LLM with enable_mm_embeds=True and all modality limits zeroed out.""" | ||
| llm = LLM( | ||
| model=MODEL, | ||
| max_model_len=2048, | ||
| enforce_eager=True, | ||
| gpu_memory_utilization=0.8, | ||
| enable_mm_embeds=True, | ||
| limit_mm_per_prompt={"image": 0}, | ||
| ) | ||
|
|
||
| yield weakref.proxy(llm) | ||
|
|
||
| del llm | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
|
|
||
|
|
||
| @pytest.mark.skip_global_cleanup | ||
| def test_generate_with_embedding(llm: LLM): | ||
| """Pre-computed embedding produces tokens without hanging.""" | ||
| embedding = ImageAsset("stop_sign").image_embeds | ||
| outputs = llm.generate( | ||
| {"prompt": PROMPT, "multi_modal_data": {"image": embedding}}, | ||
| sampling_params=SamplingParams(max_tokens=32, temperature=0.0), | ||
| ) | ||
| assert len(outputs) == 1 | ||
| assert len(outputs[0].outputs[0].text) > 0 | ||
|
|
||
|
|
||
| @pytest.mark.skip_global_cleanup | ||
| def test_raw_image_rejected(llm: LLM): | ||
| """Raw image input is still rejected when limit=0.""" | ||
| raw_image = ImageAsset("stop_sign").pil_image | ||
| with pytest.raises(ValueError, match=r"At most 0 image\(s\)"): | ||
| llm.generate( | ||
| {"prompt": PROMPT, "multi_modal_data": {"image": raw_image}}, | ||
| sampling_params=SamplingParams(max_tokens=16), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skip_global_cleanup | ||
| def test_text_only_prompt(llm: LLM): | ||
| """Text-only prompts still work under this config.""" | ||
| outputs = llm.generate( | ||
| TEXT_ONLY_PROMPT, | ||
| sampling_params=SamplingParams(max_tokens=16, temperature=0.0), | ||
| ) | ||
| assert len(outputs) == 1 | ||
| assert len(outputs[0].outputs[0].text) > 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.