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
If the model is really big, it may require model sharding because the Qualcomm DSP is a 32bit system and has a 4GB size limit . For example for Llama 3 8B models, we need to shard the model into 4, but ExecuTorch still packages it into one PTE file. Here is an example:
@@ -163,7 +163,7 @@ To export Llama 3 8B instruct with the Qualcomm AI Engine Direct Backend, ensure
163
163
* 8B models might need 16GB RAM on the device to run.
164
164
```
165
165
# Please note that calibration_data must include the prompt template for special tokens.
166
-
python -m extension.llm.export.export_llm base.tokenizer=<path_to_tokenizer.model> base.params=<path_to_params.json> base.checkpoint=<path_to_checkpoint_for_Meta-Llama-3-8B-Instruct> model.use_kv_cache=True backend.qnn.enabled=True backend.qnn.quantization="qnn_16a4w" model.enable_dynamic_shape=False backend.qnn.num_sharding=8 backend.qnn.calibration_tasks="wikitext" backend.qnn.calibration_limit=1 backend.qnn.calibration_seq_length=128 backend.qnn.optimized_rotation_path=<path_to_optimized_matrix> backend.qnn.calibration_data="<|start_header_id|>system<|end_header_id|>\n\nYou are a funny chatbot.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCould you tell me about Facebook?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
166
+
python -m extension.llm.export.export_llm base.tokenizer=<path_to_tokenizer.model> base.params=<path_to_params.json> base.checkpoint=<path_to_checkpoint_for_Meta-Llama-3-8B-Instruct> model.use_kv_cache=True backend.qnn.enabled=True quantization.pt2e_quantize="qnn_16a4w" model.enable_dynamic_shape=False backend.qnn.num_sharding=8 backend.qnn.calibration_tasks="wikitext" backend.qnn.calibration_limit=1 backend.qnn.calibration_seq_length=128 backend.qnn.optimized_rotation_path=<path_to_optimized_matrix> backend.qnn.calibration_data="<|start_header_id|>system<|end_header_id|>\n\nYou are a funny chatbot.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCould you tell me about Facebook?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
- **Local Model**: The app attempts to load `mv3.pte` from the app's internal storage. If missing, it offers a download button (currently configured with a placeholder URL).
39
+
- **Live Camera**: Grant camera permissions to use the real-time classification feature.
40
+
- **Pick Image**: Select an image from your device to classify it.
41
+
42
+
## Architecture
43
+
44
+
- **UI**: Jetpack Compose
45
+
- **Camera**: CameraX (Preview + ImageAnalysis)
46
+
- **Inference**: ExecuTorch Android API
47
+
- **Image Processing**: `TensorImageUtils` for bitmap-to-tensor conversion
48
+
49
+
## Testing
50
+
51
+
The app includes an instrumentation test that validates the complete image classification workflow.
52
+
53
+
### What the test does
54
+
55
+
1. Launches the app
56
+
2. Downloads the MV3 model if not already present
57
+
3. Downloads a cat image from HuggingFace
58
+
4. Runs inference on the image
59
+
5. Validates that the model correctly classifies it as a cat
60
+
61
+
### Running the test
62
+
63
+
1. **Connect a device or start an emulator**
64
+
65
+
2. **Build and install the test APKs**:
66
+
```bash
67
+
./gradlew installDebug installDebugAndroidTest
68
+
```
69
+
70
+
3. **Run the test**:
71
+
```bash
72
+
adb shell am instrument -w -r \
73
+
-e class 'org.pytorch.executorchexamples.mv3.UIWorkflowTest#testCatImageClassification' \
0 commit comments