From 67dd3a4581b0c029c0f56d1c427f1e3a9a1a9c7c Mon Sep 17 00:00:00 2001 From: Meihan-chen Date: Thu, 30 Oct 2025 15:52:53 +0800 Subject: [PATCH] [UT] fix skip ut test for test_utils (#3803) ### What this PR does / why we need it? [UT] fix ut test for test_utils that https://github.com/vllm-project/vllm-ascend/pull/3612 skipped. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? vLLM version: v0.11.0rc3 vLLM main: https://github.com/vllm-project/vllm/commit/17c540a993af88204ad1b78345c8a865cf58ce44 - vLLM version: v0.11.0rc3 - vLLM main: https://github.com/vllm-project/vllm/commit/83f478bb19489b41e9d208b47b4bb5a95ac171ac --------- Signed-off-by: Meihan-chen --- .github/workflows/vllm_ascend_test.yaml | 4 +--- tests/ut/test_platform.py | 2 +- tests/ut/test_utils.py | 27 +++++++++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/vllm_ascend_test.yaml b/.github/workflows/vllm_ascend_test.yaml index 8293e55b..23fb6ea6 100644 --- a/.github/workflows/vllm_ascend_test.yaml +++ b/.github/workflows/vllm_ascend_test.yaml @@ -120,9 +120,7 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux/devlib pytest -sv --cov --cov-report=xml:unittests-coverage.xml tests/ut \ --ignore tests/ut/torchair/models/test_torchair_deepseek_mtp.py \ - --ignore tests/ut/torchair/models/test_torchair_deepseek_v2.py \ - --ignore tests/ut/test_utils.py \ - --ignore tests/ut/test_platform.py + --ignore tests/ut/torchair/models/test_torchair_deepseek_v2.py - name: Upload coverage to Codecov # only upload coverage when commits merged diff --git a/tests/ut/test_platform.py b/tests/ut/test_platform.py index 34a189e0..d5d43098 100644 --- a/tests/ut/test_platform.py +++ b/tests/ut/test_platform.py @@ -359,7 +359,7 @@ class TestNPUPlatform(TestBase): if vllm_version_is("0.11.0"): self.assertEqual( vllm_config.compilation_config.level, - CompilationMode.NONE, + CompilationLevel.NO_COMPILATION, ) else: self.assertEqual( diff --git a/tests/ut/test_utils.py b/tests/ut/test_utils.py index 18479d3b..147e8378 100644 --- a/tests/ut/test_utils.py +++ b/tests/ut/test_utils.py @@ -29,6 +29,12 @@ from vllm_ascend.utils import REGISTERED_ASCEND_OPS class TestUtils(TestBase): + def setUp(self): + import importlib + + from vllm_ascend import platform + importlib.reload(platform) + def test_is_310p(self): utils._IS_310P = None with mock.patch("vllm_ascend._build_info.__soc_version__", @@ -252,16 +258,12 @@ class TestUtils(TestBase): self.assertIn("num_hidden_layers", str(context.exception)) def test_update_aclgraph_sizes(self): - # max_num_batch_sizes < len(original_sizes) test_compilation_config = CompilationConfig( cudagraph_capture_sizes=[i for i in range(150)]) model_path = os.path.join(os.path.dirname(__file__), "fake_weight") test_model_config = ModelConfig(model=model_path, enforce_eager=True) test_parallel_config = ParallelConfig() - ascend_config = mock.MagicMock() - ascend_config.max_num_batched_tokens = 2048 - ascend_config.max_model_len = 1024 - ascend_config.ascend_scheduler_config.enabled = False + ascend_config = {"ascend_scheduler_config": {"enabled": False}} test_vllm_config = VllmConfig( model_config=test_model_config, compilation_config=test_compilation_config, @@ -271,9 +273,18 @@ class TestUtils(TestBase): os.environ['HCCL_OP_EXPANSION_MODE'] = 'AIV' utils.update_aclgraph_sizes(test_vllm_config) del os.environ['HCCL_OP_EXPANSION_MODE'] - self.assertEqual( - 137, - len(test_vllm_config.compilation_config.cudagraph_capture_sizes)) + + if utils.vllm_version_is("0.11.0"): + self.assertEqual( + 137, + len(test_vllm_config.compilation_config.cudagraph_capture_sizes + )) + else: + self.assertEqual( + 0, + len(test_vllm_config.compilation_config.cudagraph_capture_sizes + )) + return test_vllm_config.speculative_config = mock.MagicMock() test_vllm_config.speculative_config.num_speculative_tokens = 2