[Bugfix][LoRA] Validate incompatible MoE adapter formats (#59924)
Signed-off-by: Brian Weston <brianweston@gmail.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: linitra24 <renshuang.zhou@daocloud.io>
This commit is contained in:
co-authored by
Codex
Jee Jee Li
linitra24
parent
581692cc0f
commit
201e537d98
@@ -414,6 +414,7 @@ class LoRAModelManager:
|
||||
pass
|
||||
|
||||
def _add_adapter(self, lora: LoRAModel):
|
||||
self._validate_moe_lora_format(lora)
|
||||
self._create_merged_loras_inplace(lora)
|
||||
self._registered_adapters[lora.id] = lora
|
||||
|
||||
@@ -1252,6 +1253,27 @@ class LoRAModelManager:
|
||||
)
|
||||
return weights
|
||||
|
||||
def _validate_moe_lora_format(self, lora_model: LoRAModel) -> None:
|
||||
if self._enable_mixed_moe_lora_format and getattr(
|
||||
lora_model, "is_3d_lora_weight", False
|
||||
):
|
||||
return
|
||||
for module_name, module in self.modules.items():
|
||||
if not isinstance(module, FusedMoEWithLoRA) or isinstance(
|
||||
module, FusedMoE3DWithLoRA
|
||||
):
|
||||
continue
|
||||
module_lora = self._get_lora_layer_weights(lora_model, module_name)
|
||||
if module_lora is not None and torch.is_tensor(module_lora.lora_a):
|
||||
raise ValueError(
|
||||
f"LoRA adapter {lora_model.id} contains fused 3D MoE weights "
|
||||
f"for {module_name!r}, but the model uses a 2D MoE LoRA "
|
||||
"wrapper. Start the engine with "
|
||||
"enable_mixed_moe_lora_format=True "
|
||||
"(--enable-mixed-moe-lora-format) and set "
|
||||
"is_3d_lora_weight=True on the LoRA request."
|
||||
)
|
||||
|
||||
def _validate_modules_to_save(self, lora_model: LoRAModel) -> None:
|
||||
if not lora_model.modules_to_save:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user