Commit 753d7ba
authored
[BugFix] Report prefiller cached tokens in PD proxy (vllm-project#11630)
在这个PR的基础上做了一些优化,vllm-project#10598
优化点:
SSE模式下,只有最后一次的chunk的cached token数是正确的,数值=prefill节点的cached
token数,而无需每轮chunk都修改。
测试流程:
单机分别部署PD节点:
P节点:
vllm serve /xxx/Qwen3-8B \
--host 0.0.0.0 \
--port 1000 \
--enable-prefix-caching \
--tensor-parallel-size 1 \
--seed 1024 \
--served-model-name Qwen3-8B \
--max-model-len 40000 \
--max-num-batched-tokens 40000 \
--enable-prompt-tokens-details \
--trust-remote-code \
--gpu-memory-utilization 0.9 \
--kv-transfer-config \
'{"kv_connector": "MooncakeConnectorV1",
"kv_role": "kv_producer",
"kv_port": "30000",
"kv_connector_extra_config": {
"prefill": {
"dp_size": 1,
"tp_size": 1
},
"decode": {
"dp_size": 1,
"tp_size": 1
}
}'
D节点:
vllm serve /xxx/Qwen3-8B \
--host 0.0.0.0 \
--port 1001 \
--no-enable-prefix-caching \
--tensor-parallel-size 1 \
--seed 1024 \
--served-model-name Qwen3-8B \
--max-model-len 40000 \
--enable-chunked-prefill \
--max-num-batched-tokens 40000 \
--trust-remote-code \
--gpu-memory-utilization 0.9 \
--enable-force-include-usage \
--kv-transfer-config \
'{"kv_connector": "MooncakeConnectorV1",
"kv_role": "kv_consumer",
"kv_port": "30100",
"kv_connector_extra_config": {
"prefill": {
"dp_size": 1,
"tp_size": 1
},
"decode": {
"dp_size": 1,
"tp_size": 1
}
}'
启动:
python3
/xxx/vllm-ascend/examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py
\
--host 0.0.0.0 \
--port 8898 \
--prefiller-hosts 0.0.0.0 \
--prefiller-ports 1000 \
--decoder-hosts 0.0.0.0 \
--decoder-ports 1001
结果如下:
root@test-xxx# curl -X POST http://localhost:8898/v1/chat/completions \
> -H "Content-Type: application/json" \
> -d '{
> "model": "Qwen3-8B",
> "messages": [{"role": "user", "content": "The Aegean Sea is an
elongated embayment of the Mediterranean Sea, lying between Europes
Balkan peninsula and Asia Minor. It is home to thousands of islands, the
most famous being Crete, Rhodes, Mykonos, and Santorini. The Aegean is
widely regarded as the cradle of ancient Greek civilization. It was here
that the Minoans and Mycenaeans built some of Europes earliest advanced
societies, and where legends of Troy and Atlantis were born.Today, the
sea is known for its crystal-clear waters, white-washed villages perched
on cliffs, and a rich maritime heritage that continues to shape the
culture of Greece and Turkey."}],
> "max_tokens": 10,
> "stream": true,
> "stream_options": {
> "include_usage": true
> }
> }'
data: {"id": "chatcmpl-xxxx", "object": "chat.completion.chunk",
"created": 1783499708, "model": "Qwen3-8B", "choi
ces": [{"index": 0, "delta": {"role": "assistant", "content": ""},
"logprobs": null, "finish_reason": null}], "usage": {"prompt_tokens":
145, "total_tokens": 145, "completion_tokens": 0,
"prompt_tokens_details": {"cached_tokens": 145}}, "prompt_token_ids":
null, "prompt_text": null}
data: {"id": "chatcmpl-xxxx", "object": "chat.completion.chunk",
"created": 1783499708, "model": "Qwen3-8B", "choi
ces": [{"index": 0, "delta": {"content": "<think>"}, "logprobs": null,
"finish_reason": null, "token_ids": null}], "usage": {"prompt_tokens":
145, "total_tokens": 146, "completion_tokens": 1,
"prompt_tokens_details": {"cached_tokens": 145}}}
data: {"id": "chatcmpl-xxxx", "object": "chat.completion.chunk",
"created": 1783499708, "model": "Qwen3-8B", "choi
ces": [{"index": 0, "delta": {"content": "\n"}, "logprobs": null,
"finish_reason": null, "token_ids": null}], "usage": {"prompt_tokens":
145, "total_tokens": 147, "completion_tokens": 2,
"prompt_tokens_details": {"cached_tokens": 145}}}
......
data: {"id": "chatcmpl-xxxx", "object": "chat.completion.chunk",
"created": 1783499708, "model": "Qwen3-8B", "choi
ces": [{"index": 0, "delta": {"content": " about"}, "logprobs": null,
"finish_reason": "length", "stop_reason": null, "token_ids": null}],
"usage": {"prompt_tokens": 145, "total_tokens": 155,
"completion_tokens": 10, "prompt_tokens_details": {"cached_tokens":
145}}}
data: {"id": "chatcmpl-xxxx", "object": "chat.completion.chunk",
"created": 1783499708, "model": "Qwen3-8B", "choi
ces": [], "usage": {"prompt_tokens": 145, "total_tokens": 155,
"completion_tokens": 10, "prompt_tokens_details": {"cached_tokens":
128}}, "system_fingerprint": "vllm-0.23.0-70fa37d5"}
data: [DONE]
仅最后一次总的token统计数{"cached_tokens": 128},(本实验中block size设置的128token)符合预期。
- vLLM version: v0.23.0
- vLLM main:
vllm-project/vllm@1f486d9
Signed-off-by: LiuY <LiuYuan_jjj@163.com>1 parent b2dc738 commit 753d7ba
1 file changed
Lines changed: 38 additions & 3 deletions
Lines changed: 38 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
168 | 196 | | |
169 | 197 | | |
170 | 198 | | |
| |||
922 | 950 | | |
923 | 951 | | |
924 | 952 | | |
925 | | - | |
| 953 | + | |
| 954 | + | |
926 | 955 | | |
927 | 956 | | |
| 957 | + | |
928 | 958 | | |
929 | 959 | | |
930 | 960 | | |
| |||
943 | 973 | | |
944 | 974 | | |
945 | 975 | | |
| 976 | + | |
946 | 977 | | |
947 | 978 | | |
948 | 979 | | |
| |||
987 | 1018 | | |
988 | 1019 | | |
989 | 1020 | | |
| 1021 | + | |
990 | 1022 | | |
991 | 1023 | | |
992 | 1024 | | |
| |||
1018 | 1050 | | |
1019 | 1051 | | |
1020 | 1052 | | |
1021 | | - | |
| 1053 | + | |
| 1054 | + | |
1022 | 1055 | | |
1023 | 1056 | | |
1024 | 1057 | | |
| |||
1028 | 1061 | | |
1029 | 1062 | | |
1030 | 1063 | | |
| 1064 | + | |
| 1065 | + | |
1031 | 1066 | | |
1032 | 1067 | | |
1033 | 1068 | | |
| |||
1061 | 1096 | | |
1062 | 1097 | | |
1063 | 1098 | | |
1064 | | - | |
| 1099 | + | |
1065 | 1100 | | |
1066 | 1101 | | |
1067 | 1102 | | |
| |||
0 commit comments