本文档记录 HuggingFaceTB/SmolLM2-1.7B(预训练基础版,1.7B 参数)在 vLLM-Ascend 0.18.0rc1 环境的快速部署与验证结果。
SmolLM2-1.7B 是 HuggingFace 发布的轻量级语言模型,使用 Llama 架构,24 层 Transformer,2048 隐藏维度,49152 词表大小,BF16 精度。模型在昇腾 NPU 上通过 vLLM-Ascend 原生推理,架构 LlamaForCausalLM 已被 vLLM-Ascend 完整支持,无需额外适配即可运行。
相关获取地址:
quay.io/ascend/vllm-ascend:v0.18.0rc1参考文档:
| 组件 | 版本 |
|---|---|
vllm-ascend | 0.18.0rc1 |
vllm | 0.18.0+empty |
transformers | 4.57.6 |
torch-npu | 2.9.0.post1+gitee7ba04 |
CANN | 8.5.1 |
SOC | ascend910_9391 |
1 逻辑卡(Ascend910,64GB HBM)/opt/atomgit/SmolLM2-1.7B8000{
"architectures": ["LlamaForCausalLM"],
"hidden_size": 2048,
"intermediate_size": 8192,
"num_attention_heads": 32,
"num_hidden_layers": 24,
"num_key_value_heads": 32,
"max_position_embeddings": 8192,
"rope_theta": 130000,
"vocab_size": 49152,
"torch_dtype": "bfloat16",
"tie_word_embeddings": true
}启动前可先检查端口:
ss -lntp | grep ':8000 ' || true已验证通过的启动命令:
export ASCEND_VISIBLE_DEVICES=0,1
export ASCEND_RT_VISIBLE_DEVICES=0,1
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export TASK_QUEUE_ENABLE=1
export OMP_PROC_BIND=false
export OMP_NUM_THREADS=1
vllm serve /opt/atomgit/SmolLM2-1.7B \
--host 0.0.0.0 \
--port 8000 \
--tensor-parallel-size 1 \
--seed 1024 \
--served-model-name smollm2-1.7b \
--max-model-len 4096 \
--max-num-seqs 16 \
--gpu-memory-utilization 0.90 \
--trust-remote-code \
--dtype bfloat16说明:
ASCEND_VISIBLE_DEVICES 需设置为逻辑设备编号(从 0 开始),而非物理芯片 ID基础检查:
curl -sf http://127.0.0.1:8000/v1/models推理测试:
curl -sf http://127.0.0.1:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "smollm2-1.7b",
"prompt": "The capital of France is",
"max_tokens": 32,
"temperature": 0
}'验证结果:
/v1/models 返回 200,模型 smollm2-1.7b 已加载/v1/completions 返回 200,输出 Paris. The capital of the United States is Washington, D.C...使用 GSM8K 5-shot 对模型进行精度评测,对比 CPU 基准。
python scripts/eval_gsm8k.py --api http://127.0.0.1:8000 --model_name smollm2-1.7b --baseline 31.0 --output scripts/gsm8k_results.json| 参数 | 值 |
|---|---|
| 数据集 | GSM8K |
| 评测方式 | 5-shot |
| 样本总数 | 1,319 |
| Max tokens | 256 |
| Temperature | 0 |
| Stop sequences | ["\nQuestion:", "\n\n"] |
| 指标 | NPU 结果 | CPU 基准 | 差异 |
|---|---|---|---|
| Accuracy | 25.02% | 26% | -0.98% |
结论:NPU 上 GSM8K 5-shot 准确率为 25.02%,与 CPU 基准 26% 差异 -0.98%,在合理范围内,验证通过。
测试条件:128 input / 128 output / concurrency=4,20 requests。
| 指标 | 数值 |
|---|---|
duration | 16.93 s |
request_throughput | 1.181 req/s |
output_throughput | 151.22 tok/s |
total_token_throughput | 245.73 tok/s |
mean_latency_ms | 3383.22 ms |
median_latency_ms | 3393.48 ms |
p99_latency_ms | 3412.59 ms |
mean_tpot_ms | 26.43 ms/token |
设备编号:ASCEND_VISIBLE_DEVICES 需使用从 0 开始的逻辑设备编号。如系统显示物理 Chip ID 为 4/5,实际需设置为 0,1。使用错误的设备编号会导致 aclInit 错误(error code 107001)。
模型架构兼容:LlamaForCausalLM 已被 vLLM-Ascend 0.18.0 原生支持,无需额外适配代码或算子替换。
显存占用:1.7B BF16 模型约占用 4GB HBM,Ascend910 单卡(64GB)有充足余量。
此为基础版模型:本验证使用的是预训练基础版(非 Instruct 版),输出为续写模式。如需对话场景,建议使用 HuggingFaceTB/SmolLM2-1.7B-Instruct。