[Bugfix][LoRA] Use an explicit capability flag for tower connector LoRA (#53092)
Signed-off-by: linitra24 <Joy25810@foxmail.com>
This commit is contained in:
@@ -201,8 +201,8 @@ class LoRAModelManager:
|
||||
self.punica_wrapper_mapping[lm_prefix] = llm_punica_wrapper
|
||||
|
||||
# First, determine if the model supports tower connector LoRA.
|
||||
self.supports_tower_connector_lora = self.supports_mm and hasattr(
|
||||
self.model, "get_num_mm_encoder_tokens"
|
||||
self.supports_tower_connector_lora = (
|
||||
self.supports_mm and self.model.supports_tower_connector_lora
|
||||
)
|
||||
|
||||
# Then, handle the case where the feature is disabled in the config.
|
||||
|
||||
@@ -525,6 +525,8 @@ class Blip2MultiModalProcessor(BaseMultiModalProcessor[Blip2ProcessingInfo]):
|
||||
class Blip2ForConditionalGeneration(
|
||||
nn.Module, SupportsLoRA, SupportsMultiModal, SupportsPP, SupportsQuant
|
||||
):
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -618,6 +618,7 @@ class DotsOCRForCausalLM(nn.Module, SupportsMultiModal, SupportsPP, SupportsLoRA
|
||||
"fc13": ["fc1", "fc3"],
|
||||
}
|
||||
supports_encoder_tp_data = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
|
||||
@@ -524,6 +524,8 @@ class Gemma3ForConditionalGeneration(
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -978,6 +978,7 @@ class Gemma4ForConditionalGeneration(
|
||||
# window instead of dropping them (which would make image attention
|
||||
# causal-only for images larger than the sliding window).
|
||||
mm_prefix_clamp_sliding_window: bool = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
packed_modules_mapping = {
|
||||
"qkv_proj": [
|
||||
|
||||
@@ -1755,6 +1755,7 @@ class Glm4vForConditionalGeneration(
|
||||
)
|
||||
|
||||
supports_encoder_tp_data = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
|
||||
@@ -503,6 +503,8 @@ class Idefics3ForConditionalGeneration(nn.Module, SupportsMultiModal, SupportsLo
|
||||
],
|
||||
}
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -167,6 +167,12 @@ class SupportsMultiModal(SupportsMultiModalEmbeddings, Protocol):
|
||||
`multimodal_config.mm_device_do_normalize`.
|
||||
"""
|
||||
|
||||
supports_tower_connector_lora: ClassVar[bool] = False
|
||||
"""
|
||||
A flag that indicates whether this model supports
|
||||
`lora_config.enable_tower_connector_lora`.
|
||||
"""
|
||||
|
||||
requires_raw_input_tokens: ClassVar[bool] = False
|
||||
"""
|
||||
A flag that indicates this model processes input id tokens
|
||||
|
||||
@@ -553,6 +553,7 @@ class InternVLChatModel(
|
||||
SupportsEncoderCudaGraph,
|
||||
):
|
||||
supports_encoder_tp_data = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
hf_to_vllm_mapper = WeightsMapper(
|
||||
orig_to_new_prefix=dict.fromkeys(
|
||||
|
||||
@@ -1235,6 +1235,8 @@ class BaseKeyeModule(nn.Module, SupportsMultiModal):
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -520,6 +520,8 @@ class LlavaForConditionalGeneration(
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -231,6 +231,7 @@ class LlavaNextMultiModalProcessor(BaseLlavaNextMultiModalProcessor[_I]):
|
||||
class LlavaNextForConditionalGeneration(
|
||||
nn.Module, SupportsLoRA, SupportsMultiModal, SupportsPP
|
||||
):
|
||||
supports_tower_connector_lora = True
|
||||
packed_modules_mapping = {
|
||||
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
|
||||
"gate_up_proj": ["gate_proj", "up_proj"],
|
||||
|
||||
@@ -323,6 +323,8 @@ class LlavaNextVideoForConditionalGeneration(
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("video"):
|
||||
|
||||
@@ -740,6 +740,7 @@ class Llama4ForConditionalGeneration(
|
||||
}
|
||||
|
||||
supports_encoder_tp_data = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
|
||||
@@ -274,6 +274,8 @@ class PaliGemmaForConditionalGeneration(
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -309,6 +309,8 @@ class PixtralForConditionalGeneration(
|
||||
"gate_up_proj": ["gate_proj", "up_proj"],
|
||||
}
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("image"):
|
||||
|
||||
@@ -1256,6 +1256,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
|
||||
supports_encoder_tp_data = True
|
||||
supports_mm_device_do_normalize = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
def iter_mm_grid_thw(
|
||||
self, mm_features: list[MultiModalFeatureSpec]
|
||||
|
||||
@@ -1194,6 +1194,7 @@ class Qwen2VLForConditionalGeneration(
|
||||
|
||||
supports_encoder_tp_data = True
|
||||
supports_mm_device_do_normalize = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
def iter_mm_grid_thw(
|
||||
self, mm_features: list[MultiModalFeatureSpec]
|
||||
|
||||
@@ -361,6 +361,7 @@ class Qwen3ASRForConditionalGeneration(
|
||||
}
|
||||
|
||||
supported_languages = ISO639_1_SUPPORTED_LANGS
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
hf_to_vllm_mapper = WeightsMapper(
|
||||
orig_to_new_prefix={
|
||||
|
||||
@@ -1753,6 +1753,7 @@ class Qwen3VLForConditionalGeneration(
|
||||
}
|
||||
|
||||
supports_encoder_tp_data = True
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
supported_video_pruning_methods = ("evs", "vidcom2")
|
||||
|
||||
|
||||
@@ -610,6 +610,8 @@ class UltravoxModel(nn.Module, SupportsMultiModal, SupportsPP, SupportsLoRA):
|
||||
}
|
||||
)
|
||||
|
||||
supports_tower_connector_lora = True
|
||||
|
||||
@classmethod
|
||||
def get_placeholder_str(cls, modality: str, i: int) -> str | None:
|
||||
if modality.startswith("audio"):
|
||||
|
||||
Reference in New Issue
Block a user