Skip to content
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Suggested PR Title:

[Config][Misc] Remove msMonitor daemon environment variable

Suggested PR Summary:

### What this PR does / why we need it?

Removes the legacy `MSMONITOR_USE_DAEMON` environment variable after its behavior was migrated to `additional_config.msmonitor_use_daemon`. Runtime code, deployment examples, test configurations, and documentation are migrated to the config field where applicable.

### Does this PR introduce _any_ user-facing change?

Yes. `MSMONITOR_USE_DAEMON` is no longer read. Users must configure the behavior with `--additional-config '{"msmonitor_use_daemon":true}'`.

### How was this patch tested?

- Unit tests in `tests/ut/test_ascend_config.py` and `tests/ut/profiler/test_torch_npu_profiler.py`
- Ruff check and formatting
References
  1. The repository style guide requires providing a suggested PR Title and PR Summary in markdown code blocks. (link)

| `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. |
Expand Down
22 changes: 6 additions & 16 deletions tests/ut/profiler/test_torch_npu_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down Expand Up @@ -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",
Expand All @@ -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")
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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),
)

Expand Down
11 changes: 11 additions & 0 deletions tests/ut/test_ascend_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Comment on lines +506 to +512

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The existing unit tests test_migrated_config_falls_back_to_envs (around line 409) and test_migrated_config_overrides_envs (around line 461) still reference MSMONITOR_USE_DAEMON and assert fallback/override behaviors for it.

Since MSMONITOR_USE_DAEMON has been completely removed from vllm_ascend/envs.py and vllm_ascend/ascend_config.py, test_migrated_config_falls_back_to_envs will now fail because msmonitor_use_daemon will evaluate to False instead of falling back to True.

Please clean up the legacy MSMONITOR_USE_DAEMON references and assertions from those two existing tests to prevent test failures.


@_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):
Expand Down
7 changes: 1 addition & 6 deletions vllm_ascend/ascend_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions vllm_ascend/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions vllm_ascend/profiler/torch_npu_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
Expand Down
Loading