Replies: 4 comments
|
[Time: Pls see timestamp in the screenshots] Benchmark data of project ggml-hexagonbenchmark data of ggml-hexagon(PR in the llama.cpp community:ggml-org#12326) on Android phone equipped with Qualcomm Snapdragon 8Elite(one of the most advanced mobile SoC on our planet at the moment): ./scripts/build-run-android.sh run_benchmark ADD 0/1/2/3/4 ./scripts/build-run-android.sh run_benchmark MUL_MAT 0/1/2/3/4 unfortunately the following computational result is incorrect. How to verify on Android phoneOverviewa Linux machine is required for following steps, Android phone equipped with Qualcomm Snapdragon 8Elite is strongly recommended.
for 8Gen3(0x8c75): Stepsthe following steps have verified in a fresh&clean ggml-hexagon clone with 8Elite based Android phone.
What does 0/1/2/3/4 mean in the script?
HVX and HMXHVX: Hexagon Vector eXtension I'm confused about QNN-NPU and Hexagon-NPU, Are they different implementations of the same hardware?there some subtle differences between QNN-NPU,QNN-HTP,Hexagon-NPU,Hexagon-cDSP, pls refer to:
as my personal understanding, in the all: both QNN-HTP, QNN-NPU, QNN-DSP, Hexagon-cDSP, Hexagon-NPU are all NPU-based solution. Technical merits in PR-12326:
Updated benchmark data of fp32 mulmat on Hexagon cDSP(actually updated on 06/27/2025, merged in this comment on Jun 8 2025)benchmark data of ggml-hexagon(PR in the llama.cpp community:ggml-org#12326) on Android phone equipped with Qualcomm Snapdragon 8Elite(one of the most advanced mobile SoC on our planet at the moment): how to verify on Android phone: same as above. performance of fp32 4096x4096 mulmat on cDSP: before 05/27/2025: about 28 seconds. |
|
[Time: Pls see timestamp in the screenshots] Overall evaluation of ggml-opencl,ggml-vulkan,ggml-hexagon and the default ggml backend on Android phoneIntroductionAs well known, there are ggml-opencl,ggml-vulkan backend in the llama.cpp project. In this technical post, I'd like to introduce an overall evaluation of ggml-opencl, ggml-vulkan, ggml-hexagon in PR-12326 (which launched on 03/2024 and re-launched since 01/29/2025 and re-re-launched since 05/27/2025), and the default ggml backend on Snapdragon 8Elite based Android phone. Some background knowledge about ggml-hexagon can be found in the entry point of this discussion and the above technical post. In order to provide a fair and straightforward comparison of the performance of these backends, this evaluation will use llama-cli instead of llama-bench which is preferred by AI experts. As well known, Android phone is a typcial resource constrained device. Accordingly, qwen1_5-1_8b.gguf will be used in this evaluation because the weights in qwen1_5-1_8b.gguf is suitable for all these 4 backends on Android phone. For simplify workflow of developing/improving/testing ggml-opencl, ggml-vulkan and ggml-hexagon on Android phone(especially Snapdragon high-end mobile SoC based Android phone), following build scripts are provided: How to build ggml-opencl backend for Android device on Linuxhttps://github.com/zhouwg/ggml-hexagon/blob/self-build/scripts/build-run-ggmlopencl-android.sh DetailsHow to build ggml-vulkan backend for Android device on Linuxhttps://github.com/zhouwg/ggml-hexagon/blob/self-build/scripts/build-run-ggmlvulkan-android.sh DetailsHow to build ggml-hexagon backend for Android device on Linuxhttps://github.com/zhouwg/ggml-hexagon/blob/self-build/scripts/build-run-ggmlhexagon-android.sh (supports performance comparison between QNN-CPU, QNN-GPU, QNN-NPU, Hexagon-cDSP and the default ggml backend (ARM NEON)). Benchmark data
Details
Details
DetailsDetailsDetailsDetails
Details
forground running logs: DetailsDetailsConclusionAfter compare ggml-opencl, ggml-vulkan, ggml-hexagon, the default ggml backend on Snapdragon 8Elite based Android phone, I personally think:
the default ggml backend(ARM NEON backend) >= ggml-opencl >>> ggml-hexagon(aka Hexagon NPU backend) > ggml-vulkan
OpenCL-based GPU driver > FastRPC-based NPU driver > Vulkan-based GPU driver
NPU driver > OpenCL-based GPU driver > Vulkan-based GPU driver Qualcomm's Hexagon SDK team can remove the qidl mechanism in the new Hexagon SDK and provide a simple and effective approach/mechanism to exchange arbitrary data between ARM AP side and cDSP side, let developers do what they want to do on the world-class and state-of-the-art Hexagon NPU(aka Hexagon-cDSP) rather than study the confusing codes which generated by qidl mechanisim, this move will be helpful for their high-level QNN SDK/SNPE SDK and helpful for llama.cpp community. Obviously, it would be a great move if Qualcomm could open their HMX instructions and the corresponding tech docs. At the same time, compare to ggml-vulkan on Snapdragon based Android phone,
Analysis
|
|
[Time:Jul 12 2025] From the original author of ggml:
|
|
[Time:Jul 12 2025, updated on Jul 13 2025]
|
































Uh oh!
There was an error while loading. Please reload this page.
Introduction
Focus on LLM inference on Android Phone/Pad/TV/STB/PC/Intelligent Cockpit Domain in Intelligent Electric Vehicle, especially focus on llama.cpp + Android phone equipped with Qualcomm Snapdragon high-end mobile SoC, such as Snapdragon 8Gen3, 8Elite, 8Elite2(might-be released on 09/2025 or 10/2025)....
Maintain an up-to-date discussion to track the latest development of fundamental technologies, state-of-the-art on-device LLM models, Android APPs, future directions in this rapidly evolving field.
Table of Contents
Part 1: Research Papers
on-device inference
core technologies
fundamental technologies
Part 2: On-Device Inference framework
Part 3: Hardware acceleration
OpenCL
ggml-opencl: https://github.com/ggml-org/llama.cpp/tree/master/ggml/src/ggml-opencl
Vulkan
ggml-vulkan: https://github.com/ggml-org/llama.cpp/tree/master/ggml/src/ggml-vulkan
Qualcomm Hexagon NPU
QNN solution
aka End-to-End solution, which is similar to the Qualcomm's official AI-Hub solution.
Fig-1: cited from Qualcomm's QNN SDK Manual
QNN solution based fully/semi open source projects:
llama.cpp solution
a specified ggml backend for llama.cpp on Android. Theoretically speaking, model preparation/conversion is not needed in this solution, which is exactly similar to ggml-cuda,ggml-metal,ggml-sycl,ggml-opencl,ggml-cann,ggml-vulkan.
Fig-2: cited from Qualcomm's Hexagon SDK Programmers_Reference_Manual
libggml-hexagons.so(running on ARM CPU side): ggml-hexagon.cpp + stub.c
libggmldsp_skel.so(running on DSP side): ggmldsp.c + skel.c + add.c + mulmat.c + ... ( developers and AI experts can operate hardware directly on DSP side)
Fig-3: self-made
llama.cpp solution based open source projects:
Part 4: LLamacpp based Android APPs
llama.cpp based Androd APPs
Part 5: State-of-the-art on-device LLM models
Google gemma-3n:
HuggingFace SmolVLM:
Part 6: Mobile SoC References
Part 7: Acknowledgement
AI inference framework-
GGML(as a programmer whom believe the philosophy of "simple is beautiful" which comes from the great Unix, I personally/always think it's another FFmpeg since 03/2024 and I like it very much although there are many AI inference frameworks from big IT tech giants)
AI application engine-
ASR engine whisper.cpp
-
LLM engine llama.cpp
-
CV engine opencv-mobile
-
MTMD(multimodal) engine MTMD subsystem in llama.cpp
Qualcomm- help on 04/04/2024 from a software engineer at Quic(Qualcomm Innovation Center)
a breakthrough help in my initial PoC of ggml-qnn which launched on 03/2024
- reminder/help on 03/19/2025 from a staff tech expert at Qualcomm
a breakthrough reminder/help that told me "QNN is not the right solution here", then ggml-hexagon(HWACCEL_CDSP) appeared
References- https://mp.weixin.qq.com/s/1lUSlc0tvEWLuOFOP0WkUA (zh)
- https://github.com/ngxson/smolvlm-realtime-webcam
Disclaimer
I'm an experienced full-stack(from kernel, framework to APP) Android programmer, but I don't know anything about hardcore AI tech.
Correction and guidance from developers/domain experts/AI experts are greatly welcomed and appreciated.
All reactions