Commit b743cc1
authored
Qualcomm AI Engine Direct - Improve GA Static Phi-4-mini accuracy (#13573)
Summary:
- Refactor custom annotation for R3
- Fix warning message in quantization
- Add phi-4-mini setting into README
- Fixed segmemtation fault when run the model with sharding
- Add a test case for phi-4 in test_qnn_delegate.py
- Add new parameter "group_size" in llama.py to set block size in block
quantization
## Sample Script
```
python examples/qualcomm/oss_scripts/llama/llama.py -b build-android -s ${SERIAL_NUM} -m ${SOC_MODEL} \
--ptq 16a4w_block --group_size 16 --checkpoint consolidated.00.pth --params params.json --num_sharding 4 \
--tokenizer_model tokenizer.model --decoder_model phi_4_mini --model_mode hybrid --prefill_ar_len 128 \
--max_seq_len 1024 --prompt "I would like to learn python, could you teach me with a simple example?"
```
## Result
Stats with QNN2.37.0 on SM8750
Accuracy: 10.82
Token Rate: 22.727273
Results:
--prompt "I would like to learn python, could you teach me with a simple
example?"
```
<|user|>I would like to learn python, could you teach me with one simple program?<|end|><|assistant|>Of course! Let's get started with a simple Python program. We'll create a simple program that asks for your name and then greets you.
```python
# Ask for the user's name
name = input("Please enter your name: ")
# Greet the user
print(f"Hello, {name}! Welcome to the world of Python.")
```
To run this program, you would need to copy the code into a Python environment (like an IDE or a Python interpreter). When you run the program, it will prompt you to enter your name, and then it will greet you by name. Enjoy learning Python!<|end|>
```
## Test plan
Added E2E test to test_qnn_delegate.py
cc: @haowhsu-quic1 parent f154d50 commit b743cc1
File tree
6 files changed
+121
-19
lines changed- backends/qualcomm
- builders
- quantizer
- runtime/backends
- tests
- examples/qualcomm/oss_scripts/llama
6 files changed
+121
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
343 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| |||
356 | 361 | | |
357 | 362 | | |
358 | 363 | | |
359 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
360 | 370 | | |
361 | 371 | | |
362 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 54 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 55 | | |
63 | | - | |
64 | 56 | | |
65 | 57 | | |
66 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
1137 | | - | |
| 1137 | + | |
| 1138 | + | |
1138 | 1139 | | |
1139 | 1140 | | |
1140 | 1141 | | |
| |||
2571 | 2572 | | |
2572 | 2573 | | |
2573 | 2574 | | |
2574 | | - | |
2575 | | - | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
2576 | 2578 | | |
2577 | 2579 | | |
2578 | 2580 | | |
| |||
4541 | 4543 | | |
4542 | 4544 | | |
4543 | 4545 | | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
| 4587 | + | |
| 4588 | + | |
| 4589 | + | |
| 4590 | + | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
| 4596 | + | |
| 4597 | + | |
| 4598 | + | |
| 4599 | + | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
4544 | 4617 | | |
4545 | 4618 | | |
4546 | 4619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
238 | 244 | | |
239 | 245 | | |
240 | 246 | | |
241 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
242 | 250 | | |
243 | 251 | | |
244 | 252 | | |
| |||
635 | 643 | | |
636 | 644 | | |
637 | 645 | | |
638 | | - | |
| 646 | + | |
639 | 647 | | |
640 | 648 | | |
641 | 649 | | |
| |||
853 | 861 | | |
854 | 862 | | |
855 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
856 | 871 | | |
857 | 872 | | |
858 | 873 | | |
859 | 874 | | |
860 | 875 | | |
861 | 876 | | |
| 877 | + | |
862 | 878 | | |
863 | 879 | | |
864 | 880 | | |
| |||
908 | 924 | | |
909 | 925 | | |
910 | 926 | | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | 927 | | |
915 | 928 | | |
916 | 929 | | |
| |||
1175 | 1188 | | |
1176 | 1189 | | |
1177 | 1190 | | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1178 | 1198 | | |
1179 | 1199 | | |
1180 | 1200 | | |
| |||
0 commit comments