diff --git a/docs/source/tutorials/models/DeepSeekOCR2.md b/docs/source/tutorials/models/DeepSeekOCR2.md index 5b133498a56..158c2d3985d 100644 --- a/docs/source/tutorials/models/DeepSeekOCR2.md +++ b/docs/source/tutorials/models/DeepSeekOCR2.md @@ -124,7 +124,6 @@ Run the following script to execute online inference. #!/bin/sh export VLLM_USE_V1=1 -export VLLM_ASCEND_ENABLE_NZ=0 export TOKENIZERS_PARALLELISM=false export PYTORCH_NPU_ALLOC_CONF="expandable_segments:True" export TASK_QUEUE_ENABLE=1 @@ -140,6 +139,7 @@ vllm serve /root/.cache/DeepSeek-OCR-2 \ --gpu-memory-utilization 0.8 \ --allowed-local-media-path / \ --additional-config '{ + "weight_nz_mode": 0, "enable_cpu_binding": true, "multistream_overlap_shared_expert": true, "ascend_compilation_config": {"fuse_qknorm_rope": false} diff --git a/docs/source/tutorials/models/GLM5.2.md b/docs/source/tutorials/models/GLM5.2.md index 805fc114ce4..9f7eca17ceb 100644 --- a/docs/source/tutorials/models/GLM5.2.md +++ b/docs/source/tutorials/models/GLM5.2.md @@ -1293,7 +1293,6 @@ The 1M context scenarios are validated on Atlas 800 A3 only; the A2 series is no Recommended command: ```shell -export VLLM_ASCEND_ENABLE_NZ=1 export HCCL_OP_EXPANSION_MODE="AIV" export OMP_PROC_BIND=false export OMP_NUM_THREADS=20 @@ -1322,7 +1321,7 @@ vllm serve \ --decode-context-parallel-size 16 \ --cp-kv-cache-interleave-size 128 \ --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY", "cudagraph_capture_sizes": [4, 16, 128]}' \ - --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true, "enable_sparse_li_c8": true, "enable_cpu_binding": true}' \ + --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true, "enable_sparse_li_c8": true, "enable_cpu_binding": true,"weight_nz_mode":1}' \ --speculative-config '{"num_speculative_tokens": 3, "method": "deepseek_mtp", "enforce_eager": true}' \ --quantization ascend \ --enable-expert-parallel \ @@ -1333,7 +1332,7 @@ Key Parameter Descriptions (in addition to [Single-Node Deployment](#5111-single **1M-specific environment variables:** -- `VLLM_ASCEND_ENABLE_NZ=1`: Enables NZ format memory layout for the C8 quantized tensors, required for the 1M context deployment. +- `additional_config.weight_nz_mode=1`: Enables NZ format memory layout for the C8 quantized tensors, required for the 1M context deployment. - `VLLM_WORKER_MULTIPROC_METHOD=spawn`: Uses the spawn start method for multi-process workers (required in this scenario). **1M-specific vllm serve parameters:** @@ -1359,7 +1358,6 @@ export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name -export VLLM_ASCEND_ENABLE_NZ=1 export HCCL_OP_EXPANSION_MODE="AIV" export OMP_PROC_BIND=false export OMP_NUM_THREADS=20 @@ -1392,7 +1390,7 @@ vllm serve \ --decode-context-parallel-size 8 \ --cp-kv-cache-interleave-size 128 \ --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}' \ - --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true}' \ + --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true,"weight_nz_mode":1}' \ --speculative-config '{"num_speculative_tokens": 3, "method": "deepseek_mtp", "enforce_eager": true}' \ --quantization ascend \ --enable-expert-parallel \ @@ -1425,7 +1423,6 @@ export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name -export VLLM_ASCEND_ENABLE_NZ=1 export HCCL_OP_EXPANSION_MODE="AIV" export OMP_PROC_BIND=false export OMP_NUM_THREADS=20 @@ -1459,7 +1456,7 @@ vllm serve \ --decode-context-parallel-size 8 \ --cp-kv-cache-interleave-size 128 \ --enforce-eager \ - --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": true}' \ + --additional-config '{"enable_flashcomm1": true, "enable_dsa_cp": true, "ascend_compilation_config": {"enable_npugraph_ex": true}, "multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": true,"weight_nz_mode":1}' \ --speculative-config '{"num_speculative_tokens": 1, "method": "deepseek_mtp", "enforce_eager": true}' \ --quantization ascend \ --enable-expert-parallel \ @@ -1498,7 +1495,6 @@ export HCCL_IF_IP=$local_ip export GLOO_SOCKET_IFNAME=$nic_name export TP_SOCKET_IFNAME=$nic_name export HCCL_SOCKET_IFNAME=$nic_name -export VLLM_ASCEND_ENABLE_NZ=1 export HCCL_OP_EXPANSION_MODE="AIV" export OMP_PROC_BIND=false export OMP_NUM_THREADS=20 @@ -1532,7 +1528,7 @@ vllm serve \ --decode-context-parallel-size 8 \ --cp-kv-cache-interleave-size 128 \ --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}' \ - --additional-config '{"ascend_compilation_config": {"enable_npugraph_ex": true},"multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": true}' \ + --additional-config '{"ascend_compilation_config": {"enable_npugraph_ex": true},"multistream_overlap_shared_expert": true,"enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": true,"weight_nz_mode":1}' \ --speculative-config '{"num_speculative_tokens": 3, "method": "deepseek_mtp", "enforce_eager": true}' \ --quantization ascend \ --enable-expert-parallel \ diff --git a/docs/source/user_guide/configuration/additional_config.md b/docs/source/user_guide/configuration/additional_config.md index 2a066902d91..85c718e5b83 100644 --- a/docs/source/user_guide/configuration/additional_config.md +++ b/docs/source/user_guide/configuration/additional_config.md @@ -85,7 +85,7 @@ The following table lists additional configuration options available in vLLM Asc | `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. | | `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. | +| `weight_nz_mode` | int | `1` | Weight NZ mode. `0` disables NZ, `1` enables NZ only for quantized weights, and `2` also enables NZ for BF16/FP16 weights when supported. The legacy `VLLM_ASCEND_ENABLE_NZ` environment variable is no longer supported. | | `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. | | `enable_transpose_kv_cache_by_block`| bool | `True` | Whether to enable transpose KV cache by block. Can also be configured via the `VLLM_ASCEND_FUSION_OP_TRANSPOSE_KV_CACHE_BY_BLOCK` environment variable during the migration period. | | `enable_dsa_cp` | bool | `False` | Whether to enable dsa_cp for DeepSeek V3.2, DeepSeek V4, and other models with the same architecture. This feature depends on FlashComm1. Please ensure that FlashComm1 is enabled before enabling this feature.| @@ -244,9 +244,9 @@ ShortRequestFirst is a waiting-queue policy for FCFS synchronous or asynchronous **rl_config** -`rl_config` is a one-click RL mode switch. When `enabled` is `true`, it refreshes the global Ascend configuration on every initialization, forces `AscendConfig.weight_nz_mode=0`, synchronizes `VLLM_ASCEND_ENABLE_NZ=0`, sets `VLLM_SERVER_DEV_MODE=1`, and removes the `expandable_segments` entry from `PYTORCH_NPU_ALLOC_CONF` with an informational log. These fixed RL behaviors are not configurable as `rl_config` sub-fields. When `enabled` is `false`, all other sub-fields are ignored. +`rl_config` is a one-click RL mode switch. When `enabled` is `true`, it refreshes the global Ascend configuration on every initialization, forces `AscendConfig.weight_nz_mode=0`, sets `VLLM_SERVER_DEV_MODE=1`, and removes the `expandable_segments` entry from `PYTORCH_NPU_ALLOC_CONF` with an informational log. These fixed RL behaviors are not configurable as `rl_config` sub-fields. When `enabled` is `false`, all other sub-fields are ignored. -When RL mode is enabled, its fixed NZ and developer-endpoint settings take precedence over top-level configuration and environment variables. `VLLM_BATCH_INVARIANT=1` remains enabled when `rl_config.enable_batch_invariant` is false. +When RL mode is enabled, its fixed NZ setting takes precedence over the top-level `weight_nz_mode` configuration. `VLLM_BATCH_INVARIANT=1` remains enabled when `rl_config.enable_batch_invariant` is false. | Name | Type | Default | Description | | ---- | ---- | ------- | ----------- | diff --git a/docs/source/user_guide/feature_guide/sleep_mode.md b/docs/source/user_guide/feature_guide/sleep_mode.md index 1505e22091e..5b32211b2cf 100644 --- a/docs/source/user_guide/feature_guide/sleep_mode.md +++ b/docs/source/user_guide/feature_guide/sleep_mode.md @@ -100,7 +100,6 @@ The following is a simple example of how to use sleep mode. os.environ["VLLM_USE_MODELSCOPE"] = "True" os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" - os.environ["VLLM_ASCEND_ENABLE_NZ"] = "0" if __name__ == "__main__": prompt = "How are you?" @@ -109,7 +108,11 @@ The following is a simple example of how to use sleep mode. print(f"Free memory before sleep: {free / 1024 ** 3:.2f} GiB") # record npu memory use baseline in case other process is running used_bytes_baseline = total - free - llm = LLM("Qwen/Qwen2.5-0.5B-Instruct", enable_sleep_mode=True) + llm = LLM( + "Qwen/Qwen2.5-0.5B-Instruct", + enable_sleep_mode=True, + additional_config={"weight_nz_mode": 0}, + ) sampling_params = SamplingParams(temperature=0, max_tokens=10) output = llm.generate(prompt, sampling_params) @@ -137,9 +140,10 @@ The following is a simple example of how to use sleep mode. export VLLM_SERVER_DEV_MODE="1" export VLLM_WORKER_MULTIPROC_METHOD="spawn" export VLLM_USE_MODELSCOPE="True" - export VLLM_ASCEND_ENABLE_NZ="0" - vllm serve Qwen/Qwen2.5-0.5B-Instruct --enable-sleep-mode + vllm serve Qwen/Qwen2.5-0.5B-Instruct \ + --enable-sleep-mode \ + --additional-config='{"weight_nz_mode": 0}' # after serving is up, post to these endpoints. # /sleep reads level from the query string (JSON body is ignored). diff --git a/examples/rl/rlhf_async_new_apis.py b/examples/rl/rlhf_async_new_apis.py index 47870ef3f0e..e74784c0860 100644 --- a/examples/rl/rlhf_async_new_apis.py +++ b/examples/rl/rlhf_async_new_apis.py @@ -190,9 +190,6 @@ def generate(self, token_ids: list[int], max_new_tokens: int) -> list[int]: "VLLM_BATCH_INVARIANT": "1", "HCCL_DETERMINISTIC": "strict", "LCCL_DETERMINISTIC": "1", - # Disable FRACTAL_NZ mode (also handled by batch invariance override_envs) - "VLLM_ASCEND_ENABLE_NZ": "0", - "VLLM_ASCEND_ENABLE_MATMUL_ALLREDUCE": "0", # Enable expandable segments for PyTorch NPU allocator "PYTORCH_NPU_ALLOC_CONF": "expandable_segments:True", } @@ -210,6 +207,7 @@ def generate(self, token_ids: list[int], max_new_tokens: int) -> list[int]: max_model_len=8192, distributed_executor_backend="ray", gpu_memory_utilization=0.75, + additional_config={"weight_nz_mode": 0}, weight_transfer_config=WeightTransferConfig(backend="hccl"), ) diff --git a/tests/e2e/nightly/single_node/models/configs/DeepSeek-V3.2-W8A8-DCP.yaml b/tests/e2e/nightly/single_node/models/configs/DeepSeek-V3.2-W8A8-DCP.yaml index 703c34d80cd..ddf2612769b 100644 --- a/tests/e2e/nightly/single_node/models/configs/DeepSeek-V3.2-W8A8-DCP.yaml +++ b/tests/e2e/nightly/single_node/models/configs/DeepSeek-V3.2-W8A8-DCP.yaml @@ -6,7 +6,6 @@ test_cases: - name: "DeepSeek-V3.2-W8A8-DCP-replicated-indexer" model: "vllm-ascend/DeepSeek-V3.2-W8A8" envs: - VLLM_ASCEND_ENABLE_NZ: "1" HCCL_OP_EXPANSION_MODE: "AIV" OMP_PROC_BIND: "false" OMP_NUM_THREADS: "20" @@ -63,7 +62,7 @@ test_cases: - "--compilation-config" - '{"cudagraph_mode": "FULL_DECODE_ONLY", "cudagraph_capture_sizes":[4, 16, 64, 128]}' - "--additional-config" - - '{"enable_dsa_cp": true, "ascend_compilation_config":{"enable_npugraph_ex": true, "enable_static_kernel": false}, "multistream_overlap_shared_expert": true, "enable_mc2_hierarchy_comm": false, "enable_sparse_sfa_c8": true, "enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": false}' + - '{"enable_dsa_cp": true, "ascend_compilation_config":{"enable_npugraph_ex": true, "enable_static_kernel": false}, "multistream_overlap_shared_expert": true, "enable_mc2_hierarchy_comm": false, "enable_sparse_sfa_c8": true, "enable_sparse_li_c8": true, "enable_cpu_binding": true, "recompute_scheduler_enable": false,"weight_nz_mode":1}' - "--speculative-config" - '{"num_speculative_tokens": 3, "method": "deepseek_mtp"}' test_content: [] diff --git a/tests/e2e/nightly/single_node/models/configs/Kimi-K2.5.yaml b/tests/e2e/nightly/single_node/models/configs/Kimi-K2.5.yaml index 39eb893b95d..aeeace8deee 100644 --- a/tests/e2e/nightly/single_node/models/configs/Kimi-K2.5.yaml +++ b/tests/e2e/nightly/single_node/models/configs/Kimi-K2.5.yaml @@ -12,7 +12,6 @@ _envs: &envs TASK_QUEUE_ENABLE: "1" VLLM_ASCEND_ENABLE_MLAPO: "1" VLLM_ASCEND_ENABLE_FLASHCOMM1: "1" - VLLM_ASCEND_ENABLE_NZ: "1" _server_cmd: &server_cmd - "--enable-expert-parallel" @@ -44,7 +43,7 @@ _server_cmd: &server_cmd - "--speculative-config" - '{"method":"eagle3", "model":"lightseekorg/kimi-k2.5-eagle3", "num_speculative_tokens":3}' - "--additional-config" - - '{"enable_shared_expert_dp":true}' + - '{"enable_shared_expert_dp":true,"weight_nz_mode":1}' - "--mm-processor-cache-gb" - "0" - "--mm-encoder-tp-mode" diff --git a/tests/e2e/nightly/single_node/models/configs/MiniMax-M2.5-w8a8-QuaRot-A2.yaml b/tests/e2e/nightly/single_node/models/configs/MiniMax-M2.5-w8a8-QuaRot-A2.yaml index 010a5bc30fb..ce1902f6ede 100644 --- a/tests/e2e/nightly/single_node/models/configs/MiniMax-M2.5-w8a8-QuaRot-A2.yaml +++ b/tests/e2e/nightly/single_node/models/configs/MiniMax-M2.5-w8a8-QuaRot-A2.yaml @@ -13,7 +13,6 @@ test_cases: OMP_NUM_THREADS: "1" TASK_QUEUE_ENABLE: "1" VLLM_ASCEND_ENABLE_FUSED_MC2: "1" - VLLM_ASCEND_ENABLE_NZ: "1" VLLM_TORCH_PROFILER_WITH_STACK: "0" VLLM_TORCH_PROFILER_DIR: "./profile" VLLM_USE_MODELSCOPE: "true" @@ -52,7 +51,7 @@ test_cases: - "--compilation-config" - '{"cudagraph_mode": "FULL_DECODE_ONLY"}' - "--additional-config" - - '{"enable_cpu_binding": true, "enable_npugraph_ex": true, "enable_static_kernel": true}' + - '{"enable_cpu_binding": true, "enable_npugraph_ex": true, "enable_static_kernel": true,"weight_nz_mode":1}' benchmarks: acc: case_type: accuracy diff --git a/tests/e2e/nightly/single_node/models/configs/Qwen3-VL-235B-A22B-Instruct-W8A8.yaml b/tests/e2e/nightly/single_node/models/configs/Qwen3-VL-235B-A22B-Instruct-W8A8.yaml index 874ce36b3a4..db22e039739 100644 --- a/tests/e2e/nightly/single_node/models/configs/Qwen3-VL-235B-A22B-Instruct-W8A8.yaml +++ b/tests/e2e/nightly/single_node/models/configs/Qwen3-VL-235B-A22B-Instruct-W8A8.yaml @@ -11,7 +11,6 @@ _envs: &envs PYTORCH_NPU_ALLOC_CONF: "expandable_segments:True" VLLM_ASCEND_ENABLE_FLASHCOMM1: "1" VLLM_ASCEND_ENABLE_FUSED_MC2: "1" - VLLM_ASCEND_ENABLE_NZ: "2" VLLM_ASCEND_BALANCE_SCHEDULING: "1" SERVER_PORT: "DEFAULT_PORT" @@ -66,5 +65,7 @@ test_cases: server_cmd_extra: - "--compilation_config" - '{"cudagraph_mode": "FULL_DECODE_ONLY", "cudagraph_capture_sizes": [1,2,4,8,16,24,32]}' + - --additional-config + - '{"weight_nz_mode":2}' benchmarks: <<: *benchmarks diff --git a/tests/e2e/nightly/single_node/models/configs/Qwen3.5-27B-w8a8-A2.yaml b/tests/e2e/nightly/single_node/models/configs/Qwen3.5-27B-w8a8-A2.yaml index cba55bf9291..729119ba06e 100644 --- a/tests/e2e/nightly/single_node/models/configs/Qwen3.5-27B-w8a8-A2.yaml +++ b/tests/e2e/nightly/single_node/models/configs/Qwen3.5-27B-w8a8-A2.yaml @@ -13,7 +13,6 @@ test_cases: OMP_NUM_THREADS: "1" TASK_QUEUE_ENABLE: "1" VLLM_ASCEND_ENABLE_DENSE_OPTIMIZE: "1" - VLLM_ASCEND_ENABLE_NZ: "1" VLLM_ASCEND_ENABLE_FUSED_MC2: "1" SERVER_PORT: "DEFAULT_PORT" server_cmd: @@ -33,7 +32,7 @@ test_cases: - "--gpu-memory-utilization" - "0.95" - "--additional-config" - - '{"enable_cpu_binding":true, "enable_weight_nz_layout":true}' + - '{"enable_cpu_binding":true, "enable_weight_nz_layout":true,"weight_nz_mode":1}' - "--speculative_config" - '{"method": "qwen3_5_mtp", "num_speculative_tokens": 3,"enforce_eager": true}' - "--compilation-config" diff --git a/tests/e2e/pull_request/one_card/rlhf/conftest.py b/tests/e2e/pull_request/one_card/rlhf/conftest.py index 2b434033d99..920d9d194ca 100644 --- a/tests/e2e/pull_request/one_card/rlhf/conftest.py +++ b/tests/e2e/pull_request/one_card/rlhf/conftest.py @@ -93,7 +93,6 @@ def server( env = { **os.environ, "VLLM_SERVER_DEV_MODE": "1", - "VLLM_ASCEND_ENABLE_NZ": "0", "HF_HUB_OFFLINE": "1", } base = _DUMMY_ARGS if dummy_weights else _BASE_ARGS @@ -107,6 +106,8 @@ def server( str(port), "--served-model-name", "m", + "--additional-config", + '{"weight_nz_mode": 0}', *(base + (extra_args or [])), ] # Establish the test process's NPU device context while the card is still diff --git a/tests/e2e/pull_request/one_card/rlhf/state_transitions/test_sleep_wake.py b/tests/e2e/pull_request/one_card/rlhf/state_transitions/test_sleep_wake.py index 6ece08c4cae..c54c86adde7 100644 --- a/tests/e2e/pull_request/one_card/rlhf/state_transitions/test_sleep_wake.py +++ b/tests/e2e/pull_request/one_card/rlhf/state_transitions/test_sleep_wake.py @@ -28,7 +28,7 @@ --enable-sleep-mode KV cache allocated via CuMemAllocator; without this flag sleep/wake are no-ops and the bug cannot trigger. VLLM_SERVER_DEV_MODE=1 - VLLM_ASCEND_ENABLE_NZ=0 + --additional-config '{"weight_nz_mode": 0}' """ import requests diff --git a/tests/e2e/pull_request/one_card/test_npu_ipc_weight_transfer.py b/tests/e2e/pull_request/one_card/test_npu_ipc_weight_transfer.py index 0e8bf78a21b..6e83417d517 100644 --- a/tests/e2e/pull_request/one_card/test_npu_ipc_weight_transfer.py +++ b/tests/e2e/pull_request/one_card/test_npu_ipc_weight_transfer.py @@ -97,6 +97,8 @@ def test_npu_ipc_weight_transfer_updates_server_weights(): "--port", str(port), "--trust-remote-code", + "--additional-config", + '{"weight_nz_mode": 0}', ] # VLLM_SERVER_DEV_MODE registers the dev endpoints; insecure serialization # lets the server unpickle the IPC handles sent over HTTP. Pin the server to @@ -105,7 +107,6 @@ def test_npu_ipc_weight_transfer_updates_server_weights(): "VLLM_SERVER_DEV_MODE": "1", "VLLM_ALLOW_INSECURE_SERIALIZATION": "1", "ASCEND_RT_VISIBLE_DEVICES": str(INFERENCE_DEVICE_INDEX), - "VLLM_ASCEND_ENABLE_NZ": "0", } with RemoteOpenAIServer( diff --git a/tests/e2e/pull_request/one_card/test_xlite.py b/tests/e2e/pull_request/one_card/test_xlite.py index 358cef557cf..3d2e3204bba 100644 --- a/tests/e2e/pull_request/one_card/test_xlite.py +++ b/tests/e2e/pull_request/one_card/test_xlite.py @@ -23,15 +23,11 @@ # ruff: noqa: E501 -import os - import pytest from tests.e2e.conftest import wait_until_npu_memory_free from tests.e2e.pull_request.utils import PROMPTS_SHORT, compare_logprobs -os.environ["VLLM_ASCEND_ENABLE_NZ"] = "2" - MODELS: list[str] = ["Qwen/Qwen3-0.6B"] @@ -52,7 +48,10 @@ def test_models_with_xlite_decode_only(model: str): "model_name": model, "max_model_len": 1024, "block_size": 128, - "additional_config": {"xlite_graph_config": {"enabled": True, "full_mode": False}}, + "additional_config": { + "weight_nz_mode": 2, + "xlite_graph_config": {"enabled": True, "full_mode": False}, + }, } compare_logprobs(runner_kwargs=runner_kwargs, prompts=PROMPTS_SHORT) @@ -74,6 +73,9 @@ def test_models_with_xlite_full_mode(model: str): "model_name": model, "max_model_len": 1024, "block_size": 128, - "additional_config": {"xlite_graph_config": {"enabled": True, "full_mode": True}}, + "additional_config": { + "weight_nz_mode": 2, + "xlite_graph_config": {"enabled": True, "full_mode": True}, + }, } compare_logprobs(runner_kwargs=runner_kwargs, prompts=PROMPTS_SHORT) diff --git a/tests/e2e/pull_request/two_card/test_hccl_weight_transfer.py b/tests/e2e/pull_request/two_card/test_hccl_weight_transfer.py index 7dbbefdad22..9b999a61bc4 100644 --- a/tests/e2e/pull_request/two_card/test_hccl_weight_transfer.py +++ b/tests/e2e/pull_request/two_card/test_hccl_weight_transfer.py @@ -188,6 +188,8 @@ def test_hccl_weight_transfer_updates_server_weights(): "--port", str(port), "--trust-remote-code", + "--additional-config", + '{"weight_nz_mode": 0}', ] # The dev-mode endpoints (/init_weight_transfer_engine, /update_weights, # /pause, /resume, ...) are only registered when VLLM_SERVER_DEV_MODE=1. @@ -195,7 +197,6 @@ def test_hccl_weight_transfer_updates_server_weights(): env_dict = { "VLLM_SERVER_DEV_MODE": "1", "ASCEND_RT_VISIBLE_DEVICES": "0", - "VLLM_ASCEND_ENABLE_NZ": "0", } _log(f"starting server on port {port} (device 0, dummy weights) ...") diff --git a/tests/e2e/pull_request/two_card/test_xlite.py b/tests/e2e/pull_request/two_card/test_xlite.py index 36ba2fe2ddc..5f9f705a4a3 100644 --- a/tests/e2e/pull_request/two_card/test_xlite.py +++ b/tests/e2e/pull_request/two_card/test_xlite.py @@ -28,8 +28,6 @@ from tests.e2e.conftest import DPVllmRunner, VllmRunner, wait_until_npu_memory_free from tests.e2e.pull_request.utils import PROMPTS_SHORT -os.environ["VLLM_ASCEND_ENABLE_NZ"] = "2" - MODELS: list[str] = ["Qwen/Qwen3-30B-A3B"] TPDP_SIZES: list[tuple[int, int]] = [(2, 1), (1, 2)] @@ -58,7 +56,10 @@ def test_models_with_xlite_decode_only(model: str, tpdp: tuple[int, int]): enable_expert_parallel=True, block_size=128, max_model_len=2048, - additional_config={"xlite_graph_config": {"enabled": True, "full_mode": False}}, + additional_config={ + "weight_nz_mode": 2, + "xlite_graph_config": {"enabled": True, "full_mode": False}, + }, ) as vllm_model: outputs = vllm_model.generate_greedy(PROMPTS_SHORT, 3) @@ -89,7 +90,10 @@ def test_models_with_xlite_full_mode(model: str, tpdp: tuple[int, int]): enable_expert_parallel=True, block_size=128, max_model_len=2048, - additional_config={"xlite_graph_config": {"enabled": True, "full_mode": True}}, + additional_config={ + "weight_nz_mode": 2, + "xlite_graph_config": {"enabled": True, "full_mode": True}, + }, ) as vllm_model: outputs = vllm_model.generate_greedy(PROMPTS_SHORT, 3) diff --git a/tests/e2e/weekly/single_node/models/test_qwen3_30b_acc.py b/tests/e2e/weekly/single_node/models/test_qwen3_30b_acc.py index eaed6ab5b7a..a595e6f30e3 100644 --- a/tests/e2e/weekly/single_node/models/test_qwen3_30b_acc.py +++ b/tests/e2e/weekly/single_node/models/test_qwen3_30b_acc.py @@ -85,7 +85,6 @@ async def test_models(model: str, tp_size: int) -> None: "HCCL_BUFFSIZE": "1024", "OMP_NUM_THREADS": "1", "PYTORCH_NPU_ALLOC_CONF": "expandable_segments:True", - "VLLM_ASCEND_ENABLE_NZ": "2", "MOONCAKE_CONFIG_PATH": "mooncake.json", } if tp_size != 1: diff --git a/tests/ut/test_ascend_config.py b/tests/ut/test_ascend_config.py index e00436200b7..a583a6248bb 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.assertEqual(ascend_config.weight_nz_mode, 1) ascend_compilation_config = ascend_config.ascend_compilation_config self.assertTrue(ascend_compilation_config.fuse_norm_quant) @@ -417,7 +418,6 @@ def test_migrated_config_falls_back_to_envs(self, mock_fix_incompatible_config, "VLLM_ASCEND_ENABLE_FLASHCOMM1": "1", "MSMONITOR_USE_DAEMON": "1", "VLLM_ASCEND_FUSION_OP_TRANSPOSE_KV_CACHE_BY_BLOCK": "0", - "VLLM_ASCEND_ENABLE_NZ": "2", }, ): ascend_config = init_ascend_config(test_vllm_config) @@ -427,17 +427,12 @@ def test_migrated_config_falls_back_to_envs(self, mock_fix_incompatible_config, self.assertTrue(ascend_config.enable_flashcomm1) self.assertTrue(ascend_config.msmonitor_use_daemon) self.assertFalse(ascend_config.enable_transpose_kv_cache_by_block) - self.assertEqual(ascend_config.weight_nz_mode, 2) + self.assertEqual(ascend_config.weight_nz_mode, 1) mock_info_once.assert_any_call( "AscendConfig.enable_mlapo falls back to environment variable VLLM_ASCEND_ENABLE_MLAPO with value False. " "Please use additional_config.enable_mlapo instead, because VLLM_ASCEND_ENABLE_MLAPO will be " "removed in the next release." ) - mock_info_once.assert_any_call( - "AscendConfig.weight_nz_mode falls back to environment variable VLLM_ASCEND_ENABLE_NZ with value 2. " - "Please use additional_config.weight_nz_mode instead, because VLLM_ASCEND_ENABLE_NZ will be removed " - "in the next release." - ) @_clean_up_ascend_config @patch("vllm_ascend.ascend_config.logger.info_once") @@ -475,7 +470,6 @@ def test_migrated_config_overrides_envs(self, mock_fix_incompatible_config, mock "VLLM_ASCEND_ENABLE_FLASHCOMM1": "1", "MSMONITOR_USE_DAEMON": "1", "VLLM_ASCEND_FUSION_OP_TRANSPOSE_KV_CACHE_BY_BLOCK": "0", - "VLLM_ASCEND_ENABLE_NZ": "2", }, ): ascend_config = init_ascend_config(test_vllm_config) @@ -500,6 +494,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_weight_nz_mode_ignores_removed_env(self, mock_fix_incompatible_config): + test_vllm_config = VllmConfig() + test_vllm_config.additional_config = {"weight_nz_mode": 2} + with patch.dict(os.environ, {"VLLM_ASCEND_ENABLE_NZ": "0"}): + ascend_config = init_ascend_config(test_vllm_config) + + self.assertEqual(ascend_config.weight_nz_mode, 2) + @_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): @@ -637,7 +641,6 @@ def test_rl_config_enabled_applies_best_practice_defaults(self, mock_fix_incompa ascend_config = init_ascend_config(test_vllm_config) self.assertEqual(ascend_config.weight_nz_mode, 0) - self.assertEqual(os.environ.get("VLLM_ASCEND_ENABLE_NZ"), "0") self.assertEqual(os.environ.get("VLLM_SERVER_DEV_MODE"), "1") self.assertNotIn("VLLM_BATCH_INVARIANT", os.environ) self.assertFalse(ascend_config.rl_config.sleep_mode_extra_cleanup) @@ -681,23 +684,19 @@ def test_rl_config_disabled_is_noop(self, mock_fix_incompatible_config): "enabled": False, "sleep_mode_extra_cleanup": True, "enable_batch_invariant": True, - } + }, + "weight_nz_mode": 2, } allocator_config = "page_size:1g,expandable_segments:True" with patch.dict( os.environ, - { - "VLLM_ASCEND_ENABLE_NZ": "2", - "PYTORCH_NPU_ALLOC_CONF": allocator_config, - }, + {"PYTORCH_NPU_ALLOC_CONF": allocator_config}, clear=True, ): ascend_config = init_ascend_config(test_vllm_config) - # rl_config is a no-op when the master switch is off: the env var is - # neither overridden by the sub-field nor rewritten by rl_config. + # rl_config is a no-op when the master switch is off. self.assertEqual(ascend_config.weight_nz_mode, 2) - self.assertEqual(os.environ["VLLM_ASCEND_ENABLE_NZ"], "2") self.assertNotIn("VLLM_SERVER_DEV_MODE", os.environ) self.assertNotIn("VLLM_BATCH_INVARIANT", os.environ) self.assertEqual(os.environ["PYTORCH_NPU_ALLOC_CONF"], allocator_config) @@ -713,8 +712,6 @@ def test_rl_config_overrides_top_level_weight_nz_mode(self, mock_fix_incompatibl } with patch.dict(os.environ, {}, clear=True): ascend_config = init_ascend_config(test_vllm_config) - self.assertEqual(os.environ["VLLM_ASCEND_ENABLE_NZ"], "0") - self.assertEqual(ascend_config.weight_nz_mode, 0) mock_warning.assert_called_once_with( "RL config requires weight_nz_mode=0; overriding AscendConfig.weight_nz_mode from %s to 0.", diff --git a/tests/ut/worker/a2/test_worker_v1.py b/tests/ut/worker/a2/test_worker_v1.py index e2e5c95a69e..92d1a98a858 100644 --- a/tests/ut/worker/a2/test_worker_v1.py +++ b/tests/ut/worker/a2/test_worker_v1.py @@ -1669,10 +1669,7 @@ def test_start_weight_update_dispatches_to_engine(self, mock_get_ascend_config): engine = MagicMock() worker = self._make_worker(engine=engine) - # The runtime AscendConfig is authoritative even when the deprecated - # environment variable still carries a stale import-time value. - with patch.dict("os.environ", {"VLLM_ASCEND_ENABLE_NZ": "1"}): - worker.start_weight_update() + worker.start_weight_update() engine.start_weight_update.assert_called_once_with() self.assertTrue(worker._weight_update_active) @@ -1693,10 +1690,7 @@ def test_start_weight_update_rejects_nz(self, mock_get_ascend_config): engine = MagicMock() worker = self._make_worker(engine=engine) - with ( - patch.dict("os.environ", {"VLLM_ASCEND_ENABLE_NZ": "0"}), - self.assertRaises(ValueError), - ): + with self.assertRaises(ValueError): worker.start_weight_update() def test_update_weights_requires_start(self): @@ -1705,7 +1699,6 @@ def test_update_weights_requires_start(self): with self.assertRaises(RuntimeError): worker.update_weights({"names": [], "dtype_names": [], "shapes": []}) - @patch.dict("os.environ", {"VLLM_ASCEND_ENABLE_NZ": "0"}) def test_update_weights_dispatches_to_engine(self): engine = MagicMock() worker = self._make_worker(engine=engine) diff --git a/vllm_ascend/ascend_config.py b/vllm_ascend/ascend_config.py index d30e74fa0fe..c44448d792d 100644 --- a/vllm_ascend/ascend_config.py +++ b/vllm_ascend/ascend_config.py @@ -236,12 +236,7 @@ def __init__(self, vllm_config: "VllmConfig"): self.pa_shape_list = additional_config.get("pa_shape_list", []) # Weight NZ mode configuration. # 0: disabled, 1: only quant case enable nz (default), 2: BF16/FP16 also enable nz - self.weight_nz_mode = self._get_config_value( - additional_config, - "weight_nz_mode", - "VLLM_ASCEND_ENABLE_NZ", - ascend_envs.VLLM_ASCEND_ENABLE_NZ, - ) + self.weight_nz_mode = additional_config.get("weight_nz_mode", 1) from vllm_ascend.utils import model_uses_sfa_sparse @@ -590,8 +585,6 @@ def apply(self, ascend_config: "AscendConfig") -> None: ascend_config.weight_nz_mode, ) ascend_config.weight_nz_mode = 0 - os.environ["VLLM_ASCEND_ENABLE_NZ"] = "0" - from vllm_ascend.platform import _disable_expandable_segments _disable_expandable_segments() diff --git a/vllm_ascend/envs.py b/vllm_ascend/envs.py index f6a111d5c97..48374fc3943 100644 --- a/vllm_ascend/envs.py +++ b/vllm_ascend/envs.py @@ -77,11 +77,6 @@ # it will consume more NPU memory. If reducing NPU memory usage is a higher priority # for your DeepSeek W8A8 scene, then disable it. "VLLM_ASCEND_ENABLE_MLAPO": lambda: bool(int(os.getenv("VLLM_ASCEND_ENABLE_MLAPO", "1"))), - # Whether to enable weight cast format to FRACTAL_NZ. - # 0: close nz; - # 1: only quant case enable nz; - # 2: enable nz as long as possible. - "VLLM_ASCEND_ENABLE_NZ": lambda: int(os.getenv("VLLM_ASCEND_ENABLE_NZ", 1)), # Whether to anbale dynamic EPLB "DYNAMIC_EPLB": lambda: os.getenv("DYNAMIC_EPLB", "false").lower(), # Whether to enable fused MC2 (`dispatch_ffn_combine/mega_moe`). diff --git a/vllm_ascend/utils.py b/vllm_ascend/utils.py index b582cd777c3..b51016b97d3 100644 --- a/vllm_ascend/utils.py +++ b/vllm_ascend/utils.py @@ -280,7 +280,7 @@ def _should_trans_nz(weight: torch.Tensor) -> bool: # NZ conversion policy: # - 310P: always convert supported weights to FRACTAL_NZ -# - non-310P: follow VLLM_ASCEND_ENABLE_NZ +# - non-310P: follow additional_config.weight_nz_mode # - FP32: never convert # - meta tensor: never convert def maybe_trans_nz(weight: torch.Tensor) -> torch.Tensor: