From c848da0687a1f74df5c8dcf33f577fa20491dd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E6=B4=BE=E6=9E=9C=E5=A5=B6=E6=88=91=E8=BF=98?= =?UTF-8?q?=E8=A6=81?= <47294568+845473182@users.noreply.github.com> Date: Wed, 19 Nov 2025 21:31:58 +0800 Subject: [PATCH] [Bugfix] fix nightly multi-node EPLB tests' "DYNAMIC_EPLB=true" environment not working (#4223) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What this PR does / why we need it? fix nightly multi-node EPLB tests by adjusting vllm_ascend\eplb\core\eplb_utils.py dynamic_eplb gate checking ### Does this PR introduce _any_ user-facing change? no - vLLM version: v0.11.0 - vLLM main: https://github.com/vllm-project/vllm/commit/2918c1b49c88c29783c86f78d2c4221cb9622379 --------- Signed-off-by: 白永斌 Signed-off-by: 欧派果奶我还要 <47294568+845473182@users.noreply.github.com> Co-authored-by: 白永斌 Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- tests/ut/eplb/core/test_eplb_utils.py | 12 +++++++++--- vllm_ascend/envs.py | 5 ++++- vllm_ascend/eplb/core/eplb_utils.py | 7 +++++-- vllm_ascend/patch/platform/__init__.py | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) 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