diff --git a/vllm/lora/model_manager.py b/vllm/lora/model_manager.py index d19bf311a1..a8ade6969f 100644 --- a/vllm/lora/model_manager.py +++ b/vllm/lora/model_manager.py @@ -418,16 +418,14 @@ class LoRAModelManager: if isinstance(module, PPMissingLayer): continue - 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 - ): + if self.lora_config.target_modules is None: + if not is_supported_lora_module( + module_name, + module, + self.supported_lora_modules, + ): + continue + elif not self._match_target_modules(module_name): continue punica_wrapper = self._get_punica_wrapper(module_name) @@ -574,7 +572,12 @@ class LoRAModelManager: model = LoRAModel(lora_id, rank, {}) for module_name, module in self.model.named_modules(): if ( - not self._match_target_modules(module_name, module) + not is_supported_lora_module( + module_name, + module, + self.supported_lora_modules, + ) + or not self._match_target_modules(module_name) or not isinstance(module, BaseLayerWithLoRA) or self._get_punica_wrapper(module_name) is None ): @@ -710,27 +713,16 @@ class LoRAModelManager: ) return adjusted_rank - 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 - modules, then applies deployment-time restrictions based on - LoRAConfig.target_modules. + def _match_target_modules(self, module_name: str) -> bool: + """Check if a module passes the deployment-time target filter. 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. + True if the module passes the filter, False otherwise. """ - if not is_supported_lora_module( - module_name, - module, - self.supported_lora_modules, - ): - return False return is_in_target_modules( module_name, self.lora_config.target_modules,