File size: 3,808 Bytes
fd5eade
 
 
 
 
 
 
b461289
 
fd5eade
 
 
b461289
 
 
 
 
 
 
fd5eade
 
 
b461289
 
 
 
 
fd5eade
 
 
 
 
 
 
 
 
 
 
b461289
fd5eade
b461289
fd5eade
 
 
 
 
 
 
 
b461289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd5eade
b461289
fd5eade
3472d91
fd5eade
b461289
fd5eade
b461289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
base_model: openbmb/MiniCPM5-2B
library_name: llama.cpp
---

# MiniCPM5-2B on AX8860 (llama.cpp + ggml-axera)

在爱芯 AX8860 的 NPU 上用 llama.cpp 运行 MiniCPM5-2B 文本模型:思考开关、工具调用,OpenAI 兼容服务。
MiniCPM5-2B on the Axera AX8860 NPU with llama.cpp: text model with a thinking switch, tool calling and an OpenAI-compatible server.

## 性能 / Performance

| | |
|---|---|
| decode | **59.5 tokens/s** |
| 4k prompt prefill | **6219 tokens/s**(3907 token 0.63 s) |
| 上下文 / context | 最长 / up to 131072 |

`sh bench.sh` 复现 / reproduce(生成 50 token / 50 generated tokens):

| prompt | `-c` | prompt 耗时 / time | decode tokens/s |
|---|---:|---:|---:|
| 5 token | 8192 | 0.04 s | 59.5 |
| 46 token | 8192 | 0.05 s | 59.2 |
| 3907 token | 8192 | 0.63 s | 51.9 |
| 5 token | 131072 | 0.04 s | 59.2 |
| 3907 token | 131072 | 0.63 s | 52.1 |

## 快速开始 / Quick start

```sh
sh run.sh "The capital of France is" 64     # 文本补全 / completion
sh run.sh -c                                # 命令行对话 / chat
sh run.sh -s 8080                           # OpenAI 兼容服务 / server
sh bench.sh                                 # 性能复现 / benchmark
sh bench.sh ppl                             # 困惑度 / perplexity
```

需要 AX8860,SDK V0.5.1 或更新;HF 下载的文件没有执行权限,用 `sh` 调用即可 / needs an AX8860 with SDK V0.5.1+; call the scripts with `sh`.

服务请求 / Server request:

```sh
curl http://127.0.0.1:8080/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "messages": [{"role": "user", "content": "用一句话介绍长江"}],
  "chat_template_kwargs": {"enable_thinking": false}
}'
```

## 文件 / Files

| 文件 / File | 说明 / Description |
|---|---|
| `MiniCPM5-2B-Q8_0.gguf` | 模型权重(官方 Q8_0)/ weights (official Q8_0),2.68 GB,md5 `57e37e3fd7758a9e4f7c687cf5c0e257` |
| `bin/` | llama.cpp 板端程序(静态链接)/ board programs (static) |
| `kernels/` | NPU kernel 2 个:prefill、decode(含输出头)+ `manifest.json` / two kernels: prefill and decode (with the output head) + `manifest.json` |
| `run.sh`,`chat_template.jinja` | 运行脚本与服务端对话模板 / run script and the server's chat template |
| `bench.sh` 及 prompt | 性能与困惑度复现 / benchmark and perplexity |

## 说明 / Notes

- 权重在加载时由 GGUF 转成 MXFP8,KV 为 BF16;Q8_0 与 F16 GGUF 都可加载 / weights are converted from the GGUF to MXFP8 at load, with a BF16 KV cache; both Q8_0 and F16 GGUFs load.
- 一套 kernel 覆盖到 131072 上下文,KV 按 `-c` 分配;用环境变量 `CTX` 调整 / one kernel set covers up to 131072 tokens and allocates the KV by `-c`; set `CTX` to change it.
- 思考开关用 `chat_template_kwargs.enable_thinking`;工具调用使用包内 `chat_template.jinja` / toggle thinking with `chat_template_kwargs.enable_thinking`; tool calling uses the bundled `chat_template.jinja`.
- 没有 MTP 头,不支持 MTP 投机解码 / no MTP head, so no MTP speculative decoding.
- `run.sh -c` 需要真实终端 / chat mode needs an interactive terminal.
- 运行时独占 NPU 4 核;服务端 `-np 1` / takes all 4 NPU cores; the server runs `-np 1`.

## 正确性 / Correctness

- 文本补全、服务端对话与思考开关在板上工作正常 / completion, server chat and the thinking switch work on the board.
- PPL(`sh bench.sh ppl`,`-c 512`)/ perplexity:

| 语言 / language | `-ub 1` | `-ub 4` |
|---|---:|---:|
| 中文 / zh | 16.70 | 16.72 |
| 英文 / en | 13.33 | 13.44 |

## 源码 / Sources

- llama.cpp:[ZHEQIUSHUI/llama.cpp](https://github.com/ZHEQIUSHUI/llama.cpp) @ `6613735ce`

## 更新 / Changelog

- 2026-11-15:首次发布 / first release.