[LoRA] Avoid false target matches for unsupported module types (#52313)

Signed-off-by: linitra24 <Joy25810@foxmail.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
linitra24
2026-08-19 16:48:11 +00:00
committed by GitHub
co-authored by Jee Jee Li
parent 0c8c3f41cf
commit 9b5f3454f2
3 changed files with 39 additions and 51 deletions
+18 -4
View File
@@ -418,7 +418,16 @@ class LoRAModelManager:
if isinstance(module, PPMissingLayer):
continue
if not self._match_target_modules(module_name):
target_modules = self.lora_config.target_modules
is_configured_target = target_modules is not None and is_in_target_modules(
module_name,
target_modules,
self.packed_modules_mapping,
)
if (
not self._match_target_modules(module_name, module)
and not is_configured_target
):
continue
punica_wrapper = self._get_punica_wrapper(module_name)
@@ -565,7 +574,7 @@ class LoRAModelManager:
model = LoRAModel(lora_id, rank, {})
for module_name, module in self.model.named_modules():
if (
not self._match_target_modules(module_name)
not self._match_target_modules(module_name, module)
or not isinstance(module, BaseLayerWithLoRA)
or self._get_punica_wrapper(module_name) is None
):
@@ -701,7 +710,7 @@ class LoRAModelManager:
)
return adjusted_rank
def _match_target_modules(self, module_name: str) -> bool:
def _match_target_modules(self, module_name: str, module: nn.Module) -> bool:
"""Check if a module should have LoRA applied.
This method first checks if the module is in vLLM's supported LoRA
@@ -711,11 +720,16 @@ class LoRAModelManager:
Args:
module_name: Full dot-separated module name (e.g.,
"model.layers.0.self_attn.o_proj")
module: Runtime module associated with ``module_name``.
Returns:
True if LoRA should be applied to this module, False otherwise.
"""
if not is_supported_lora_module(module_name, self.supported_lora_modules):
if not is_supported_lora_module(
module_name,
module,
self.supported_lora_modules,
):
return False
return is_in_target_modules(
module_name,