【“星瑞” O6 评测】 — llm CPU部署对比高通骁龙CPU
前言
随着大模型应用场景的不断拓展,arm cpu 凭借其独特优势在大模型推理领域的重要性日益凸显。它在性能、功耗、架构适配等多方面发挥关键作用,推动大模型在不同场景落地
1. CPU对比
星睿 O6 CPU 采用 Armv9 架构,集成了 Arm®v9 CPU 核心、Arm Immortalis™ GPU 及安谋科技 “周易” NPU 等。其中,“周易” NPU 算力可达 30TOPS,在处理 AI 相关任务时,异构的架构能让 CPU、GPU、NPU 协同工作,加速 AI 模型的运行。骁龙 8 Elite 采用 2+6 架构设计,首次运用专为智能手机打造的第二代自研 Oryon CPU 架构。两颗超大核频率为 4.32GHz,六颗大核频率为 3.53GHz,每个 CPU 丛集都配备了较大缓存,还引入全新的数据时序预取器以及全新的性能内核设计,在通用计算性能上表现强劲。
这里我们让二者通过llama.cpp跑同样模型的推理速度对比
2. 星瑞O6跑llama.cpp
参阅:https://aijishu.com/a/1060000000507877
3. 骁龙8 Elite跑llama.cpp
3.1 依赖安装
## 1.安装[termux](https://termux.dev/en/)app,配置ssh,## 2.安装编译环境
apt update && apt upgrade -y
apt install git cmake
3.2 不开启klelidiAI优化
cmake -B build
cmake --build build --config Release -j
3.2 验证模型正确性
还是使用“星瑞” O6 评测 —— CPU llama.cpp不同优化速度对比转换的模型
taskset -c 0,3,4,5,6,7 ./build_kle/bin/llama-cli -m asserts/Qwen2.5-3B-Instruct-Q4_0.gguf -c 4096 -t 6 --conversation
打印信息
> hello
Hello! How can I assist you today? Do you have any questions or topics you'd like to discuss?>
llama_perf_sampler_print: sampling time = 2.79 ms / 32 runs ( 0.09 ms per token, 11477.76 tokens per second)
llama_perf_context_print: load time = 498.94 ms
llama_perf_context_print: prompt eval time = 592.82 ms / 9 tokens ( 65.87 ms per token, 15.18 tokens per second)
llama_perf_context_print: eval time = 1711.00 ms / 22 runs ( 77.77 ms per token, 12.86 tokens per second)
llama_perf_context_print: total time = 6498.13 ms / 31 tokens
Interrupted by user
3.3 不开启klelidiAI优化的benchmark
taskset -c 0,1,2,3,4,5,6,7 ./build/bin/llama-bench -m asserts/Qwen2.5-3B-Instruct-Q4_0.gguf -p 128 -n 128 -t 8
用[0,2,3,4,5,6,7]7个核心的结果
model | size | params | backend | threads | test | t/s |
---|---|---|---|---|---|---|
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 7 | pp128 | 63.59 ± 0.31 |
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 7 | tg128 | 10.87 ± 0.37 |
用8个核心的结果
model | size | params | backend | threads | test | t/s |
---|---|---|---|---|---|---|
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 8 | pp128 | 72.39 ± 1.43 |
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 8 | tg128 | 9.99 ± 1.02 |
3.5 开启kleidiai优化的benchmark
kleidiai已经集成到llama.cpp的后端,只需要编译时给定正确的选项就行。
cmake -B build_kle -DGGML_CPU_KLEIDIAI=ON
cmake --build build_kle --config Release -j
benchmark命令: taskset -c 0,2,3,4,5,6,7 ./build_kle/bin/llama-bench -m asserts/Qwen2.5-3B-Instruct-Q4_0.gguf -p 128 -n 128 -t 7
用[0,2,3,4,5,6,7]7个核心的结果
model | size | params | backend | threads | test | t/s |
---|---|---|---|---|---|---|
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 7 | pp128 | 61.55 ± 0.10 |
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 7 | tg128 | 10.41 ± 0.13 |
用8个核心的结果
model | size | params | backend | threads | test | t/s |
---|---|---|---|---|---|---|
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 8 | pp128 | 69.05 ± 0.88 |
qwen2 3B Q4_0 | 1.69 GiB | 3.09 B | CPU | 8 | tg128 | 9.68 ± 0.16 |
打印中有load_tensors: CPU_KLEIDIAI model buffer size = 1488.38 MiB
和KLEIDIAI = 1
表明编译选项正确打开。
4.总结
从推理速度来看:星瑞O6在同样的核心数量时,推理速度更快。而且星瑞O6共有12个CPU核。
5.疑问
- 从主频来看高通的主频更高,理论上推理速度应该更快。
- 不知道用高通的qnn cpu后端能否比llama.cpp推理更快。