qaihm-bot commited on
Commit
6be2ace
·
verified ·
1 Parent(s): 5ffea62

See https://github.com/quic/ai-hub-models/releases/v0.46.1 for changelog.

Files changed (3) hide show
  1. README.md +37 -186
  2. StateTransformer_float.tflite +0 -3
  3. tool-versions.yaml +0 -3
README.md CHANGED
@@ -10,207 +10,61 @@ pipeline_tag: other
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/statetransformer/web-assets/model_demo.png)
12
 
13
- # StateTransformer: Optimized for Mobile Deployment
14
- ## Multi-agent trajectory prediction model for autonomous driving
15
 
16
  StateTransformer is a transformer-based model designed for trajectory prediction in self-driving scenarios. It integrates rasterized map data, agent context, and temporal dynamics to generate accurate future trajectories.
17
 
18
- This repository provides scripts to run StateTransformer on Qualcomm® devices.
19
- More details on model performance across various devices, can be found
20
- [here](https://aihub.qualcomm.com/models/statetransformer).
21
 
 
22
 
 
 
23
 
24
- ### Model Details
25
 
26
- - **Model Type:** Model_use_case.driver_assistance
27
- - **Model Stats:**
28
- - Model checkpoint: pretrained-mixtral-small
29
- - Input resolution: 1x224x224x58, 1x224x224x58, 1x4x7
30
- - Number of parameters: 90.7M
31
- - Model size (float): 348 MB
32
 
33
- | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
34
- |---|---|---|---|---|---|---|---|---|
35
- | StateTransformer | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 945.244 ms | 222 - 238 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
36
- | StateTransformer | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 783.052 ms | 227 - 255 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
37
- | StateTransformer | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 564.388 ms | 217 - 226 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
38
- | StateTransformer | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 791.845 ms | 224 - 240 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
39
- | StateTransformer | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 488.485 ms | 224 - 257 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
40
- | StateTransformer | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 416.152 ms | 226 - 249 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
41
- | StateTransformer | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 353.973 ms | 176 - 197 MB | CPU | [StateTransformer.tflite](https://huggingface.co/qualcomm/StateTransformer/blob/main/StateTransformer.tflite) |
42
 
 
43
 
44
 
 
45
 
46
- ## Installation
 
 
 
47
 
 
48
 
49
- Install the package via pip:
50
- ```bash
51
- # NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
52
- pip install "qai-hub-models[statetransformer]" git+https://github.com/motional/nuplan-devkit.git@d60b4cd2071de9bb041509c43f5226dd22f248c0#egg=nuplan_devkit
53
- ```
54
 
 
55
 
56
- ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
57
 
58
- Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
59
- Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
60
-
61
- With this API token, you can configure your client to run models on the cloud
62
- hosted devices.
63
- ```bash
64
- qai-hub configure --api_token API_TOKEN
65
- ```
66
- Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
67
-
68
-
69
-
70
- ## Demo off target
71
-
72
- The package contains a simple end-to-end demo that downloads pre-trained
73
- weights and runs this model on a sample input.
74
-
75
- ```bash
76
- python -m qai_hub_models.models.statetransformer.demo
77
- ```
78
-
79
- The above demo runs a reference implementation of pre-processing, model
80
- inference, and post processing.
81
-
82
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
83
- environment, please add the following to your cell (instead of the above).
84
- ```
85
- %run -m qai_hub_models.models.statetransformer.demo
86
- ```
87
-
88
-
89
- ### Run model on a cloud-hosted device
90
-
91
- In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
92
- device. This script does the following:
93
- * Performance check on-device on a cloud-hosted device
94
- * Downloads compiled assets that can be deployed on-device for Android.
95
- * Accuracy check between PyTorch and on-device outputs.
96
-
97
- ```bash
98
- python -m qai_hub_models.models.statetransformer.export
99
- ```
100
-
101
-
102
-
103
- ## How does this work?
104
-
105
- This [export script](https://aihub.qualcomm.com/models/statetransformer/qai_hub_models/models/StateTransformer/export.py)
106
- leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
107
- on-device. Lets go through each step below in detail:
108
-
109
- Step 1: **Compile model for on-device deployment**
110
-
111
- To compile a PyTorch model for on-device deployment, we first trace the model
112
- in memory using the `jit.trace` and then call the `submit_compile_job` API.
113
-
114
- ```python
115
- import torch
116
-
117
- import qai_hub as hub
118
- from qai_hub_models.models.statetransformer import Model
119
-
120
- # Load the model
121
- torch_model = Model.from_pretrained()
122
-
123
- # Device
124
- device = hub.Device("Samsung Galaxy S25")
125
-
126
- # Trace model
127
- input_shape = torch_model.get_input_spec()
128
- sample_inputs = torch_model.sample_inputs()
129
-
130
- pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
131
-
132
- # Compile model on a specific device
133
- compile_job = hub.submit_compile_job(
134
- model=pt_model,
135
- device=device,
136
- input_specs=torch_model.get_input_spec(),
137
- )
138
-
139
- # Get target model to run on-device
140
- target_model = compile_job.get_target_model()
141
-
142
- ```
143
-
144
-
145
- Step 2: **Performance profiling on cloud-hosted device**
146
-
147
- After compiling models from step 1. Models can be profiled model on-device using the
148
- `target_model`. Note that this scripts runs the model on a device automatically
149
- provisioned in the cloud. Once the job is submitted, you can navigate to a
150
- provided job URL to view a variety of on-device performance metrics.
151
- ```python
152
- profile_job = hub.submit_profile_job(
153
- model=target_model,
154
- device=device,
155
- )
156
-
157
- ```
158
-
159
- Step 3: **Verify on-device accuracy**
160
-
161
- To verify the accuracy of the model on-device, you can run on-device inference
162
- on sample input data on the same cloud hosted device.
163
- ```python
164
- input_data = torch_model.sample_inputs()
165
- inference_job = hub.submit_inference_job(
166
- model=target_model,
167
- device=device,
168
- inputs=input_data,
169
- )
170
- on_device_output = inference_job.download_output_data()
171
-
172
- ```
173
- With the output of the model, you can compute like PSNR, relative errors or
174
- spot check the output with expected output.
175
-
176
- **Note**: This on-device profiling and inference requires access to Qualcomm®
177
- AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
178
-
179
-
180
-
181
- ## Run demo on a cloud-hosted device
182
-
183
- You can also run the demo on-device.
184
-
185
- ```bash
186
- python -m qai_hub_models.models.statetransformer.demo --eval-mode on-device
187
- ```
188
-
189
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
190
- environment, please add the following to your cell (instead of the above).
191
- ```
192
- %run -m qai_hub_models.models.statetransformer.demo -- --eval-mode on-device
193
- ```
194
-
195
-
196
- ## Deploying compiled model to Android
197
-
198
-
199
- The models can be deployed using multiple runtimes:
200
- - TensorFlow Lite (`.tflite` export): [This
201
- tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
202
- guide to deploy the .tflite model in an Android application.
203
-
204
-
205
- - QNN (`.so` export ): This [sample
206
- app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
207
- provides instructions on how to use the `.so` shared library in an Android application.
208
-
209
-
210
- ## View on Qualcomm® AI Hub
211
- Get more details on StateTransformer's performance across various devices [here](https://aihub.qualcomm.com/models/statetransformer).
212
- Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
213
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  ## License
216
  * The license for the original implementation of StateTransformer can be found
@@ -218,9 +72,6 @@ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
218
 
219
 
220
 
221
-
222
  ## Community
223
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
224
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
225
-
226
-
 
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/statetransformer/web-assets/model_demo.png)
12
 
13
+ # StateTransformer: Optimized for Qualcomm Devices
 
14
 
15
  StateTransformer is a transformer-based model designed for trajectory prediction in self-driving scenarios. It integrates rasterized map data, agent context, and temporal dynamics to generate accurate future trajectories.
16
 
17
+ This repository contains pre-exported model files optimized for Qualcomm® devices. You can use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/statetransformer) library to export with custom configurations. More details on model performance across various devices, can be found [here](#performance-summary).
 
 
18
 
19
+ Qualcomm AI Hub Models uses [Qualcomm AI Hub Workbench](https://workbench.aihub.qualcomm.com) to compile, profile, and evaluate this model. [Sign up](https://myaccount.qualcomm.com/signup) to run these models on a hosted Qualcomm® device.
20
 
21
+ ## Getting Started
22
+ There are two ways to deploy this model on your device:
23
 
24
+ ### Option 1: Download Pre-Exported Models
25
 
26
+ Below are pre-exported model assets ready for deployment.
 
 
 
 
 
27
 
28
+ | Runtime | Precision | Chipset | SDK Versions | Download |
29
+ |---|---|---|---|---|
30
+ | QNN_DLC | float | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/statetransformer/releases/v0.46.1/statetransformer-qnn_dlc-float.zip)
31
+ | TFLITE | float | Universal | TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/statetransformer/releases/v0.46.1/statetransformer-tflite-float.zip)
 
 
 
 
 
32
 
33
+ For more device-specific assets and performance metrics, visit **[StateTransformer on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/statetransformer)**.
34
 
35
 
36
+ ### Option 2: Export with Custom Configurations
37
 
38
+ Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/statetransformer) Python library to compile and export the model with your own:
39
+ - Custom weights (e.g., fine-tuned checkpoints)
40
+ - Custom input shapes
41
+ - Target device and runtime configurations
42
 
43
+ This option is ideal if you need to customize the model beyond the default configuration provided here.
44
 
45
+ See our repository for [StateTransformer on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/statetransformer) for usage instructions.
 
 
 
 
46
 
47
+ ## Model Details
48
 
49
+ **Model Type:** Model_use_case.driver_assistance
50
 
51
+ **Model Stats:**
52
+ - Model checkpoint: pretrained-mixtral-small
53
+ - Input resolution: 1x224x224x58, 1x224x224x58, 1x4x7
54
+ - Number of parameters: 90.7M
55
+ - Model size (float): 348 MB
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
+ ## Performance Summary
58
+ | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit
59
+ |---|---|---|---|---|---|---
60
+ | StateTransformer | QNN_DLC | float | Snapdragon® X Elite | 4076.132 ms | 22 - 22 MB | NPU
61
+ | StateTransformer | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 3326.654 ms | 11 - 3356 MB | NPU
62
+ | StateTransformer | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 504.429 ms | 214 - 229 MB | CPU
63
+ | StateTransformer | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 997.127 ms | 224 - 239 MB | CPU
64
+ | StateTransformer | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 576.673 ms | 216 - 514 MB | CPU
65
+ | StateTransformer | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 752.049 ms | 217 - 233 MB | CPU
66
+ | StateTransformer | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 392.99 ms | 161 - 171 MB | CPU
67
+ | StateTransformer | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 360.867 ms | 226 - 249 MB | CPU
68
 
69
  ## License
70
  * The license for the original implementation of StateTransformer can be found
 
72
 
73
 
74
 
 
75
  ## Community
76
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
77
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
 
 
StateTransformer_float.tflite DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c5537e4f2e4d3ef90410fa2666f0f899fc892898b0bc0c5b965fa29f26fc30d1
3
- size 359024124
 
 
 
 
tool-versions.yaml DELETED
@@ -1,3 +0,0 @@
1
- tool_versions:
2
- tflite:
3
- tflite: 2.17.0