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|
15 |
+
|
16 |
+
This version of Qwen2.5-0.5B-Instruct-GPTQ-Int4 has been converted to run on the Axera NPU using **w4a16** quantization.
|
17 |
+
|
18 |
+
This model has been optimized with the following LoRA:
|
19 |
+
|
20 |
+
Compatible with Pulsar2 version: 3.4(Not released yet)
|
21 |
+
|
22 |
+
## Convert tools links:
|
23 |
+
|
24 |
+
For those who are interested in model conversion, you can try to export axmodel through the original repo : https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GPTQ-Int4
|
25 |
+
|
26 |
+
[Pulsar2 Link, How to Convert LLM from Huggingface to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/appendix/build_llm.html)
|
27 |
+
|
28 |
+
[AXera NPU LLM Runtime](https://github.com/AXERA-TECH/ax-llm)
|
29 |
+
|
30 |
+
## Support Platform
|
31 |
+
|
32 |
+
- AX650
|
33 |
+
- AX650N DEMO Board
|
34 |
+
- [M4N-Dock(η±θ―ζ΄ΎPro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
|
35 |
+
- [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html)
|
36 |
+
- AX630C
|
37 |
+
- *developing*
|
38 |
+
|
39 |
+
|Chips|w8a16|w4a16|
|
40 |
+
|--|--|--|
|
41 |
+
|AX650| 28 tokens/sec|44 tokens/sec|
|
42 |
+
|
43 |
+
## How to use
|
44 |
+
|
45 |
+
Download all files from this repository to the device
|
46 |
+
|
47 |
+
```
|
48 |
+
root@ax650:/mnt/qtang/llm-test/qwen2.5-0.5b# tree -L 1
|
49 |
+
.
|
50 |
+
βββ qwen2.5-0.5b-gptq-int4-ax650
|
51 |
+
βββ qwen2.5_tokenizer
|
52 |
+
βββ qwen2.5_tokenizer.py
|
53 |
+
βββ main_axcl_aarch64
|
54 |
+
βββ main_axcl_x86
|
55 |
+
βββ main_prefill
|
56 |
+
βββ post_config.json
|
57 |
+
βββ run_qwen2.5_0.5b_gptq_int4_ax650.sh
|
58 |
+
βββ run_qwen2.5_0.5b_gptq_int4_axcl_aarch64.sh
|
59 |
+
βββ run_qwen2.5_0.5b_gptq_int4_axcl_x86.sh
|
60 |
+
```
|
61 |
+
|
62 |
+
#### Start the Tokenizer service
|
63 |
+
|
64 |
+
```
|
65 |
+
root@ax650:/mnt/qtang/llm-test/qwen2.5-0.5b# python3 qwen2.5_tokenizer.py --port 12345
|
66 |
+
None None 151645 <|im_end|>
|
67 |
+
<|im_start|>system
|
68 |
+
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>
|
69 |
+
<|im_start|>user
|
70 |
+
hello world<|im_end|>
|
71 |
+
<|im_start|>assistant
|
72 |
+
|
73 |
+
[151644, 8948, 198, 2610, 525, 1207, 16948, 11, 3465, 553, 54364, 14817, 13, 1446, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 14990, 1879, 151645, 198, 151644, 77091, 198]
|
74 |
+
http://localhost:12345
|
75 |
+
```
|
76 |
+
|
77 |
+
#### Inference with AX650 Host, such as M4N-Dock(η±θ―ζ΄ΎPro) or AX650N DEMO Board
|
78 |
+
|
79 |
+
Open another terminal and run `run_qwen2.5_0.5b_gptq_int4_ax650.sh`
|
80 |
+
|
81 |
+
```
|
82 |
+
root@ax650:/mnt/qtang/llm-test/qwen2.5-0.5b# ./run_qwen2.5_0.5b_gptq_int4_ax650.sh
|
83 |
+
[I][ Init][ 125]: LLM init start
|
84 |
+
bos_id: -1, eos_id: 151645
|
85 |
+
3% | ββ | 1 / 27 [0.00s<0.08s, 333.33 count/s] tokenizer init ok
|
86 |
+
[I][ Init][ 26]: LLaMaEmbedSelector use mmap
|
87 |
+
100% | ββββββββββββββββββββββββββββββββ | 27 / 27 [1.34s<1.34s, 20.10 count/s] init post axmodel ok,remain_cmm(3427 MB)
|
88 |
+
[I][ Init][ 241]: max_token_len : 1024
|
89 |
+
[I][ Init][ 246]: kv_cache_size : 128, kv_cache_num: 1024
|
90 |
+
[I][ Init][ 254]: prefill_token_num : 128
|
91 |
+
[I][ load_config][ 281]: load config:
|
92 |
+
{
|
93 |
+
"enable_repetition_penalty": false,
|
94 |
+
"enable_temperature": true,
|
95 |
+
"enable_top_k_sampling": true,
|
96 |
+
"enable_top_p_sampling": false,
|
97 |
+
"penalty_window": 20,
|
98 |
+
"repetition_penalty": 1.2,
|
99 |
+
"temperature": 0.9,
|
100 |
+
"top_k": 10,
|
101 |
+
"top_p": 0.8
|
102 |
+
}
|
103 |
+
|
104 |
+
[I][ Init][ 268]: LLM init ok
|
105 |
+
Type "q" to exit, Ctrl+c to stop current running
|
106 |
+
>> who are you
|
107 |
+
[I][ Run][ 466]: ttft: 134.66 ms
|
108 |
+
I am Qwen, a Qwen AI created by Alibaba Cloud. I am here to assist you with various topics and provide help to the best of my ability. I am here to help
|
109 |
+
with any questions you have about science, technology, or any other topic you might have for help or guidance. I am always happy to help you!
|
110 |
+
[N][ Run][ 605]: hit eos,avg 42.11 token/s
|
111 |
+
|
112 |
+
>> 1+1=?
|
113 |
+
[I][ Run][ 466]: ttft: 135.07 ms
|
114 |
+
1+1=2
|
115 |
+
[N][ Run][ 605]: hit eos,avg 43.04 token/s
|
116 |
+
```
|
117 |
+
|
118 |
+
#### Inference with M.2 Accelerator card
|
119 |
+
|
120 |
+
[What is M.2 Accelerator card?](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html), Show this DEMO based on Raspberry PI 5.
|
121 |
+
|
122 |
+
```
|
123 |
+
(base) axera@raspberrypi:~/samples/qwen2.5-0.5b $ ./run_qwen2.5_0.5b_gptq_int4_axcl_aarch64.sh
|
124 |
+
build time: Feb 13 2025 15:44:57
|
125 |
+
[I][ Init][ 111]: LLM init start
|
126 |
+
bos_id: -1, eos_id: 151645
|
127 |
+
100% | ββββββββββββββββββββββββββββββββ | 27 / 27 [11.64s<11.64s, 2.32 count/s] init post axmodel okmain_cmm(6788 MB)
|
128 |
+
[I][ Init][ 226]: max_token_len : 1024
|
129 |
+
[I][ Init][ 231]: kv_cache_size : 128, kv_cache_num: 1024
|
130 |
+
[I][ load_config][ 282]: load config:
|
131 |
+
{
|
132 |
+
"enable_repetition_penalty": false,
|
133 |
+
"enable_temperature": true,
|
134 |
+
"enable_top_k_sampling": true,
|
135 |
+
"enable_top_p_sampling": false,
|
136 |
+
"penalty_window": 20,
|
137 |
+
"repetition_penalty": 1.2,
|
138 |
+
"temperature": 0.9,
|
139 |
+
"top_k": 10,
|
140 |
+
"top_p": 0.8
|
141 |
+
}
|
142 |
+
|
143 |
+
[I][ Init][ 288]: LLM init ok
|
144 |
+
Type "q" to exit, Ctrl+c to stop current running
|
145 |
+
>> who are you
|
146 |
+
I am Qwen, a Qwen-like language model created by Alibaba Cloud. I am designed to assist users in answering questions, generating text,
|
147 |
+
and participating in conversations. I am here to help you with your questions and to engage in meaningful exchanges with you.
|
148 |
+
If you have any questions, you can ask me, and if you want, you can even write to me!
|
149 |
+
[N][ Run][ 610]: hit eos,avg 25.88 token/s
|
150 |
+
|
151 |
+
>> 1+1=?
|
152 |
+
1+1=2
|
153 |
+
[N][ Run][ 610]: hit eos,avg 29.73 token/s
|
154 |
+
>> q
|
155 |
+
|
156 |
+
(base) axera@raspberrypi:~/samples/qwen2.5-0.5b $ axcl-smi
|
157 |
+
+------------------------------------------------------------------------------------------------+
|
158 |
+
| AXCL-SMI V2.26.0_20250205130139 Driver V2.26.0_20250205130139 |
|
159 |
+
+-----------------------------------------+--------------+---------------------------------------+
|
160 |
+
| Card Name Firmware | Bus-Id | Memory-Usage |
|
161 |
+
| Fan Temp Pwr:Usage/Cap | CPU NPU | CMM-Usage |
|
162 |
+
|=========================================+==============+=======================================|
|
163 |
+
| 0 AX650N V2.26.0 | 0000:01:00.0 | 170 MiB / 945 MiB |
|
164 |
+
| -- 43C -- / -- | 2% 0% | 392 MiB / 7040 MiB |
|
165 |
+
+-----------------------------------------+--------------+---------------------------------------+
|
166 |
+
|
167 |
+
+------------------------------------------------------------------------------------------------+
|
168 |
+
| Processes: |
|
169 |
+
| Card PID Process Name NPU Memory Usage |
|
170 |
+
|================================================================================================|
|
171 |
+
| 0 474440 /home/axera/samples/qwen2.5-0.5b-gptq-int4/main_axcl_aarch64 370172 KiB |
|
172 |
+
+------------------------------------------------------------------------------------------------+
|
173 |
+
(base) axera@raspberrypi:~ $
|
174 |
+
```
|