本文档记录 Granite-Speech-4.1-2B-Plus 在 Ascend NPU 环境的快速部署与验证结果。
模型基本信息:
相关资源:
| 组件 | 版本 |
|---|---|
torch | 2.9.0 |
torch-npu | 2.9.0.post1+gitee7ba04 |
transformers | 4.57.6 |
ascend-kernels | 20250516 |
Cann | 8.0 |
1 逻辑卡${MODEL_DIR}conda create -n granite-speech-npu python=3.10
conda activate granite-speech-npupip install torch==2.9.0 --index-url https://repo.myhuaweicloud.com/pypi/simple
pip install torch-npu==2.9.0.post1+gitee7ba04 --index-url https://repo.myhuaweicloud.com/pypi/simple
pip install transformers==4.57.6 --index-url https://repo.myhuaweicloud.com/pypi/simple
pip install ascend-kernels==20250516 --index-url https://repo.myhuaweicloud.com/pypi/simple
pip install accelerate datasets --index-url https://repo.myhuaweicloud.com/pypi/simpleAutoModelForSpeechSeq2Seq 而非 processor,避免 CUDA 依赖--device npu:0import torch
from transformers import AutoModelForSpeechSeq2Seq
model = AutoModelForSpeechSeq2Seq.from_pretrained(
model_dir,
trust_remote_code=True
)
model = model.to("npu:0")
model.eval()python inference.py \
--model-dir ${MODEL_DIR} \
--device npu:0 \
--warmup \
--benchmark参数说明:
--model-dir:模型权重路径--device:运行设备(默认 npu:0)--warmup:是否进行预热--benchmark:是否运行性能测试python eval.py| 指标 | 数值 |
|---|---|
| 模型 | Granite-Speech-4.1-2B-Plus |
| 参数量 | 2,111,812,956 |
| 评测工具 | 本地 NPU 测试 |
| Encoder output | [1, 1600, 2048] |
| Projector output | [1, 321, 2048] |
| LM output | [1, 32/321, 100353] |
| 精度状态 | PASS |
| 指标 | 数值 |
|---|---|
| NPU 单次推理时间(LM) | 92.59 ms |
| NPU 吞吐量 | 10.80 steps/s |
| Encoder Forward | OK |
| Language Model Forward | OK |
| Projector Forward | OK |
| Projector + LM Chain | OK |