Skip to content

Commit 0be4c1b

Browse files
ericperfectweilong.yu
authored andcommitted
[Model][LoRA]LoRA support added for Qwen2VLForConditionalGeneration (vllm-project#10022)
Signed-off-by: ericperfect <[email protected]>
1 parent 07054e2 commit 0be4c1b

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

docs/source/models/supported_models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ Text Generation
540540
- Qwen2-VL
541541
- T + I\ :sup:`E+` + V\ :sup:`+`
542542
- :code:`Qwen/Qwen2-VL-2B-Instruct`, :code:`Qwen/Qwen2-VL-7B-Instruct`, :code:`Qwen/Qwen2-VL-72B-Instruct`, etc.
543-
-
543+
- ✅︎
544544
- ✅︎
545545
* - :code:`UltravoxModel`
546546
- Ultravox

vllm/model_executor/models/qwen2_vl.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
from vllm.attention import AttentionMetadata
4242
from vllm.attention.selector import _Backend
43-
from vllm.config import CacheConfig, MultiModalConfig
43+
from vllm.config import CacheConfig, LoRAConfig, MultiModalConfig
4444
from vllm.distributed import get_pp_group, parallel_state
4545
from vllm.distributed import utils as dist_utils
4646
from vllm.inputs import (INPUT_REGISTRY, DecoderOnlyInputs, DummyData,
@@ -65,7 +65,7 @@
6565
from vllm.transformers_utils.config import uses_mrope
6666
from vllm.transformers_utils.processor import cached_get_processor
6767

68-
from .interfaces import SupportsMultiModal, SupportsPP
68+
from .interfaces import SupportsLoRA, SupportsMultiModal, SupportsPP
6969
from .utils import (PPMissingLayer, get_vit_attn_backend,
7070
is_pp_missing_parameter,
7171
make_empty_intermediate_tensors_factory)
@@ -927,13 +927,37 @@ def input_processor_for_qwen2_vl(
927927
@INPUT_REGISTRY.register_dummy_data(dummy_data_for_qwen2_vl)
928928
@INPUT_REGISTRY.register_input_processor(input_processor_for_qwen2_vl)
929929
class Qwen2VLForConditionalGeneration(nn.Module, SupportsMultiModal,
930-
SupportsPP):
930+
SupportsLoRA, SupportsPP):
931+
packed_modules_mapping = {
932+
"qkv_proj": [
933+
"q_proj",
934+
"k_proj",
935+
"v_proj",
936+
],
937+
"gate_up_proj": [
938+
"gate_proj",
939+
"up_proj",
940+
],
941+
}
942+
943+
# LoRA specific attributes
944+
# TODO Support LoRA for the visual encoder in the future.
945+
supported_lora_modules = [
946+
"qkv_proj",
947+
"o_proj",
948+
"gate_up_proj",
949+
"down_proj",
950+
]
951+
embedding_modules = {}
952+
embedding_padding_modules = []
931953

932954
def __init__(self,
933955
config: Qwen2VLConfig,
934956
multimodal_config: MultiModalConfig,
935957
cache_config: Optional[CacheConfig] = None,
936-
quant_config: Optional[QuantizationConfig] = None) -> None:
958+
quant_config: Optional[QuantizationConfig] = None,
959+
lora_config: Optional[LoRAConfig] = None) -> None:
960+
937961
super().__init__()
938962

939963
assert not cache_config.enable_prefix_caching, \

0 commit comments

Comments
 (0)