# Set up AI Hub to optimize an AI model
For quick prototyping of models on Qualcomm AI hardware, AI Hub
provides a way to optimize, validate, and deploy machine learning
models on-device for vision, audio, and speech use cases
## Set up your environment
1. Setup your Python environment. Install
[miniconda](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html)
on your machine.
Tab Windows
Tab macOS/Linux
When the installation finishes, open an Anaconda prompt from the Start menu.
When the installation finishes, open a new shell window.
Set up a Python virtual environment for AI Hub.
conda activate
Copy to clipboard
conda create python=3.10 -n qai_hub
Copy to clipboard
conda activate qai_hub
Copy to clipboard
2. Install git.
sudo apt-get install git
Copy to clipboard
3. Install the AI Hub Python client.
pip3 install qai-hub
Copy to clipboard
pip3 install "qai-hub[torch]"
Copy to clipboard
4. Sign in to AI Hub.
Go to [AI Hub](https://aihub.qualcomm.com/) and sign in with your
Qualcomm ID to view information about jobs you create.
Once signed in, go to *Account > Settings > API Token*. This
should provide an API token that you can use to configure your
client.
5. Configure the client with your API token using the following command
in your terminal.
qai-hub configure --api_token
Copy to clipboard
## Choose an AI Hub workflow
### Try a pre-optimized model
1. Go to [AI Hub Model Zoo](https://aihub.qualcomm.com/iot/models)
to access pre-optimized models available for Qualcomm evaluation kits.
2. Filter models available for your EVK. For example, pre-optimized models for RB3Gen2
can be downloaded by selecting *Qualcomm QCS6490* as the chipset in the left pane.
3. Select a model from the filtered view to go to the model page.
4. On the model page, select the chipset from the dropdown list
and choose the *TorchScript > LiteRT* path.
5. Select download to begin model download. The downloaded model is
preoptimized and ready for deployment. See [Develop your own AI/ML application](https://docs.qualcomm.com/doc/80-70018-15B/topic/develop-your-own-application.html)
for more information about deploying the model.

### Bring your own model
1. Select a pretrained model in PyTorch or ONNX format.
2. Submit a model for compilation or optimization to AI Hub using python
APIs.
When submitting a compilation job, you must select a device or the
chipset for your EVK and the target runtime to compile the model. For RB3Gen2, the
LiteRT runtime is supported.
| **Chipset** | **Runtime** | **CPU** | **GPU** | **HTP** |
| --- | --- | --- | --- | --- |
| QCS6490 | LiteRT | INT8,FP16, FP32 | FP16,FP32 | INT8,INT16 |
On submission, AI Hub generates a unique ID for the job. You can use
this job ID to view job details.
3. AI Hub optimizes the model based your device and runtime selections.
- Optionally, you can submit a job to profile or inference the
optimized model (using Python APIs) on a real device provisioned
from a device farm.
- Profiling: Benchmarks the model on a provisioned device and
provides statistics, including average inference times at the
layer level, runtime configuration, etc.
- Inference: Performs inference using an optimized model on data
submitted as part of the inference job by running the model on
a provisioned device.
4. Each submitted job will be available for review in the AI Hub portal.
A submitted compilation job will provide a downloadable link to the
optimized model. This optimized model can then be deployed on a local
development device like RB3Gen2.
The following is an example of the described workflow taken from the
[AI Hub documentation](https://aihub.qualcomm.com/iot/models). In
this example, a MobileNet V2 pretrained model from PyTorch is
uploaded to AI Hub and compiled to an optimized LiteRT model to run
on an RB3Gen2 target.
import qai_hub as hub
import torch
from torchvision.models import mobilenet_v2
import numpy as np
# Using pre-trained MobileNet
torch_model = mobilenet_v2(pretrained=True)
torch_model.eval()
# Trace model (for on-device deployment)
input_shape = (1, 3, 224, 224)
example_input = torch.rand(input_shape)
traced_torch_model = torch.jit.trace(torch_model, example_input)
# Compile and optimize the model for a specific device
compile_job = hub.submit_compile_job(
model=traced_torch_model,
device=hub.Device("QCS6490 (Proxy)"),
input_specs=dict(image=input_shape),
#compile_options="--target_runtime tflite",
)
# Profiling Job
profile_job = hub.submit_profile_job(
model=compile_job.get_target_model(),
device=hub.Device("QCS6490 (Proxy)"),
)
sample = np.random.random((1, 3, 224, 224)).astype(np.float32)
# Inference Job
inference_job = hub.submit_inference_job(
model=compile_job.get_target_model(),
device=hub.Device("QCS6490 (Proxy)"),
inputs=dict(image=[sample]),
)
# Download model
compile_job.download_target_model(filename="/tmp/mobilenetv2.tflite")
Copy to clipboard
Note
To deactivate a previously activated `qai_hub` environment use the following command.
conda deactivate
Copy to clipboard
Once the model is downloaded, it’s ready to be used for you to [Develop your own AI/ML application](https://docs.qualcomm.com/doc/80-70018-15B/topic/develop-your-own-application.html).
For more details about the AI Hub workflow and APIs, see the [AI Hub documentation](https://app.aihub.qualcomm.com/docs/hub/index.html#examples),
explore the [AI Hub tutorial videos](https://www.youtube.com/watch?v=V1CDWYZ7Shw&list=PLxeazpXYyqtOowtUdvigvAgMV5_K1KIrh),
or watch the following video about how to profile models in AI Hub.
Note
The video above uses Python 3.8 as an example.
Python 3.8 and Python 3.10 are supported.
Last Published: Oct 13, 2025
[Previous Topic
Compile and optimize an AI model](https://docs.qualcomm.com/bundle/publicresource/80-70018-15B/topics/compile-and-optimize-model.md) [Next Topic
Use LiteRT to optimize an AI model](https://docs.qualcomm.com/bundle/publicresource/80-70018-15B/topics/tflite.md)