Skip to content

Commit 5da6e53

Browse files
ppppengpppeng
andauthored
[main][Feature] enable prefill with mc2 with additional_config (vllm-project#11022)
### What this PR does / why we need it? This PR adds support for reserving MC2 token capacity for prefill batches on Ascend. A new `additional_config` option, `enable_prefill_mc2`, is introduced. When it is enabled, `mc2_token_capacity` is calculated based on `max_num_batched_tokens` instead of the decode-only capacity. This allows MC2 to be used in prefill-heavy workloads where the required token capacity can be larger than the decode-only path. The switch is disabled by default. It is intended as a temporary option until MC2 operators are complete for all scenarios, after which MC2 can be enabled by default. ### Does this PR introduce any user-facing change? Yes. Users can now enable prefill MC2 capacity reservation through the Ascend `additional_config` option: `enable_prefill_mc2: true` By default, this option is `False`. When enabled, users should ensure that `max_num_batched_tokens` is configured appropriately. The documentation recommends that the maximum value of `max_num_batched_tokens` should be `tp_size * 512`. ### How was this patch tested? This PR was tested with: The PR also triggered the project CI checks, including DCO, docs link checks, E2E workflow, lint-and-select-tests, and selected tests on CPU, 310P, A2, and A3 configurations. - vLLM version: v0.23.0 - vLLM main: vllm-project/vllm@a30addc --------- Signed-off-by: pppeng <liuzepeng6@huawei.com> Signed-off-by: pppeng <372907983@qq.com> Co-authored-by: pppeng <liuzepeng6@huawei.com>
1 parent 929e461 commit 5da6e53

5 files changed

Lines changed: 93 additions & 3 deletions

File tree

.github/workflows/configs/nightly_config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ a3:
134134
- name: glm-4.7-w8a8
135135
os: linux-aarch64-a3-16
136136
config_file_path: GLM-4.7.yaml
137+
- name: glm-5.1-w8a8-prefill-mc2
138+
os: linux-aarch64-a3-16
139+
config_file_path: GLM-5.1-W8A8-PrefillMC2.yaml
137140
- name: kimi-k2.5
138141
os: linux-aarch64-a3-16
139142
config_file_path: Kimi-K2.5.yaml

docs/source/user_guide/configuration/additional_config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ The following table lists additional configuration options available in vLLM Asc
8989
| `enable_sparse_c8` | bool | `False` | Whether to enable KV cache C8 in DSA models (e.g., DeepSeek V3.2 and GLM5). Not supported on Ascend 950 devices now |
9090
| `c8_enable_reshape_optim` | bool | `False` | Whether to enable StoreKVBlock operator achieves acceleration under the C8 feature (this means that enable_sparse_c8 needs to be enabled). In the PD separation scenario, only the P node is enabled. |
9191
| `enable_mc2_hierarchy_comm` | bool | `False` | Enable dispatch/combine op inter-node communication by ROCE. |
92+
| `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. |
9293
| `profiling_chunk_config` | dict | `{}` | Configuration options for dynamic chunked pipeline parallel. See [Dynamic Chunked Pipeline Parallel](../feature_guide/dynamic_chunk_pipeline_parallel.md) for details. |
9394
| `enable_balance_scheduling` | bool | `False` | Whether to enable balance scheduling. Can also be configured via the `VLLM_ASCEND_BALANCE_SCHEDULING` environment variable during the migration period. |
9495
| `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. |
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# ==========================================
2+
# ACTUAL TEST CASES
3+
# ==========================================
4+
5+
test_cases:
6+
- name: "GLM-5.1-W8A8-PrefillMC2"
7+
model: "Eco-Tech/GLM-5.1-w8a8" #need update
8+
envs:
9+
OMP_PROC_BIND: "false"
10+
OMP_NUM_THREADS: "1"
11+
HCCL_OP_EXPANSION_MODE: "AIV"
12+
PYTORCH_NPU_ALLOC_CONF: "expandable_segments:True"
13+
VLLM_USE_V1: "1"
14+
HCCL_BUFFSIZE: "1800"
15+
ASCEND_AGGREGATE_ENABLE: "1"
16+
ASCEND_TRANSPORT_PRINT: "1"
17+
ACL_OP_INIT_MODE: "1"
18+
ASCEND_A3_ENABLE: "1"
19+
VLLM_NIXL_ABORT_REQUEST_TIMEOUT: "300000"
20+
TASK_QUEUE_ENABLE: "1"
21+
VLLM_ASCEND_ENABLE_MLAPO: "1"
22+
VLLM_ASCEND_ENABLE_FLASHCOMM1: "1"
23+
SERVER_PORT: "DEFAULT_PORT"
24+
server_cmd:
25+
- "--tensor-parallel-size"
26+
- "16"
27+
- "--data-parallel-size"
28+
- "1"
29+
- "--port"
30+
- "$SERVER_PORT"
31+
- "--seed"
32+
- "1024"
33+
- "--max-model-len"
34+
- "10240"
35+
- "--max-num-batched-tokens"
36+
- "4096"
37+
- "--max-num-seqs"
38+
- "32"
39+
- "--trust-remote-code"
40+
- "--quantization"
41+
- "ascend"
42+
- "--async-scheduling"
43+
- "--no-enable-prefix-caching"
44+
- "--enable-expert-parallel"
45+
- "--gpu-memory-utilization"
46+
- "0.94"
47+
- "--compilation-config"
48+
- '{"cudagraph_mode":"FULL_DECODE_ONLY"}'
49+
- "--speculative-config"
50+
- '{"num_speculative_tokens": 3, "method":"deepseek_mtp", "enforce_eager": true}'
51+
- "--additional_config"
52+
- '{"enable_prefill_mc2": true}'
53+
- "--reasoning-parser"
54+
- "glm45"
55+
- "--tool-call-parser"
56+
- "glm47"
57+
58+
benchmarks:
59+
acc_gsm8k:
60+
case_type: accuracy
61+
dataset_path: vllm-ascend/gsm8k-lite
62+
request_conf: vllm_api_general_chat
63+
dataset_conf: gsm8k/gsm8k_gen_0_shot_cot_chat_prompt
64+
max_out_len: 8192
65+
batch_size: 32
66+
baseline: 96.88
67+
temperature: 1.0
68+
top_p: 0.95
69+
thinking: true
70+
threshold: 5
71+
72+
perf_2:
73+
case_type: performance
74+
dataset_path: vllm-ascend/GSM8K-in3500-bs400
75+
request_conf: vllm_api_stream_chat
76+
dataset_conf: gsm8k/gsm8k_gen_0_shot_cot_str_perf
77+
num_prompts: 64
78+
max_out_len: 1500
79+
batch_size: 32
80+
request_rate: 0
81+
baseline: 1
82+
threshold: 0.97

vllm_ascend/ascend_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def __init__(self, vllm_config: "VllmConfig"):
162162
self.enable_cpu_binding = additional_config.get("enable_cpu_binding", True)
163163
self.enable_sleep_mode_extra_cleanup = additional_config.get("enable_sleep_mode_extra_cleanup", False)
164164
self.multistream_dsv4_dsa_overlap = additional_config.get("multistream_dsv4_dsa_overlap", True)
165+
self.enable_prefill_mc2 = bool(additional_config.get("enable_prefill_mc2", False))
165166

166167
self.enable_matmul_allreduce = self._get_config_value(
167168
additional_config,

vllm_ascend/ascend_forward_context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,17 @@ def set_mc2_tokens_capacity(vllm_config, max_num_reqs, uniform_decode_query_len)
203203
global _mc2_tokens_capacity
204204
if _mc2_tokens_capacity is not None:
205205
return
206-
if vllm_config.compilation_config.cudagraph_capture_sizes:
206+
if get_ascend_config().enable_prefill_mc2:
207+
max_num_tokens = vllm_config.scheduler_config.max_num_batched_tokens
208+
elif vllm_config.compilation_config.cudagraph_capture_sizes:
207209
max_num_tokens = vllm_config.compilation_config.max_cudagraph_capture_size
208210
else:
209-
# NOTE: To save memory, we cap the max number of tokens to 512.
210-
max_num_tokens = min(max_num_reqs * uniform_decode_query_len, 512)
211+
max_num_tokens = max_num_reqs * uniform_decode_query_len
211212
tp_size = vllm_config.parallel_config.tensor_parallel_size
212213
# Use integer arithmetic for ceiling division.
213214
num_tokens_per_tp_rank = (max_num_tokens + tp_size - 1) // tp_size
215+
# NOTE: To save memory, we cap the max number of tokens to 512.
216+
num_tokens_per_tp_rank = min(num_tokens_per_tp_rank, 512)
214217
_mc2_tokens_capacity = num_tokens_per_tp_rank * tp_size
215218

216219

0 commit comments

Comments
 (0)