diff --git a/tests/ut/eplb/core/test_eplb_utils.py b/tests/ut/eplb/core/test_eplb_utils.py index 29ee4276..0d73c7a3 100644 --- a/tests/ut/eplb/core/test_eplb_utils.py +++ b/tests/ut/eplb/core/test_eplb_utils.py @@ -128,7 +128,7 @@ class TestEPLBParamUtils: with pytest.raises( ValueError, match= - 'Can not enable dynamic_eplb when not export DYNAMIC_EPLB="true".' + 'Can not enable dynamic_eplb when DYNAMIC_EPLB is not set to "true" or "1".' ): EPLBParamUtils.check_dynamic_eplb(True) @@ -136,7 +136,7 @@ class TestEPLBParamUtils: with pytest.raises( ValueError, match= - 'Can not enable dynamic_eplb when not export DYNAMIC_EPLB="true".' + 'Can not enable dynamic_eplb when DYNAMIC_EPLB is not set to "true" or "1".' ): EPLBParamUtils.check_dynamic_eplb(True) @@ -144,7 +144,7 @@ class TestEPLBParamUtils: with pytest.raises( ValueError, match= - 'Can not enable dynamic_eplb when not export DYNAMIC_EPLB="true".' + 'Can not enable dynamic_eplb when DYNAMIC_EPLB is not set to "true" or "1".' ): EPLBParamUtils.check_dynamic_eplb(True) @@ -152,6 +152,12 @@ class TestEPLBParamUtils: monkeypatch.setenv("DYNAMIC_EPLB", "true") EPLBParamUtils.check_dynamic_eplb(True) + monkeypatch.setenv("DYNAMIC_EPLB", "True") + EPLBParamUtils.check_dynamic_eplb(True) + + monkeypatch.setenv("DYNAMIC_EPLB", "1") + EPLBParamUtils.check_dynamic_eplb(True) + def test_check_expert_map_path_none(self): EPLBParamUtils.check_expert_map_path(None) diff --git a/vllm_ascend/envs.py b/vllm_ascend/envs.py index c1934f3d..f2877a46 100644 --- a/vllm_ascend/envs.py +++ b/vllm_ascend/envs.py @@ -172,7 +172,10 @@ env_variables: Dict[str, Callable[[], Any]] = { lambda: int(os.getenv("VLLM_ASCEND_ENABLE_NZ", 1)), # Decide whether we should enable CP parallelism. "VLLM_ASCEND_ENABLE_CONTEXT_PARALLEL": - lambda: bool(int(os.getenv("VLLM_ASCEND_ENABLE_CONTEXT_PARALLEL", '0'))) + lambda: bool(int(os.getenv("VLLM_ASCEND_ENABLE_CONTEXT_PARALLEL", '0'))), + # Whether to anbale dynamic EPLB + "DYNAMIC_EPLB": + lambda: os.getenv("DYNAMIC_EPLB", "false").lower(), } # end-env-vars-definition diff --git a/vllm_ascend/eplb/core/eplb_utils.py b/vllm_ascend/eplb/core/eplb_utils.py index 0a558682..4e9c56c9 100644 --- a/vllm_ascend/eplb/core/eplb_utils.py +++ b/vllm_ascend/eplb/core/eplb_utils.py @@ -22,6 +22,8 @@ import sys import torch from vllm.logger import logger +import vllm_ascend.envs as envs_ascend + def determine_default_expert_map(global_expert_num, world_size, rank_id, global_redundant_expert_num): @@ -140,9 +142,10 @@ class EPLBParamUtils: return if not isinstance(dynamic_eplb, bool): raise TypeError("The dynamic_eplb is not bool.") - if dynamic_eplb and os.getenv("DYNAMIC_EPLB", "false") != "true": + + if dynamic_eplb and envs_ascend.DYNAMIC_EPLB not in ("true", "1"): raise ValueError( - 'Can not enable dynamic_eplb when not export DYNAMIC_EPLB="true".' + 'Can not enable dynamic_eplb when DYNAMIC_EPLB is not set to "true" or "1".' ) @staticmethod diff --git a/vllm_ascend/patch/platform/__init__.py b/vllm_ascend/patch/platform/__init__.py index b4ef6332..4f6c2851 100644 --- a/vllm_ascend/patch/platform/__init__.py +++ b/vllm_ascend/patch/platform/__init__.py @@ -16,11 +16,12 @@ import os +import vllm_ascend.envs as envs_ascend import vllm_ascend.patch.platform.patch_config # noqa import vllm_ascend.patch.platform.patch_distributed # noqa import vllm_ascend.patch.platform.patch_mamba_config # noqa import vllm_ascend.patch.platform.patch_sched_yield # noqa -if os.getenv("DYNAMIC_EPLB", "false") == "true" or os.getenv( +if envs_ascend.DYNAMIC_EPLB not in ("true", "1") or os.getenv( "EXPERT_MAP_RECORD", "false") == "true": import vllm_ascend.patch.platform.patch_multiproc_executor # noqa