Skip to content

Commit 7d2452d

Browse files
committed
add more to performance with streamline section
1 parent c88d1f0 commit 7d2452d

13 files changed

Lines changed: 143 additions & 193 deletions

content/learning-paths/mobile-graphics-and-gaming/voice-assistant/7-benchmark-with-streamline.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

content/learning-paths/mobile-graphics-and-gaming/voice-assistant/7-performance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ adb push build/lib/* /data/local/tmp/benchmark_test/
4040
```output
4141
build/lib/archive/: 9 files pushed. 140.0 MB/s (36970298 bytes in 0.252s)
4242
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)
43+
build/lib/libllm-jni.so: 1 file pushed. 153.8 MB/s (3832152 bytes in 0.024s)
4444
11 files pushed. 137.0 MB/s (45775626 bytes in 0.319s)
4545
```
4646

@@ -49,7 +49,7 @@ This will copy the executables you can run:
4949
adb push build/bin/* /data/local/tmp/benchmark_test/
5050
```
5151
```output
52-
build/bin/arm-llm-bench-cli: 1 file pushed. 134.3 MB/s (3415344 bytes in 0.024s)
52+
build/bin/llm-bench-cli: 1 file pushed. 134.3 MB/s (3415344 bytes in 0.024s)
5353
build/bin/llm-cpp-tests: 1 file pushed. 157.7 MB/s (17783848 bytes in 0.108s)
5454
build/bin/llm_bench: 1 file pushed. 22.6 MB/s (85688 bytes in 0.004s)
5555
build/bin/llm_demo: 1 file pushed. 12.6 MB/s (34656 bytes in 0.003s)
@@ -74,7 +74,7 @@ You can now run the executable in ADB shell, providing the path to libraries and
7474
```sh
7575
adb shell
7676
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
77+
LD_LIBRARY_PATH=./ ./llm-bench-cli -m mnn/llama-3.2-1b/ -i 128 -o 128 -t 1 -n 5 -w 1
7878
```
7979

8080
As you see in the output, the flags used by executable are listed below:
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
3+
title: Performance with Streamline
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. You can use `ENABLE_STREAMLINE` flag to add streamline annotations:
22+
23+
```
24+
cmake --preset=x-android-aarch64 -B build -DLLM_FRAMEWORK=mnn -DBUILD_BENCHMARK=ON -DENABLE_STREAMLINE=ON
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/libllm-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/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+
Copy the `gatord` binary from your Arm Performance Studio installation to your android device:
73+
74+
```sh
75+
adb push ./streamline/bin/android/arm64/gatord /data/local/tmp/
76+
```
77+
78+
Start the gator daemon on your android device and point to the benchmarking executable you profile, `--wait-process` flag will ensure you can start the gator daemon and wait for a process matching the specified command to launch before starting capture:
79+
80+
```bash
81+
adb shell
82+
cd /data/local/tmp
83+
./gatord --allow-command --wait-process llm-bench-cli
84+
```
85+
86+
In Streamline tool, you can use the following to configure the capture:
87+
1. Select TCP target and ensure there's an existing target available
88+
2. Use select counters button to select the counters you would like to see in the Streamline capture
89+
3. Use capture settings button to add more information to your capture
90+
91+
![Streamline configure capture alt-text#center](configure_capture.png "Streamline configure capture")
92+
93+
94+
Add counters from a template with the button shown below, select `SME2 Basic Utilization` and save:
95+
96+
![Streamline select counters alt-text#center](streamline_select_counters.png "Streamline select counters")
97+
98+
In Capture Settings, add previously built libraries from `build/lib/` and executables from `build/bin/` to get a more detailed analysis:
99+
100+
![Streamline capture settings alt-text#center](streamline_capture_settings.png "Streamline capture settings")
101+
102+
You can now click `Start Capture` in Streamline and click `Save` which opens up a Capture file and waits for the process.
103+
104+
On your target device, run the executable in ADB shell, providing the path to libraries and the number of iterations to benchmark:
105+
106+
```sh
107+
adb shell
108+
cd /data/local/tmp/benchmark_test/
109+
LD_LIBRARY_PATH=./ ./llm-bench-cli -m mnn/llama-3.2-1b/ -i 128 -o 128 -t 1 -n 5 -w 1
110+
```
111+
112+
You will start to see the capture being populated once the benchmarking application starts:
113+
114+
![Streamline capture alt-text#center](streamline_capture.png "Streamline capture")
115+
116+
Once the benchmarking application finishes, `Cancel` image download in streamline, it will take some time for capture to be analysed.
117+
118+
You can now look at the `Timeline` tab to see SME kernels utilization throughout the exeucution of your benchmarking application:
119+
120+
![Streamline timeline alt-text#center](streamline_timeline.png "Streamline timeline")
121+
122+
You can also look in `Log` tab to see the Streamline annotations you have enabled in LLM-Runner build:
123+
124+
![Streamline annotations alt-text#center](streamline_annotations.png "Streamline annotations")
125+
126+
By double-clicking on one of the annotations like `LLM::NextToken`, you can look at the timeline and SME/CPU instruction ratio for this specific part of LLM execution:
127+
128+
![Streamline LLM::NextToken timeline alt-text#center](streamline_next_token_timeline.png "Streamline LLM::NextToken timeline")
129+
130+
{{% notice Note %}}
131+
The Android system enforces throttling, so your own results may vary slightly.
132+
{{% /notice %}}
133+
134+
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.
135+
136+
### What can Arm Streamline show?
137+
138+
To summarize, with use of Arm Streamline you can firstly confirm that SME2 kernels are being used by your chosen framework. By looking at the timeline, you can match SME2 activity to the benchmarking phases phases. For multithreaded code, compare threads. Good signs: SME2 activity across worker threads during the compute phase. Bad signs: one active thread, gaps, or long non-SME2 regions.
139+
140+

content/learning-paths/mobile-graphics-and-gaming/voice-assistant/8-performance.md

Lines changed: 0 additions & 150 deletions
This file was deleted.
95.9 KB
Loading
156 KB
Loading
336 KB
Loading
139 KB
Loading
80 KB
Loading
200 KB
Loading

0 commit comments

Comments
 (0)