[Bugfix] LoRA for DeepSeek V3.2 (#35077)
Signed-off-by: Hollow Man <hollowman@opensuse.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Jee Jee Li
parent
04eac6ba24
commit
a250f1bd5f
+25
-3
@@ -73,7 +73,9 @@ def get_lora_id():
|
||||
return _GLOBAL_LORA_ID
|
||||
|
||||
|
||||
_all_lora_classes: set[type[BaseLayerWithLoRA]] = {
|
||||
# Order matters here: more specific wrappers must be checked before generic
|
||||
# merged/column-parallel wrappers in from_layer().
|
||||
_all_lora_classes: tuple[type[BaseLayerWithLoRA], ...] = (
|
||||
VocabParallelEmbeddingWithLoRA,
|
||||
ColumnParallelLinearWithLoRA,
|
||||
MergedColumnParallelLinearWithLoRA,
|
||||
@@ -90,7 +92,7 @@ _all_lora_classes: set[type[BaseLayerWithLoRA]] = {
|
||||
RowParallelLinearWithShardedLoRA,
|
||||
FusedMoEWithLoRA,
|
||||
FusedMoE3DWithLoRA,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def is_moe_model(model: nn.Module) -> bool:
|
||||
@@ -258,6 +260,7 @@ def is_supported_lora_module(
|
||||
def is_in_target_modules(
|
||||
module_name: str,
|
||||
target_modules: list[str] | None,
|
||||
packed_modules_mapping: dict[str, list[str]] | None = None,
|
||||
) -> bool:
|
||||
"""Check if a module passes the deployment-time target_modules filter.
|
||||
|
||||
@@ -268,14 +271,33 @@ def is_in_target_modules(
|
||||
module_name: Full dot-separated module name.
|
||||
target_modules: Optional deployment-time restriction list from
|
||||
LoRAConfig.target_modules.
|
||||
packed_modules_mapping: Optional model-defined mapping from packed
|
||||
runtime module names to their adapter-visible submodule names
|
||||
(e.g. ``{"gate_up_proj": ["gate_proj", "up_proj"]}``).
|
||||
|
||||
Returns:
|
||||
True if the module passes the filter, False otherwise.
|
||||
"""
|
||||
if target_modules is None:
|
||||
return True
|
||||
target_module_set = set(target_modules)
|
||||
module_suffix = module_name.split(".")[-1]
|
||||
return module_suffix in set(target_modules)
|
||||
if module_suffix in target_module_set or module_name in target_module_set:
|
||||
return True
|
||||
|
||||
if not packed_modules_mapping:
|
||||
return False
|
||||
|
||||
# Runtime packed parent matched by deployment-time child targets.
|
||||
packed_children = packed_modules_mapping.get(module_suffix)
|
||||
if packed_children and any(child in target_module_set for child in packed_children):
|
||||
return True
|
||||
|
||||
# Adapter-visible packed child matched by deployment-time parent target.
|
||||
return any(
|
||||
module_suffix in children and packed_parent in target_module_set
|
||||
for packed_parent, children in packed_modules_mapping.items()
|
||||
)
|
||||
|
||||
|
||||
def get_adapter_absolute_path(lora_path: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user