Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions vllm_ascend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,24 @@ def prefill_context_parallel_enable() -> bool:


def is_moe_model(vllm_config: VllmConfig):
"""Checks if the model is a MoE model by config"""
global _IS_MOE_MODEL
if _IS_MOE_MODEL is None:
config = vllm_config.model_config.hf_config
_IS_MOE_MODEL = any('experts' in key.lower()
for key in config.to_dict())
model_configs = vllm_config.model_config.hf_config.to_dict()
_IS_MOE_MODEL = _is_contain_expert(model_configs)
return _IS_MOE_MODEL


def _is_contain_expert(config: Any):
if isinstance(config, dict):
for k, v in config.items():
if "expert" in str(k):
return True
if _is_contain_expert(v):
return True
return False


def weak_ref_tensor(tensor: Any) -> Any:
"""
Create a weak reference to a tensor.
Expand Down
Loading