Repository navigation
Implicit language-model-only mode via limit-mm-per-prompt #22299
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
Changes from 69 commits
16e2d78
d666559
7714cfa
a2f4720
2f5da46
f9d4709
3bc743d
7478cdc
9c66f5d
3048ba3
31f45f5
dc20458
cf71e91
f3a7a3e
741c1b0
6443303
8881e6b
e862c6b
73a1a6e
fc41700
69526d3
68b2413
434e9b3
7594efb
6744ac1
e1748fa
e0f1383
af746ee
aac7794
1c6cef8
5af9e58
15850be
12966d4
acf0d5a
e941f33
e329b33
9b5a176
0a6a655
006c0c8
4f060b6
665698c
a34e38f
8e049be
c7d8545
4355cfb
f20b040
12b4853
85d4756
64b3a57
ebcb01c
42f674c
7723c45
cf8aab7
e05914e
244e08f
9e4da59
df168cb
4b7992f
83b7ff0
9c4d6e1
ba90fb1
b613e22
3d64d84
0c2e198
e8661ce
2d6e358
03807c7
dda8e00
1cfe05a
fc98f6f
ac0fa66
33d1f48
19ba00a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """ | ||
| Unit tests for MultiModalRegistry.supports_multimodal_inputs and | ||
| Qwen2.5-VL visual component loading behavior. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from vllm.multimodal import MULTIMODAL_REGISTRY | ||
|
|
||
| from ..models.utils import build_model_context | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model_id,limit_mm_per_prompt,expected", | ||
| [ | ||
| ("Qwen/Qwen2-0.5B-Instruct", {}, False), | ||
| ("Qwen/Qwen2.5-VL-3B-Instruct", {}, True), | ||
| ("Qwen/Qwen2.5-VL-3B-Instruct", { | ||
| "image": 0, | ||
| "video": 0 | ||
| }, False), | ||
| ("Qwen/Qwen2.5-VL-3B-Instruct", { | ||
| "image": 0 | ||
| }, True), | ||
| ], | ||
| ) | ||
| @pytest.mark.core_model | ||
| def test_supports_multimodal_inputs(model_id, limit_mm_per_prompt, expected): | ||
| """Test supports_multimodal_inputs returns correct boolean for various | ||
| configs.""" | ||
| ctx = build_model_context( | ||
| model_id, | ||
| limit_mm_per_prompt=limit_mm_per_prompt, | ||
| ) | ||
| assert MULTIMODAL_REGISTRY.supports_multimodal_inputs( | ||
| ctx.model_config) is expected | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -722,13 +722,24 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""): | |
| "exactly same result as the transformers implementation " | ||
| "in the audio tower part.") | ||
|
|
||
| self.audio_tower = Qwen2_5OmniAudioEncoder(thinker_config.audio_config) | ||
| self.visual = Qwen2_5_VisionTransformer( | ||
| vision_config=thinker_config.vision_config, | ||
| norm_eps=getattr(thinker_config.text_config, "rms_norm_eps", 1e-6), | ||
| quant_config=quant_config, | ||
| prefix=maybe_prefix(prefix, "visual"), | ||
| ) | ||
| if multimodal_config.get_limit_per_prompt("audio"): | ||
|
ywang96 marked this conversation as resolved.
Resolved
|
||
| self.audio_tower = Qwen2_5OmniAudioEncoder( | ||
| thinker_config.audio_config) | ||
| else: | ||
| self.audio_tower = None | ||
|
|
||
| if multimodal_config.get_limit_per_prompt( | ||
| "image") or multimodal_config.get_limit_per_prompt("video"): | ||
|
ywang96 marked this conversation as resolved.
Resolved
Comment on lines
+731
to
+732
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is decoupled from This also means |
||
| self.visual = Qwen2_5_VisionTransformer( | ||
| vision_config=thinker_config.vision_config, | ||
| norm_eps=getattr(thinker_config.text_config, "rms_norm_eps", | ||
| 1e-6), | ||
| quant_config=quant_config, | ||
| prefix=maybe_prefix(prefix, "visual"), | ||
| ) | ||
| else: | ||
| self.visual = None | ||
|
|
||
| self.quant_config = quant_config | ||
| self.language_model = init_vllm_registered_model( | ||
| vllm_config=vllm_config, | ||
|
|
@@ -886,9 +897,15 @@ def compute_logits( | |
|
|
||
| def load_weights(self, weights: Iterable[tuple[str, | ||
| torch.Tensor]]) -> set[str]: | ||
| skip_prefixes = ["talker.", "token2wav."] | ||
| if self.audio_tower is None: | ||
| skip_prefixes.extend(["audio_tower."]) | ||
| if self.visual is None: | ||
| skip_prefixes.extend(["visual."]) | ||
|
|
||
| loader = AutoWeightsLoader( | ||
| self, | ||
| skip_prefixes=["talker.", "token2wav."], | ||
| skip_prefixes=skip_prefixes, | ||
| ) | ||
| loaded_weights = loader.load_weights(weights, | ||
| mapper=self.hf_to_vllm_mapper) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.