-
Notifications
You must be signed in to change notification settings - Fork 754
minibench README #5367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
minibench README #5367
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| Minibench: ExecuTorch Android Benchmark App | ||
| === | ||
|
|
||
| Minibench is a benchmarking app for testing the performance of the ExecuTorch runtime on Android devices. | ||
|
|
||
| It supports both generic (vision, audio, etc) models and LLM. | ||
|
|
||
| - For generic model, it reports metrics such as model load time, and average inference time. | ||
| - For LLM, it reports metrics such as model load time, and tokens per second. | ||
| - We are working on providing more metrics in the future. | ||
|
|
||
| Minibench is usedful for giving reference performance data when developers integrate ExecuTorch with their own Android app. | ||
|
|
||
| ## Build | ||
| You will need executorch AAR for Java and JNI dependencies. | ||
| ``` | ||
| export ANDROID_NDK=<path_to_android_ndk> | ||
| sh build/build_android_llm_demo.sh | ||
| ``` | ||
| and copy the AAR to `app/libs`. | ||
| ``` | ||
| mkdir -p app/libs | ||
| cp $BUILD_AAR_DIR/executorch.aar app/libs | ||
| ``` | ||
|
|
||
| You can also refer to [this script](https://github.com/pytorch/executorch/blob/62024d8/.github/workflows/android-perf.yml#L226-L235) to see how it is built. | ||
|
|
||
| Then you can build and install the app on Android Studio, or simply run | ||
| ``` | ||
| ./gradlew installDebug | ||
| ``` | ||
|
|
||
| ## Usage | ||
| This apk does not come with a launcher icon. Instead, trigger it from command line | ||
|
|
||
| ### Push model to a directory | ||
| ``` | ||
| adb shell mkdir /data/local/tmp/minibench | ||
| adb push my_model.pte /data/local/tmp/minibench | ||
| # optionally, push tokenizer for LLM | ||
| adb push tokenizer.bin /data/local/tmp/minibench | ||
| ``` | ||
|
|
||
| ### Generic model | ||
| ``` | ||
| adb shell am start -W -S -n org.pytorch.minibench/org.pytorch.minibench.LlmBenchmarkActivity \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a note to clarify that we only test the first pte model found in |
||
| --es model_dir /data/local/tmp/minibench | ||
| ``` | ||
|
|
||
| ### LLM | ||
| ``` | ||
| adb shell am start -W -S -n org.pytorch.minibench/org.pytorch.minibench.LlmBenchmarkActivity \ | ||
| --es model_dir /data/local/tmp/minibench --es tokenizer_path /data/local/tmp/minibench/tokenizer.bin | ||
| ``` | ||
|
|
||
| ### Fetch results | ||
| ``` | ||
| adb shell run-as org.pytorch.minibench cat files/benchmark_results.json | ||
| ``` | ||
| If the ExecuTorch runner is initialized and loads your model, but there is a load error or run error, you will see error code from that JSON. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think add a link to a wiki on how to export a pte model here would be useful (if such page exists elsewhere)