diff --git a/docs/source/user_guide/configuration/additional_config.md b/docs/source/user_guide/configuration/additional_config.md index 2a066902d91..2c73434ef42 100644 --- a/docs/source/user_guide/configuration/additional_config.md +++ b/docs/source/user_guide/configuration/additional_config.md @@ -83,7 +83,7 @@ The following table lists additional configuration options available in vLLM Asc | `enable_prefill_mc2` | bool | `False` | Whether to reserve mc2_token_capacity for prefill batches. When enabled, `max_num_batched_tokens` is used to calculate the mc2_token_capacity instead of the decode-only capacity. In this scenario, the recommended maximum value of `max_num_batched_tokens` is `tp_size * 512`. This is a temporary switch; once MC2 operators are complete for all scenarios, this switch will be removed and MC2 will be enabled by default. | | `mega_moe_max_tokens` | int | `65536` | Per-rank token capacity after dispatch in the mega moe (dispatch_ffn_combine) fused operator. When load imbalance causes a rank to receive more tokens than this limit, the excess tokens are dropped and skipped from computation, degrading accuracy. Do not set this too large: workspace memory scales linearly with this value. | | `enable_flashcomm1` | bool | `False` | Whether to enable FlashComm1 optimization. Can also be configured via the `VLLM_ASCEND_ENABLE_FLASHCOMM1` environment variable during the migration period. | -| `msmonitor_use_daemon` | bool | `False` | Whether to use daemon mode for msmonitor. Can also be configured via the `MSMONITOR_USE_DAEMON` environment variable during the migration period. | +| `msmonitor_use_daemon` | bool | `False` | Whether to use daemon mode for msmonitor. The legacy `MSMONITOR_USE_DAEMON` environment variable is no longer supported. | | `enable_mlapo` | bool | `True` | Whether to enable MLAPO (Model Layer-wise Adaptive Parallel Optimization). Can also be configured via the `VLLM_ASCEND_ENABLE_MLAPO` environment variable during the migration period. | | `weight_nz_mode` | int | `1` | Weight NZ mode. Can also be configured via the `VLLM_ASCEND_ENABLE_NZ` environment variable during the migration period. | | `enable_fused_mc2` | int | `0` | Fused MC2 configuration. Can also be configured via the `VLLM_ASCEND_ENABLE_FUSED_MC2` environment variable during the migration period. | diff --git a/tests/ut/profiler/test_torch_npu_profiler.py b/tests/ut/profiler/test_torch_npu_profiler.py index fc9d70cbf17..6bdab6889db 100644 --- a/tests/ut/profiler/test_torch_npu_profiler.py +++ b/tests/ut/profiler/test_torch_npu_profiler.py @@ -39,7 +39,6 @@ def test_start_stop_delegate_to_underlying_profiler(self): mock_profiler.start.assert_called_once() mock_profiler.stop.assert_called_once() - @patch("vllm_ascend.profiler.torch_npu_profiler.envs_ascend") @patch("vllm_ascend.profiler.torch_npu_profiler.get_ascend_config") @patch("torch_npu.profiler._ExperimentalConfig") @patch("torch_npu.profiler.profile") @@ -58,11 +57,9 @@ def test_create_profiler_enabled( mock_profile, mock_experimental_config, mock_get_ascend_config, - mock_envs_ascend, ): from vllm_ascend.profiler.torch_npu_profiler import TorchNPUProfilerWrapper - mock_envs_ascend.MSMONITOR_USE_DAEMON = 0 mock_get_ascend_config.side_effect = RuntimeError("Ascend config is not initialized") profiler_config = ProfilerConfig( @@ -139,13 +136,11 @@ def test_create_profiler_empty_dir(self): self.assertIn("torch_profiler_dir cannot be empty", str(cm.exception)) - @patch("vllm_ascend.profiler.torch_npu_profiler.envs_ascend") @patch("vllm_ascend.profiler.torch_npu_profiler.get_ascend_config") - def test_create_profiler_raises_when_msmonitor_env_enabled(self, mock_get_ascend_config, mock_envs_ascend): + def test_create_profiler_raises_when_msmonitor_enabled(self, mock_get_ascend_config): from vllm_ascend.profiler.torch_npu_profiler import TorchNPUProfilerWrapper - mock_envs_ascend.MSMONITOR_USE_DAEMON = 1 - mock_get_ascend_config.side_effect = RuntimeError("Ascend config is not initialized") + mock_get_ascend_config.return_value = MagicMock(msmonitor_use_daemon=True) profiler_config = ProfilerConfig( profiler="torch", torch_profiler_dir="/path/to/traces", @@ -155,11 +150,10 @@ def test_create_profiler_raises_when_msmonitor_env_enabled(self, mock_get_ascend TorchNPUProfilerWrapper._create_profiler(profiler_config, "test_trace") self.assertIn( - "MSMONITOR_USE_DAEMON and torch profiler cannot be both enabled at the same time.", + "additional_config.msmonitor_use_daemon and torch profiler cannot be enabled at the same time.", str(cm.exception), ) - @patch("vllm_ascend.profiler.torch_npu_profiler.envs_ascend") @patch("torch_npu.profiler._ExperimentalConfig") @patch("torch_npu.profiler.profile") @patch("torch_npu.profiler.tensorboard_trace_handler") @@ -168,7 +162,7 @@ def test_create_profiler_raises_when_msmonitor_env_enabled(self, mock_get_ascend @patch("torch_npu.profiler.AiCMetrics") @patch("torch_npu.profiler.ProfilerActivity") @patch("vllm_ascend.profiler.torch_npu_profiler.get_ascend_config") - def test_create_profiler_config_overrides_msmonitor_env( + def test_create_profiler_with_msmonitor_disabled( self, mock_get_ascend_config, mock_profiler_activity, @@ -178,11 +172,9 @@ def test_create_profiler_config_overrides_msmonitor_env( mock_trace_handler, mock_profile, mock_experimental_config, - mock_envs_ascend, ): from vllm_ascend.profiler.torch_npu_profiler import TorchNPUProfilerWrapper - mock_envs_ascend.MSMONITOR_USE_DAEMON = 1 mock_ascend_config = MagicMock() mock_ascend_config.msmonitor_use_daemon = False mock_get_ascend_config.return_value = mock_ascend_config @@ -202,12 +194,10 @@ def test_create_profiler_config_overrides_msmonitor_env( mock_profile.assert_called_once() - @patch("vllm_ascend.profiler.torch_npu_profiler.envs_ascend") @patch("vllm_ascend.profiler.torch_npu_profiler.get_ascend_config") - def test_create_profiler_config_enables_msmonitor_over_env(self, mock_get_ascend_config, mock_envs_ascend): + def test_create_profiler_config_enables_msmonitor(self, mock_get_ascend_config): from vllm_ascend.profiler.torch_npu_profiler import TorchNPUProfilerWrapper - mock_envs_ascend.MSMONITOR_USE_DAEMON = 0 mock_ascend_config = MagicMock() mock_ascend_config.msmonitor_use_daemon = True mock_get_ascend_config.return_value = mock_ascend_config @@ -220,7 +210,7 @@ def test_create_profiler_config_enables_msmonitor_over_env(self, mock_get_ascend TorchNPUProfilerWrapper._create_profiler(profiler_config, "test_trace") self.assertIn( - "MSMONITOR_USE_DAEMON and torch profiler cannot be both enabled at the same time.", + "additional_config.msmonitor_use_daemon and torch profiler cannot be enabled at the same time.", str(cm.exception), ) diff --git a/tests/ut/test_ascend_config.py b/tests/ut/test_ascend_config.py index e00436200b7..d31cbde0a82 100644 --- a/tests/ut/test_ascend_config.py +++ b/tests/ut/test_ascend_config.py @@ -196,6 +196,7 @@ def test_init_ascend_config_without_additional_config(self, mock_fix_incompatibl ascend_config = init_ascend_config(test_vllm_config) self.assertFalse(ascend_config.multistream_overlap_shared_expert) self.assertFalse(ascend_config.enable_kv_nz) + self.assertFalse(ascend_config.msmonitor_use_daemon) ascend_compilation_config = ascend_config.ascend_compilation_config self.assertTrue(ascend_compilation_config.fuse_norm_quant) @@ -500,6 +501,16 @@ def test_enable_flashcomm1_config_overrides_disabled_env(self, mock_fix_incompat self.assertTrue(ascend_config.enable_flashcomm1) self.assertTrue(enable_sp(test_vllm_config)) + @_clean_up_ascend_config + @patch("vllm_ascend.platform.NPUPlatform.check_and_update_config") + def test_msmonitor_daemon_ignores_removed_env(self, mock_fix_incompatible_config): + test_vllm_config = VllmConfig() + test_vllm_config.additional_config = {"msmonitor_use_daemon": False} + with patch.dict(os.environ, {"MSMONITOR_USE_DAEMON": "1"}): + ascend_config = init_ascend_config(test_vllm_config) + + self.assertFalse(ascend_config.msmonitor_use_daemon) + @_clean_up_ascend_config @patch("vllm_ascend.platform.NPUPlatform.check_and_update_config") def test_enable_sp_falls_back_to_env_without_current_config(self, mock_check_and_update_config): diff --git a/vllm_ascend/ascend_config.py b/vllm_ascend/ascend_config.py index d30e74fa0fe..3fcf2c8cf4f 100644 --- a/vllm_ascend/ascend_config.py +++ b/vllm_ascend/ascend_config.py @@ -188,12 +188,7 @@ def __init__(self, vllm_config: "VllmConfig"): "VLLM_ASCEND_ENABLE_MLAPO", ascend_envs.VLLM_ASCEND_ENABLE_MLAPO, ) - self.msmonitor_use_daemon = self._get_config_value( - additional_config, - "msmonitor_use_daemon", - "MSMONITOR_USE_DAEMON", - ascend_envs.MSMONITOR_USE_DAEMON, - ) + self.msmonitor_use_daemon = additional_config.get("msmonitor_use_daemon", False) self.enable_transpose_kv_cache_by_block = self._get_config_value( additional_config, "enable_transpose_kv_cache_by_block", diff --git a/vllm_ascend/envs.py b/vllm_ascend/envs.py index f6a111d5c97..ebac2ace818 100644 --- a/vllm_ascend/envs.py +++ b/vllm_ascend/envs.py @@ -70,8 +70,6 @@ # This feature will get better performance when concurrency is large. # DEPRECATED: use additional_config.enable_flashcomm1 instead. "VLLM_ASCEND_ENABLE_FLASHCOMM1": lambda: bool(int(os.getenv("VLLM_ASCEND_ENABLE_FLASHCOMM1", "0"))), - # Whether to enable msMonitor tool to monitor the performance of vllm-ascend. - "MSMONITOR_USE_DAEMON": lambda: bool(int(os.getenv("MSMONITOR_USE_DAEMON", "0"))), # Whether to enable MLAPO optimization for DeepSeek W8A8 series models. # This option is enabled by default. MLAPO can improve performance, but # it will consume more NPU memory. If reducing NPU memory usage is a higher priority diff --git a/vllm_ascend/profiler/torch_npu_profiler.py b/vllm_ascend/profiler/torch_npu_profiler.py index e84d817c4bd..2f5c09c68f6 100644 --- a/vllm_ascend/profiler/torch_npu_profiler.py +++ b/vllm_ascend/profiler/torch_npu_profiler.py @@ -23,7 +23,6 @@ from vllm.config import ProfilerConfig from vllm.profiler.wrapper import WorkerProfiler -import vllm_ascend.envs as envs_ascend from vllm_ascend.ascend_config import get_ascend_config @@ -40,11 +39,13 @@ def _create_profiler(profiler_config: ProfilerConfig, trace_name: str) -> Any: raise RuntimeError(f"Unrecognized profiler: {profiler_config.profiler}") if not profiler_config.torch_profiler_dir: raise RuntimeError("torch_profiler_dir cannot be empty.") - msmonitor_use_daemon = envs_ascend.MSMONITOR_USE_DAEMON + msmonitor_use_daemon = False with suppress(RuntimeError): msmonitor_use_daemon = get_ascend_config().msmonitor_use_daemon if msmonitor_use_daemon: - raise RuntimeError("MSMONITOR_USE_DAEMON and torch profiler cannot be both enabled at the same time.") + raise RuntimeError( + "additional_config.msmonitor_use_daemon and torch profiler cannot be enabled at the same time." + ) experimental_config = torch_npu.profiler._ExperimentalConfig( export_type=torch_npu.profiler.ExportType.Text,