Skip to content

Commit fb67914

Browse files
committed
Add MoE verification for multi-modal models
Signed-off-by: shen-shanshan <[email protected]>
1 parent ec98320 commit fb67914

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

vllm_ascend/utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,24 @@ def prefill_context_parallel_enable() -> bool:
672672

673673

674674
def is_moe_model(vllm_config: VllmConfig):
675+
"""Checks if the model is a MoE model by config"""
675676
global _IS_MOE_MODEL
676677
if _IS_MOE_MODEL is None:
677-
config = vllm_config.model_config.hf_config
678-
_IS_MOE_MODEL = any('experts' in key.lower()
679-
for key in config.to_dict())
678+
model_configs = vllm_config.model_config.hf_config.to_dict()
679+
_IS_MOE_MODEL = _is_contain_expert(model_configs)
680680
return _IS_MOE_MODEL
681681

682682

683+
def _is_contain_expert(config: dict | str):
684+
if isinstance(config, dict):
685+
for k, v in config.items():
686+
if "expert" in str(k):
687+
return True
688+
if _is_contain_expert(v):
689+
return True
690+
return False
691+
692+
683693
def weak_ref_tensor(tensor: Any) -> Any:
684694
"""
685695
Create a weak reference to a tensor.

0 commit comments

Comments
 (0)