Skip to content

Commit c88d1f0

Browse files
committed
Add streamline section to voice assistant learning path
1 parent 89ea0ac commit c88d1f0

7 files changed

Lines changed: 194 additions & 3 deletions

File tree

content/learning-paths/mobile-graphics-and-gaming/run-stable-audio-open-small-with-lite-rt/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ prerequisites:
2020

2121
author:
2222
- Nina Drozd
23+
- Annie Tallund
2324
- Gian Marco Iodice
2425
- Adnan AlSinan
2526
- Aude Vuilliomenet
26-
- Annie Tallund
2727

2828
generate_summary_faq: true
2929
rerun_summary: false

content/learning-paths/mobile-graphics-and-gaming/voice-assistant/2-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ Currently, this module provides a thin C++ layer as well as JNI bindings for dev
7979
|Framework|Dependency|Input modalities supported|Output modalities supported|Neural Network|
8080
|---|---|---|---|---|
8181
|llama.cpp|https://github.com/ggml-org/llama.cpp|`image`, `text`|`text`|phi-2, qwen-2-VL, llama-3.2-1B|
82-
|onnxruntime-genai|https://github.com/microsoft/onnxruntime-genai|`text`|`text`|phi-4-mini-instruct-onnx|
82+
|onnxruntime-genai|https://github.com/microsoft/onnxruntime-genai|`text`|`text`|phi-4-mini-instruct, llama-3.2-1B|
8383
|mnn|https://github.com/alibaba/MNN|`image`, `text`|`text`|qwen-2.5-VL, llama-3.2-1B|
84-
|mediapipe|https://github.com/google-ai-edge/mediapipe|`text`|`text`|gemma-2b-it-cpu-int4|
84+
|executorch|https://github.com/pytorch/executorch|`text`|`text`|llama-3.2-1B|
8585

8686

8787

content/learning-paths/mobile-graphics-and-gaming/voice-assistant/6-benchmark.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ You can use application controls to enable extra functionality or gather perform
2828
|---|---|---|
2929
|Input tokens|128|Number of prompt (input) tokens fed to the model before generation starts.|
3030
|Output tokens|128|Number of new tokens the model should generate after the prompt.|
31+
|Context size|2048|Context size in tokens.|
3132
|Threads|4|Number of CPU threads used for inference.|
3233
|Iterations|5|Number of measured benchmark runs to collect stable, averaged measurements.|
3334
|Warmup|1|Number of warmup iterations which are not counted in benchmarking, these eliminate one-time overheads before measuring.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
title: Use with Arm Streamline
4+
5+
weight: 9
6+
7+
### FIXED, DO NOT MODIFY
8+
9+
layout: learningpathall
10+
11+
---
12+
13+
## Arm Streamline
14+
15+
[Streamline](https://developer.arm.com/Tools%20and%20Software/Streamline%20Performance%20Analyzer)is an example of a sampling profiler that takes regular samples of various counters and registers in the system to provide a detailed view of the system's performance.
16+
17+
You can install Streamline and Arm Performance Studio on your host machine and connect to your target Arm device to capture the data.
18+
19+
In this example, the target device is an Arm-powered Android phone. The data is captured over a USB connection, and then analyzed on your host machine.
20+
21+
For more information on Streamline usage, see [Tutorials and Training Videos](https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Studio).
22+
23+
24+
## Build application with debug information
25+
26+
Ensure the test device is connected and visible in Streamline, you may see not see any debuggable applications available in Streamline yet:
27+
28+
![Streamline select device alt-text#center](streamline_select_device.png "Streamline select device")
29+
30+
Now choose a debug build variant in Android Studio to build a debuggable application:
31+
32+
![Debug build variant alt-text#center](debug_build_variant.png "Debug build")
33+
34+
Build and run the debug build variant of voice assistant in Android Studio, now you can select this application in Streamline:
35+
36+
![Streamline select application alt-text#center](streamline_select_application.png "Streamline select application")
37+
38+
39+
40+
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
3+
title: Performance
4+
5+
weight: 10
6+
7+
### FIXED, DO NOT MODIFY
8+
9+
layout: learningpathall
10+
11+
---
12+
13+
## Benchmarking LLM on Android phone
14+
15+
You can also benchmark the LLM functionality on Android phone outside of RTVA application. For this, you can use the Large Language Models repository:
16+
17+
```
18+
https://github.com/Arm-Examples/LLM-Runner
19+
```
20+
21+
and build for your chosen LLM backend, ensure that `NDK_PATH` is set properly. SME kernels are enabled by default, so let's first build with SME disabled:
22+
23+
```
24+
cmake --preset=x-android-aarch64 -B build/ -DBUILD_BENCHMARK=ON -DLLM_FRAMEWORK=mnn -DMNN_SME2=OFF
25+
cmake --build ./build
26+
```
27+
28+
{{% notice %}}
29+
For troubleshooting any build issues, refer to [large-language-models README](https://github.com/Arm-Examples/LLM-Runner/blob/main/README.md)
30+
{{% /notice %}}
31+
32+
### Phone setup
33+
34+
Now that you have all the libraries and executables needed, you can create a benchmarking directory and push the needed libraries to the phone:
35+
36+
```sh
37+
adb shell mkdir /data/local/tmp/benchmark_test/
38+
adb push build/lib/* /data/local/tmp/benchmark_test/
39+
```
40+
```output
41+
build/lib/archive/: 9 files pushed. 140.0 MB/s (36970298 bytes in 0.252s)
42+
build/lib/libMNN.so: 1 file pushed. 139.5 MB/s (4973176 bytes in 0.034s)
43+
build/lib/libarm-llm-jni.so: 1 file pushed. 153.8 MB/s (3832152 bytes in 0.024s)
44+
11 files pushed. 137.0 MB/s (45775626 bytes in 0.319s)
45+
```
46+
47+
This will copy the executables you can run:
48+
```sh
49+
adb push build/bin/* /data/local/tmp/benchmark_test/
50+
```
51+
```output
52+
build/bin/arm-llm-bench-cli: 1 file pushed. 134.3 MB/s (3415344 bytes in 0.024s)
53+
build/bin/llm-cpp-tests: 1 file pushed. 157.7 MB/s (17783848 bytes in 0.108s)
54+
build/bin/llm_bench: 1 file pushed. 22.6 MB/s (85688 bytes in 0.004s)
55+
build/bin/llm_demo: 1 file pushed. 12.6 MB/s (34656 bytes in 0.003s)
56+
4 files pushed. 141.7 MB/s (21319536 bytes in 0.143s)
57+
```
58+
Finally, copy the models to benchmark:
59+
```sh
60+
adb push resources_downloaded/models/mnn/ /data/local/tmp/benchmark_test/
61+
```
62+
63+
### Benchmarking the models
64+
65+
To make sure the screen stays on and the CPU is not throttled use the following commands:
66+
67+
```sh
68+
adb shell svc power stayon true
69+
adb shell dumpsys deviceidle disable
70+
```
71+
72+
You can now run the executable in ADB shell, providing the path to libraries and the number of iterations to benchmark:
73+
74+
```sh
75+
adb shell
76+
cd /data/local/tmp/benchmark_test/
77+
LD_LIBRARY_PATH=./ ./arm-llm-bench-cli -m mnn/llama-3.2-1b/ -i 128 -o 128 -t 1 -n 5 -w 1
78+
```
79+
80+
As you see in the output, the flags used by executable are listed below:
81+
* `-m` : path to the specific model or a directory with model and configuration files
82+
* `-i` : number input tokens to use
83+
* `-o` : number output tokens to generate
84+
* `-t` : number of threads to use
85+
* `-n` : number of iterations used for benchmarking
86+
* `-w` : number of warmup iterations, not included in benchmarking
87+
88+
```output
89+
90+
=== ARM LLM Benchmark ===
91+
92+
Parameters:
93+
model_path : mnn/llama-3.2-1b/
94+
num_input_tokens : 128
95+
num_output_tokens : 128
96+
num_threads : 1
97+
num_iterations : 5
98+
num_warmup : 1
99+
100+
101+
======= Results =========
102+
103+
| Framework | Threads | Test | Performance |
104+
| ------------------ | ------- | ------ | -------------------------- |
105+
| mnn | 1 | pp128 | 196.446 ± 0.377 (t/s) |
106+
| mnn | 1 | tg128 | 27.222 ± 0.369 (t/s) |
107+
| mnn | 1 | TTFT | 687.931 ± 2.279 (ms) |
108+
| mnn | 1 | Total | 5354.526 ± 63.163 (ms) |
109+
110+
```
111+
112+
To get benchmark numbers with use of SME kernels, you can rerun the full "Benchmarking LLM on Android phone" section without setting `MNN_SME2` to `OFF`. Omitting the `MNN_SME2` flag enables SME instructions by default.:
113+
114+
```
115+
cmake --preset=x-android-aarch64 -B build/ -DBUILD_BENCHMARK=ON -DLLM_FRAMEWORK=mnn
116+
cmake --build ./build
117+
```
118+
119+
120+
## Example performance with a Vivo X300 Android phone
121+
122+
The table table shows the measurements taken on a Vivo X300 Android phone:
123+
124+
| LLM Framework | Model | Threads | Without SME2 | With SME2 | Uplift |
125+
|-------------------|-----------------------|---------|----------------|-----------|----------|
126+
| mnn | qwen25vl-3b | 1 | 85 | 134 | 57.65 % |
127+
| | | 2 | 95 | 140 | 47.37 % |
128+
| | llama-3.2-1B | 1 | 196 | 339 | 72.96 % |
129+
| | | 2 | 275 | 396 | 44.00 % |
130+
| llama.cpp | qwen-2-VL | 1 | 113 | 146 | 29.20 % |
131+
| | | 2 | 92 | 139 | 51.09 % |
132+
| | llama-3.2-1B | 1 | 148 | 173 | 16.89 % |
133+
| | | 2 | 124 | 191 | 54.03 % |
134+
| | phi-2 | 1 | 58 | 77 | 32.76 % |
135+
| | | 2 | 46 | 60 | 30.43 % |
136+
137+
138+
{{% notice Note %}}
139+
The Android system enforces throttling, so your own results may vary slightly.
140+
{{% /notice %}}
141+
142+
These measurements show how fast the model processes (encodes) 128 input tokens when running on a single CPU thread. As the results illustrate, SME2 delivers a significant performance boost even when using just one or two CPU cores on an Android phone, meaning faster processing without needing to involve multiple CPU cores.
143+
144+
### Why use KleidiAI?
145+
146+
To summarize, KleidiAI simplifies development by abstracting away low-level optimization: developers can write high-level code while the KleidiAI library selects the most efficient implementation at runtime based on the target hardware. This is possible thanks to its deeply optimized micro-kernels tailored for Arm architectures.
147+
148+
As newer versions of the architecture become available, KleidiAI becomes even more powerful: simply updating the library allows applications like the multimodal Voice Assistant to take advantage of the latest architectural improvements such as SME2, without requiring any code changes. This means better performance on newer devices with no additional effort from developers.
149+
150+
13.6 KB
Loading
58.2 KB
Loading

0 commit comments

Comments
 (0)