[Misc] Make it simpler to replace out-of-tree layer classes with related LoRA layers. (#42306)

Signed-off-by: paulyu12 <507435917@qq.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
yupeng
2026-05-15 15:20:42 +08:00
committed by GitHub
co-authored by Jee Jee Li
parent 2676ab1e0b
commit 31fa757cf9
2 changed files with 13 additions and 4 deletions
+8 -2
View File
@@ -422,7 +422,10 @@ class QKVParallelLinearWithLoRA(ColumnParallelLinearWithLoRA):
packed_modules_list: list,
model_config: PretrainedConfig | None = None,
) -> bool:
return type(source_layer) is QKVParallelLinear and len(packed_modules_list) == 1
return (
type(source_layer) is maybe_get_oot_by_class(QKVParallelLinear)
and len(packed_modules_list) == 1
)
class MergedQKVParallelLinearWithLoRA(MergedColumnParallelLinearWithLoRA):
@@ -480,7 +483,10 @@ class MergedQKVParallelLinearWithLoRA(MergedColumnParallelLinearWithLoRA):
packed_modules_list: list,
model_config: PretrainedConfig | None = None,
) -> bool:
return type(source_layer) is QKVParallelLinear and len(packed_modules_list) == 3
return (
type(source_layer) is maybe_get_oot_by_class(QKVParallelLinear)
and len(packed_modules_list) == 3
)
# These following layers are based on the tensor parallelism strategy given in