本目录提供的是 MiniCPM5-1B 在 vLLM-Ascend 上运行所需的 patch 交付物:
vllm-minicpm5-1b.patch其中:
vllm-minicpm5-1b.patch
vllmminicpm_xml 工具调用解析器,用于将 MiniCPM5-1B 的 XML 工具调用输出转换为 OpenAI 兼容的 tool_calls 字段。基础镜像:
quay.io/ascend/vllm-ascend:v0.19.1rc1准备变量:
PATCH_DIR=/path/to/minicpm5_1b/patch
VLLM_REPO=/path/to/vllm
MODEL_PATH=/path/to/MiniCPM5-1B应用 vllm 补丁:
cd "$VLLM_REPO"
git apply --check "$PATCH_DIR/vllm-minicpm5-1b.patch"
git apply "$PATCH_DIR/vllm-minicpm5-1b.patch"如需回退已应用补丁,可执行:
cd "$VLLM_REPO"
git apply -R --check "$PATCH_DIR/vllm-minicpm5-1b.patch"
git apply -R "$PATCH_DIR/vllm-minicpm5-1b.patch"MiniCPM5-1B 单逻辑 NPUcd /workspace
ASCEND_RT_VISIBLE_DEVICES=0 HCCL_OP_EXPANSION_MODE=AIV \
vllm serve "$MODEL_PATH" \
--served-model-name MiniCPM5-1B \
--trust-remote-code \
--dtype bfloat16 \
--port 8000 \
--enable-auto-tool-choice \
--tool-call-parser minicpm_xml \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY"}'--tool-call-parser minicpm_xml 用于启用 MiniCPM5-1B 的 XML 工具调用解析器;如不需要工具调用能力,可去掉 --enable-auto-tool-choice 和 --tool-call-parser minicpm_xml。
服务健康检查:
curl -sS http://127.0.0.1:8000/health -w '\nHTTP %{http_code}\n'预期返回 HTTP 200。
服务就绪检查:
curl -sS http://127.0.0.1:8000/v1/models预期返回中应包含:
id: MiniCPM5-1Broot: 当前 MODEL_PATHmax_model_len: 模型默认上下文长度文本生成验证:
curl -sS http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"MiniCPM5-1B",
"messages":[
{"role":"user","content":"用中文简短回答:2+3等于几?"}
],
"temperature":0,
"max_tokens":32,
"chat_template_kwargs":{
"enable_thinking":false
}
}'工具调用验证:
curl -sS http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"MiniCPM5-1B",
"messages":[
{"role":"user","content":"查询北京今天的天气"}
],
"tools":[
{
"type":"function",
"function":{
"name":"get_weather",
"description":"查询城市天气",
"parameters":{
"type":"object",
"properties":{
"city":{"type":"string","description":"城市名称"}
},
"required":["city"]
}
}
}
],
"tool_choice":"auto",
"temperature":0,
"max_tokens":128,
"chat_template_kwargs":{
"enable_thinking":false
}
}'预期返回中应包含 OpenAI 兼容的 tool_calls 字段。
--trust-remote-code 需要保留,否则模型侧自定义配置可能无法加载。chat_template_kwargs.enable_thinking 控制。--enable-auto-tool-choice 和 --tool-call-parser minicpm_xml。