本目录提供的是本次 patch 交付物:
0001-Add-Gemma4-support-in-vllm.patch0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch其中:
0001-Add-Gemma4-support-in-vllm.patch
vllmvllm 侧性能优化0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch
vllm-ascendvllm-ascend 侧兼容性/性能修复说明:
gemma-4-E2B-it、gemma-4-E4B-it、gemma-4-26B-A4B-it 与 gemma-4-31B-it 可复用,A2 和 A3 可复用。基础镜像:
quay.io/ascend/vllm-ascend:v0.18.0rc1环境说明:
transformers 升级到 5.5.0准备变量:
PATCH_DIR=/path/to/patches
VLLM_REPO=/vllm-workspace/vllm
VLLM_ASCEND_REPO=/vllm-workspace/vllm-ascend
MODEL_ROOT=/models应用 vllm 补丁:
cd "$VLLM_REPO"
git apply --check "$PATCH_DIR/0001-Add-Gemma4-support-in-vllm.patch"
git apply "$PATCH_DIR/0001-Add-Gemma4-support-in-vllm.patch"应用 vllm-ascend 补丁:
cd "$VLLM_ASCEND_REPO"
git apply --check "$PATCH_DIR/0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch"
git apply "$PATCH_DIR/0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch"如需回退已应用补丁,可执行:
cd "$VLLM_ASCEND_REPO"
git apply -R --check "$PATCH_DIR/0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch"
git apply -R "$PATCH_DIR/0002-Add-Gemma4-runtime-fixes-in-vllm-ascend.patch"
cd "$VLLM_REPO"
git apply -R --check "$PATCH_DIR/0001-Add-Gemma4-support-in-vllm.patch"
git apply -R "$PATCH_DIR/0001-Add-Gemma4-support-in-vllm.patch"gemma-4-E2B-it 单逻辑 NPUcd /workspace
ASCEND_RT_VISIBLE_DEVICES=0 \
HCCL_OP_EXPANSION_MODE=AIV \
vllm serve "$MODEL_ROOT"/gemma-4-E2B-it \
--served-model-name gemma-4-E2B-it \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4 \
--enable-prefix-caching \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8]}'gemma-4-E4B-it 单逻辑 NPUcd /workspace
ASCEND_RT_VISIBLE_DEVICES=0 \
HCCL_OP_EXPANSION_MODE=AIV \
vllm serve "$MODEL_ROOT"/gemma-4-E4B-it \
--served-model-name gemma-4-E4B-it \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4 \
--enable-prefix-caching \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8]}'gemma-4-26B-A4B-it 两逻辑 NPUcd /workspace
ASCEND_RT_VISIBLE_DEVICES=0,1 \
HCCL_OP_EXPANSION_MODE=AIV \
HCCL_BUFFSIZE=256 \
vllm serve "$MODEL_ROOT"/gemma-4-26B-A4B-it \
--served-model-name gemma-4-26B-A4B-it \
--tensor-parallel-size 2 \
--enable-expert-parallel \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4 \
--enable-prefix-caching \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8]}'gemma-4-31B-it 四逻辑 NPUcd /workspace
ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 \
HCCL_OP_EXPANSION_MODE=AIV \
vllm serve "$MODEL_ROOT"/gemma-4-31B-it \
--served-model-name gemma-4-31B-it \
--tensor-parallel-size 4 \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4 \
--enable-prefix-caching \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8]}'服务就绪检查:
curl -sS http://127.0.0.1:8000/v1/models文本生成验证:
curl -sS http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"gemma-4-31B-it",
"messages":[
{"role":"user","content":"介绍下xx大模型"}
],
"temperature":1.0,
"max_tokens":512
}'本次性能数据全部通过 vllm bench serve 获取,口径如下:
/v1/chat/completionsopenai-chatrandom11102410241638465536temperature=0seed=20260410为体现 prefix cache 命中效果,本次每个工作负载都连续执行两次:
下表记录的全部是第二次运行指标。
示例命令:
vllm bench serve \
--backend openai-chat \
--endpoint /v1/chat/completions \
--base-url http://127.0.0.1:8000 \
--model /home/model_gemma4/gemma-4-E4B-it \
--served-model-name gemma-4-E4B-it \
--tokenizer /home/model_gemma4/gemma-4-E4B-it \
--dataset-name random \
--random-input-len 65536 \
--random-output-len 1024 \
--num-prompts 1 \
--max-concurrency 1 \
--seed 20260410 \
--temperature 0 \
--disable-tqdm \
--save-result \
--result-dir /workspace/results/gemma-4-E4B-it/64k_1k \
--result-filename round2.json \
--ignore-eos \
--percentile-metrics ttft,tpot,itl,e2el \
--metric-percentiles 0,100gemma-4-E2B-it| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 12.75 | 80.31 | 160.62 | 121.30 | 12.35 |
16k/1k | 13.06 | 78.43 | 1333.28 | 222.19 | 12.55 |
64k/1k | 19.41 | 52.77 | 3429.92 | 650.70 | 18.33 |
| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 7.82 | 130.97 | 261.95 | 71.54 | 7.57 |
16k/1k | 11.30 | 90.60 | 1540.22 | 140.06 | 10.91 |
64k/1k | 29.17 | 35.11 | 2281.94 | 479.08 | 28.04 |
gemma-4-E4B-it| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 14.78 | 69.27 | 138.54 | 140.25 | 14.31 |
16k/1k | 16.54 | 61.91 | 1052.50 | 232.70 | 15.94 |
64k/1k | 24.11 | 42.48 | 2761.17 | 668.83 | 22.91 |
| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 12.60 | 81.26 | 162.53 | 81.81 | 12.24 |
16k/1k | 16.06 | 63.77 | 1084.12 | 147.67 | 15.55 |
64k/1k | 23.49 | 43.60 | 2833.97 | 453.76 | 22.51 |
gemma-4-26B-A4B-it| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 12.28 | 83.36 | 166.72 | 157.14 | 11.85 |
16k/1k | 14.71 | 69.60 | 1183.15 | 265.37 | 14.12 |
64k/1k | 20.21 | 50.67 | 3293.70 | 694.96 | 19.07 |
| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 11.65 | 87.92 | 175.84 | 90.01 | 11.30 |
16k/1k | 14.35 | 71.36 | 1213.13 | 163.44 | 13.87 |
64k/1k | 19.82 | 51.67 | 3358.36 | 491.45 | 18.89 |
gemma-4-31B-it| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 22.55 | 45.41 | 90.81 | 187.93 | 21.86 |
16k/1k | 27.54 | 37.18 | 632.14 | 298.76 | 26.63 |
64k/1k | 38.30 | 26.74 | 1737.82 | 784.14 | 36.67 |
| 序列长度 | Benchmark 时长(s) | 输出吞吐(tok/s) | 总吞吐(tok/s) | TTFT(ms) | TPOT(ms) |
|---|---|---|---|---|---|
1k/1k | 20.73 | 49.39 | 98.79 | 101.08 | 20.17 |
16k/1k | 25.88 | 39.56 | 672.59 | 171.98 | 25.13 |
64k/1k | 36.61 | 27.97 | 1818.23 | 564.29 | 35.23 |
gemma-4-26B-A4B-it 双卡场景仍建议显式设置 HCCL_BUFFSIZE=25664k/1k 测试依赖足够大的 max_model_len,本次四个模型的默认配置均满足要求