You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the Python extensions with ARM64 Python will make it easier for developers to build GUI app for Windows on Snapdragon(WoS) platforms. Python 3.12.6 ARM64 version has support for following modules: PyQt6, OpenCV, Numpy, PyTorch*, Torchvision*, ONNX*, ONNX Runtime*. Developers can design apps that benefit from rich Python ecosystem. <br>
1
+
### 1. Intruduction:
2
2
3
-
**PyTorch, Torchvision, ONNX, ONNX Runtime: need to compile from source code.* <br>
3
+
Using the Python extensions with ARM64 Python will get better performance for developers to build GUI app for Windows on Snapdragon(WoS) platforms. Python 3.12.6 ARM64 version has support for following modules: PyQt6, OpenCV, Numpy, PyTorch*, Torchvision*, ONNX*, ONNX Runtime*. <br>
4
4
5
+
**PyTorch, Torchvision, ONNX, ONNX Runtime: need to compile from source code today.* <br>
6
+
7
+
### 2. Python and common python extensions:
8
+
Get ARM64 version 'python-3.12.6-arm64.exe' from below link and install it. Make sure to add Python to your PATH environment.
If need these Python extensioins for ARM64 Python, you need compile them by yourselves. If need support on how to compile them, you can contact with us.
25
+
26
+
### 4. MSVC library:
27
+
You need ARM64 version 'msvcp140.dll' from 'Microsoft Visual C++ 2022 Redistributable (Arm64)'. You can download it from here and install it:
28
+
https://aka.ms/arm64previewredist/
29
+
30
+
### 5. Notes: <br>
31
+
a. For C++(Visual Studio) projects, you need to set 'Runtime Library' to 'Multi-threaded DLL (/MD)'. Please refer to below link for detailed information:
If need these Python extensioins for ARM64 Python, you need compile them by yourselves. If need support on how to compile them, you can contact with us.
51
-
52
-
### 4. MSVC library:
53
-
You need ARM64 version 'msvcp140.dll' from 'Microsoft Visual C++ 2022 Redistributable (Arm64)'. You can download it from here and install it:
54
-
https://aka.ms/arm64previewredist/
55
-
56
-
### 5. Notes: <br>
57
-
a. For C++(Visual Studio) projects, you need to set 'Runtime Library' to 'Multi-threaded DLL (/MD)'. Please refer to below link for detailed information:
*[python.md](python.md) can help setup the x64 Python environment automatically.
33
+
* In WoS platform, ARM64 Python has better performance, but some Python extensions such as 'PyTorch' don't work for ARM64 Python today. For detailed help information on how to setup environment for using ARM64 Python, you can refer to [python_arm64.md](python_arm64.md)
82
34
83
35
## API from AppBuilder Python binding extension for Python projects.<br>
84
36
There're several Python classes from this extension:
This sample helps developers use C++ to build Genie based Open AI compatibility API service on Windows on Snapdragon (WoS), Mobile, Linux platforms.
4
+
This sample helps developers use C++ to build Genie based Open AI compatibility API service on Windows on Snapdragon (WoS), Mobile and Linux platforms.
5
5
6
6
# GenieAPIService
7
7
Genie OpenAI Compatible API Service.
8
8
9
9
This is an OpenAI compatible API service that can be used to access the Genie AI model.
10
10
This service can be used on multiple platforms such as Android, Windows, Linux, etc.
11
11
12
-
# Source code
13
-
## Service:
14
-
The code under this folder is C++ implementation of the service. It can be compiled to Windows, Android and Linux target.
15
-
16
-
## Android:
17
-
The code under this folder is Android app which can be used to launch the service in Android device.
18
-
19
-
## Build Service from source code:
20
-
21
-
### Build GenieAPIServer for WoS:<br>
22
-
Install Qualcomm® AI Runtime SDK, CMake, Visual Studio etc, before you compile this service.<br>
23
-
```
24
-
Set QNN_SDK_ROOT=C:\Qualcomm\AIStack\QAIRT\2.34.0.250424\
25
-
cd samples\genie\c++\Service
26
-
mkdir build && cd build
27
-
cmake -S .. -B . -A ARM64
28
-
cmake --build . --config Release
29
-
```
30
-
31
-
### Build GenieAPIServer for Android: <br>
32
-
Install Qualcomm® AI Runtime SDK, Android NDK etc, before you compile this service.<br>
33
-
```
34
-
Set QNN_SDK_ROOT=C:\Qualcomm\AIStack\QAIRT\2.34.0.250424\
35
-
set PATH=%PATH%;C:\Programs\android-ndk-r26d\toolchains\llvm\prebuilt\windows-x86_64\bin
1.[Setup LLM models](https://github.com/quic/ai-engine-direct-helper/tree/main/samples/genie/python#step-3-download-models-and-tokenizer-files) first before running the service. <br>
44
-
2. Download [Pre-build app](https://github.com/quic/ai-engine-direct-helper/releases/download/v2.34.0/GenieAPIService_2.34.zip) and copy "GenieAPIService" folder to path "ai-engine-direct-helper\samples".<br>
45
-
3. Run the commands below to launch the Service.
13
+
1.[Setup LLM models](https://github.com/quic/ai-engine-direct-helper/tree/main/samples/genie/python#step-3-download-models-and-tokenizer-files) first before running this service. <br>
14
+
2. Download [GenieAPIService binary](https://github.com/quic/ai-engine-direct-helper/releases/download/v2.34.0/GenieAPIService_2.34.zip) and copy the subdirectory "GenieAPIService" to path "ai-engine-direct-helper\samples".<br>
15
+
3. Run the following commands to launch the Service (Do *not* close this terminal window while service is running).
### Run the service on Mobile(Snapdragon® 8 Elite Mobile device): <br>
53
-
1. Copy GenieModelsfolder to the root folder of mobile sdcard.<br>
54
-
2. Copy your LLM model & tokenizer.json to "/sdcard/GenieModels/qwen2.0_7b"<br>
39
+
1. Copy the subdirectory "GenieModels" in the folder "Android" in [GenieAPIService binary](https://github.com/quic/ai-engine-direct-helper/releases/download/v2.34.0/GenieAPIService_2.34.zip)to the root path of mobile sdcard.<br>
40
+
2. Copy your QWen QNN model & tokenizer.json to "/sdcard/GenieModels/qwen2.0_7b"<br>
55
41
3. Modify the config file "/sdcard/GenieModels/qwen2.0_7b/config.json" if necessary.<br>
56
42
4. Install the GenieAPIService.apk to mobile and start it.<br>
43
+
* You can also try other models such [IBM-Granite-v3.1-8B-Instruct](https://aihub.qualcomm.com/mobile/models/ibm_granite_v3_1_8b_instruct?domain=Generative+AI&useCase=Text+Generation) which is for "Snapdragon® 8 Elite Mobile" device. You can create a subdirectory in the path "/sdcard/GenieModels/" for your model and customize the "config.json" for your model.
57
44
58
45
## Client Usage:
59
-
The service can be access through http://ip:8910/, it's compatible with OpenAI API.
60
-
Here is a Python client sample:
46
+
The service can be access through the ip address 'localhost:8910', it's compatible with OpenAI API.
47
+
Here is a Python client sample (You can run this Python client in a new terminal window):
Download files for the models listed at the end of this page, save them to following path. Need to unzip the 'weight_sharing_model_N_of_N.serialized.bin' files from model package to following path.
18
+
Download files for the [AI-Hub LLM models](https://github.com/quic/ai-engine-direct-helper/tree/main/samples/genie/python#ai-hub-llm-models) list at the end of this page, save them to following path. You need to unzip the 'weight_sharing_model_N_of_N.serialized.bin' files from model package to following path. Copy the corresponding 'tokenizer.json' file to the following directory path too.
If you want to modify the relative path of the directory where the model file is located, you need to modify the "config.json" file in the corresponding directory of the model to ensure that the tokenizer.json, htp_backend_ext_config.json and model files set in the configuration file can be found correctly.
* You can also use your own QNN LLM model (if you have one). You can create a subdirectory in the path "ai-engine-direct-helper\samples\genie\python\models\" for your model and customize the "config.json" for your model. Then use your model name in the client application.
26
27
27
-
### Step 4: Switch to webui directory
28
+
### Step 4: Switch to samples directory
28
29
Run following commands in Windows terminal:
29
30
```
30
31
cd ai-engine-direct-helper\samples
31
32
```
32
33
33
34
### Step 5: Run service
34
-
Run the following commands to launch Genie API Service:
35
+
Run the following commands to launch Genie API Service (Do *not* close this terminal window while service is running)
35
36
```
36
37
python genie\python\GenieAPIService.py
37
38
```
38
39
39
40
### Step 6: Now you can access the API service
40
-
The default IP address for this API is: [http://localhost:8910](http://localhost:8910)
41
-
You can try using the following commands to generate text or image:
41
+
The default IP address for this API is: 'localhost:8910', you can access this IP address in the client app.
42
+
You can try using the following commands to generate text or image (You can run these Python in a new terminal window):
python genie\python\GenieAPIClient.py --prompt "How to fish?" --stream
45
+
python genie\python\GenieAPIClientImage.py --prompt "spectacular view of northern lights from Alaska"
45
46
```
47
+
When you run the client, you can see the current status of processing client requests from the server. When you run the request of image generation for the first time, the server may have to download the Stable Diffusion model from AI-Hub, and it will take a long time.
0 commit comments