This repository contains the adaptation and evaluation results for running Qwen-1_8B-Chat on Huawei Ascend NPUs via vLLM-Ascend.
Qwen-1_8B-Chat is the 1.8B instruction-tuned variant of Alibaba Cloud's first-generation Qwen LLM series. It supports a maximum context window of 8K tokens and delivers capable performance in Chinese/English dialogue, text generation, and code writing.
| Attribute | Value |
|---|---|
| Architecture | QWenLMHeadModel |
| Hidden Size | 2048 |
| Attention Heads | 16 |
| Layers | 24 |
| Max Position Embeddings | 8192 |
| Model Type | Causal LM (Decoder-only) |
| Weights Source | ModelScope |
python -c "
from modelscope import snapshot_download
snapshot_download('qwen/Qwen-1_8B-Chat', cache_dir='./Qwen-1_8B-Chat')
"export ASCEND_RT_VISIBLE_DEVICES=0
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
vllm serve ./Qwen-1_8B-Chat \
--host 0.0.0.0 \
--port 8000 \
--served-model-name qwen-1_8b-chat \
--trust-remote-code \
--dtype bfloat16 \
--max-model-len 8192 \
--max-num-seqs 32# Readiness check
curl -sf http://127.0.0.1:8000/v1/models
# Chat completion
curl -s http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen-1_8b-chat",
"messages": [{"role": "user", "content": "你好"}],
"temperature": 0,
"max_tokens": 32
}'Example Response:
你好,我是来自阿里云的大规模语言模型,我叫通义千问。我是一个能够回答问题、创作文字,还能表达观点、撰写代码的超大规模语言模型...
Environment:
Benchmark Conditions: 512 input / 128 output / request-rate=4 / num-prompts=64
| Metric | Value |
|---|---|
| Duration | 17.95 s |
| Successful Requests | 64 |
| Failed Requests | 0 |
| Request Throughput | 3.56 req/s |
| Output Token Throughput | 456.29 tok/s |
| Peak Output Token Throughput | 737.00 tok/s |
| Total Token Throughput | 2281.47 tok/s |
| Mean TTFT | 64.08 ms |
| Median TTFT | 61.77 ms |
| P99 TTFT | 100.40 ms |
| Mean TPOT | 15.71 ms |
| Median TPOT | 15.96 ms |
| P99 TPOT | 17.04 ms |
Conclusion: On a single Ascend910 card, Qwen-1_8B-Chat achieves ~456 tok/s output throughput with TTFT under 65 ms.
| Metric | Value |
|---|---|
| Dataset | GSM8K (first 20 questions) |
| Correct | 3 |
| Total | 20 |
| Accuracy | 15.0% |
Note: 15% is within the expected range for a 1.8B parameter model on complex multi-step math reasoning. The primary goal is to verify NPU inference behavior matches CPU/GPU expectations.
| Question | Expected | Result |
|---|---|---|
| Capital of China? | Beijing | Correct |
| 1+1=? | 2 | Correct |
| Translate Hello | 你好 | Correct |
| Months in a year? | 12 | Correct |
| Largest planet? | Jupiter | Correct |
Chinese QA Accuracy: 5/5 = 100%
Note: This environment only has Ascend NPU; no discrete GPU is available. Therefore, CPU inference serves as the baseline for precision error comparison against NPU.
To quantify precision error and output consistency between NPU and CPU/GPU inference expectations, the same model weights, prompts, and temperature=0 settings were used on both CPU and Ascend NPU.
| Question | CPU Output | NPU Output | Consistency |
|---|---|---|---|
| Capital of China? | Beijing | Beijing. | Similar |
| 1+1=? | 1+1=2. Basic arithmetic operation... | 1+1=2. Basic concept called addition... | Different wording |
| Translate Hello | Hello! | Hello | Similar |
| Months in a year? | 12 months. | 12 months. | Exact match |
| Largest planet? | Jupiter is a gas giant... | Jupiter, diameter about 142,984 km... | Different wording |
Numeric Precision Metrics (Single Forward Pass):
| Metric | Value | Threshold | Result |
|---|---|---|---|
| Top-1 Token Agreement | 100.00% | > 99% | PASS |
| Perplexity Relative Diff | 0.0007% | < 1% | PASS |
| Hidden State Cosine Similarity | 1.000000 | > 0.9999 | PASS |
| KL Divergence | -0.000013 | ≈ 0 | PASS |
Text-Level Consistency (Autoregressive Generation):
| Metric | Value |
|---|---|
| Exact Match | 1 / 5 = 20.0% |
| Semantic Similarity | 2 / 5 = 40.0% |
| Overall Consistency | 3 / 5 = 60.0% |
| Factual Error Rate | 0% |
Error Analysis:
| Evaluation | Samples | Result | Notes |
|---|---|---|---|
| GSM8K (subset) | 20 | 15.0% | Normal for 1.8B model |
| Chinese Commonsense | 5 | 100% | Semantic understanding verified |
| CPU vs NPU Comparison | 5 | 60% overall consistent | Semantic match; differences only in wording |
NPU Accuracy Conclusion: Model inference behavior on Ascend NPU is consistent with expected capabilities. No degradation or garbled output observed.
QWenLMHeadModel is natively supported in vLLM (qwen.py) with no CUDA/Triton kernels.--trust-remote-code. The model config contains auto_map for custom tokenizer code..
├── Qwen-1_8B-Chat-vLLM-Ascend-Evaluation-Report.md # Full evaluation report
├── docs/
│ └── source/
│ └── tutorials/
│ └── models/
│ └── Qwen-1_8B-Chat.md # Tutorial documentation
├── tests/
│ └── e2e/
│ └── models/
│ └── configs/
│ └── Qwen-1_8B-Chat.yaml # Test configuration
└── README.md # This fileMIT